Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,29 @@ import json
|
|
23 |
import numpy as np
|
24 |
import gradio as gr
|
25 |
|
|
|
26 |
CHOICES = ["SNOMED", "LOINC", "CQM"]
|
27 |
JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu": 0.55,"batters":{"batter":[{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1003", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }]},"topping":[{ "id": "5001", "type": "None" },{ "id": "5002", "type": "Glazed" },{ "id": "5005", "type": "Sugar" },{ "id": "5007", "type": "Powdered Sugar" },{ "id": "5006", "type": "Chocolate with Sprinkles" },{ "id": "5003", "type": "Chocolate" },{ "id": "5004", "type": "Maple" }]}]}}"""
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
#def lowercase_title(example):
|
30 |
# return {"Description": example[title].lower()}
|
31 |
|
@@ -36,13 +56,16 @@ JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu"
|
|
36 |
#def fn( text1, text2, num, slider1, slider2, single_checkbox, checkboxes, radio, dropdown, im1, im2, im3, im4,
|
37 |
# video, audio1, audio2, file, df1, df2,):
|
38 |
def fn( text1, text2, single_checkbox, checkboxes, radio, im4, file, df1, df2,):
|
|
|
39 |
searchTerm = text1
|
40 |
searchTermSentence = text2
|
41 |
-
|
42 |
start_with_searchTermLOINC = datasetLOINC.filter(lambda example: example["Description"].startswith('Allergy')) #Allergy
|
43 |
start_with_searchTermSNOMED = datasetSNOMED.filter(lambda example: example["Description"].startswith('Hospital')) #Hospital
|
44 |
start_with_searchTermCQM = dataseteCQM.filter(lambda example: example["Description"].startswith('Telephone')) #Telephone
|
45 |
|
|
|
|
|
46 |
try:
|
47 |
top1matchLOINC = json.loads(start_with_searchTermLOINC['train'][0])
|
48 |
top1matchSNOMED = json.loads(start_with_searchTermSNOMED['train'][0])
|
@@ -51,7 +74,8 @@ def fn( text1, text2, single_checkbox, checkboxes, radio, im4,
|
|
51 |
print(start_with_searchTermLOINC)
|
52 |
print(start_with_searchTermSNOMED )
|
53 |
print(start_with_searchTermCQM )
|
54 |
-
|
|
|
55 |
|
56 |
return (
|
57 |
#(text1 if single_checkbox else text2) + ", selected:" + ", ".join(checkboxes), # Text
|
|
|
23 |
import numpy as np
|
24 |
import gradio as gr
|
25 |
|
26 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
27 |
CHOICES = ["SNOMED", "LOINC", "CQM"]
|
28 |
JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu": 0.55,"batters":{"batter":[{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1003", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }]},"topping":[{ "id": "5001", "type": "None" },{ "id": "5002", "type": "Glazed" },{ "id": "5005", "type": "Sugar" },{ "id": "5007", "type": "Powdered Sugar" },{ "id": "5006", "type": "Chocolate with Sprinkles" },{ "id": "5003", "type": "Chocolate" },{ "id": "5004", "type": "Maple" }]}]}}"""
|
29 |
|
30 |
+
|
31 |
+
def profile_dataset(dataset=datasetSNOMED, username="awacke1", token=HF_TOKEN, dataset_name="awacke1/SNOMED-CT-Code-Value-Semantic-Set.csv"):
|
32 |
+
df = pd.read_csv(dataset.name)
|
33 |
+
if len(df.columns) <= 15:
|
34 |
+
profile = pp.ProfileReport(df, title=f"{dataset_name} Report")
|
35 |
+
else:
|
36 |
+
profile = pp.ProfileReport(df, title=f"{dataset_name} Report", minimal = True)
|
37 |
+
|
38 |
+
repo_url = create_repo(f"{username}/{dataset_name}", repo_type = "space", token = token, space_sdk = "static", private=False)
|
39 |
+
|
40 |
+
profile.to_file("./index.html")
|
41 |
+
|
42 |
+
upload_file(path_or_fileobj ="./index.html", path_in_repo = "index.html", repo_id =f"{username}/{dataset_name}", repo_type = "space", token=token)
|
43 |
+
readme = f"---\ntitle: {dataset_name}\nemoji: ✨\ncolorFrom: green\ncolorTo: red\nsdk: static\npinned: false\ntags:\n- dataset-report\n---"
|
44 |
+
with open("README.md", "w+") as f:
|
45 |
+
f.write(readme)
|
46 |
+
upload_file(path_or_fileobj ="./README.md", path_in_repo = "README.md", repo_id =f"{username}/{dataset_name}", repo_type = "space", token=token)
|
47 |
+
return f"Your dataset report will be ready at {repo_url}"
|
48 |
+
|
49 |
#def lowercase_title(example):
|
50 |
# return {"Description": example[title].lower()}
|
51 |
|
|
|
56 |
#def fn( text1, text2, num, slider1, slider2, single_checkbox, checkboxes, radio, dropdown, im1, im2, im3, im4,
|
57 |
# video, audio1, audio2, file, df1, df2,):
|
58 |
def fn( text1, text2, single_checkbox, checkboxes, radio, im4, file, df1, df2,):
|
59 |
+
|
60 |
searchTerm = text1
|
61 |
searchTermSentence = text2
|
62 |
+
|
63 |
start_with_searchTermLOINC = datasetLOINC.filter(lambda example: example["Description"].startswith('Allergy')) #Allergy
|
64 |
start_with_searchTermSNOMED = datasetSNOMED.filter(lambda example: example["Description"].startswith('Hospital')) #Hospital
|
65 |
start_with_searchTermCQM = dataseteCQM.filter(lambda example: example["Description"].startswith('Telephone')) #Telephone
|
66 |
|
67 |
+
returnMsg=profile_dataset()
|
68 |
+
print(returnMsg)
|
69 |
try:
|
70 |
top1matchLOINC = json.loads(start_with_searchTermLOINC['train'][0])
|
71 |
top1matchSNOMED = json.loads(start_with_searchTermSNOMED['train'][0])
|
|
|
74 |
print(start_with_searchTermLOINC)
|
75 |
print(start_with_searchTermSNOMED )
|
76 |
print(start_with_searchTermCQM )
|
77 |
+
print(returnMsg)
|
78 |
+
print("Datasets Processed")
|
79 |
|
80 |
return (
|
81 |
#(text1 if single_checkbox else text2) + ", selected:" + ", ".join(checkboxes), # Text
|