Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,51 @@
|
|
|
|
|
| 1 |
import json
|
| 2 |
-
import
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
DATA = json.load(f)
|
| 13 |
|
| 14 |
# ---------------------
|
| 15 |
# Build searchable text
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download
|
| 2 |
import json
|
| 3 |
+
import pandas as pd
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
+
REPO_ID = "ashutoshzade/EIRKG"
|
| 7 |
|
| 8 |
+
# CHANGE THIS TO YOUR ACTUAL FILE
|
| 9 |
+
FILENAME = "YOUR_JSON_FILENAME.json"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def load_dataset():
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
|
| 16 |
+
print("Downloading EIRKG dataset...")
|
| 17 |
+
|
| 18 |
+
path = hf_hub_download(
|
| 19 |
+
repo_id=REPO_ID,
|
| 20 |
+
repo_type="dataset",
|
| 21 |
+
filename=FILENAME
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
print("Success!")
|
| 25 |
+
|
| 26 |
+
if FILENAME.endswith(".json"):
|
| 27 |
+
with open(path,"r",encoding="utf-8") as f:
|
| 28 |
+
return json.load(f)
|
| 29 |
+
|
| 30 |
+
if FILENAME.endswith(".jsonl"):
|
| 31 |
+
data=[]
|
| 32 |
+
with open(path,"r",encoding="utf-8") as f:
|
| 33 |
+
for line in f:
|
| 34 |
+
data.append(json.loads(line))
|
| 35 |
+
return data
|
| 36 |
+
|
| 37 |
+
if FILENAME.endswith(".csv"):
|
| 38 |
+
return pd.read_csv(path).to_dict("records")
|
| 39 |
+
|
| 40 |
+
except Exception as e:
|
| 41 |
+
|
| 42 |
+
print(e)
|
| 43 |
+
|
| 44 |
+
return []
|
| 45 |
+
|
| 46 |
+
DATA = load_dataset()
|
| 47 |
|
| 48 |
+
print(len(DATA))
|
|
|
|
| 49 |
|
| 50 |
# ---------------------
|
| 51 |
# Build searchable text
|