Update app.py
Browse files
app.py
CHANGED
@@ -3,32 +3,31 @@ import pandas as pd
|
|
3 |
|
4 |
# Load and parse the CSV file from Hugging Face
|
5 |
def load_data():
|
6 |
-
url = "https://huggingface.co/datasets/unijoh/RAVNlex/
|
|
|
7 |
lemmas = {}
|
8 |
current_lemma = None
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
}
|
31 |
-
lemmas[current_lemma].append(lemma_data)
|
32 |
|
33 |
print("Loaded lemmas:", lemmas) # Debugging output
|
34 |
return lemmas
|
|
|
3 |
|
4 |
# Load and parse the CSV file from Hugging Face
|
5 |
def load_data():
|
6 |
+
url = "https://huggingface.co/datasets/unijoh/RAVNlex/resolve/main/RAVNlex_small.csv"
|
7 |
+
df = pd.read_csv(url, delimiter='\t', encoding='iso-8859-10', dtype=str)
|
8 |
lemmas = {}
|
9 |
current_lemma = None
|
10 |
|
11 |
+
for row in df.itertuples(index=False, name=None):
|
12 |
+
if len(row) < 5:
|
13 |
+
print(f"Skipping problematic line: {row}")
|
14 |
+
continue
|
15 |
+
orto, ppos, phon1, phon2, comm, *pronunciations = row
|
16 |
+
if orto == '---':
|
17 |
+
current_lemma = None
|
18 |
+
elif current_lemma is None:
|
19 |
+
current_lemma = orto.replace("ORTO:", "")
|
20 |
+
lemmas[current_lemma] = []
|
21 |
+
else:
|
22 |
+
lemma_data = {
|
23 |
+
'word': orto.replace("ORTO:", "") if orto else "",
|
24 |
+
'PPOS': ppos.replace("PPOS:", "") if ppos else "",
|
25 |
+
'PHON1': phon1.replace("PHON:", "") if phon1 else "",
|
26 |
+
'PHON2': phon2.replace("PHON:", "") if phon2 else "",
|
27 |
+
'COMM': comm if comm else "",
|
28 |
+
'pronunciations': pronunciations
|
29 |
+
}
|
30 |
+
lemmas[current_lemma].append(lemma_data)
|
|
|
|
|
31 |
|
32 |
print("Loaded lemmas:", lemmas) # Debugging output
|
33 |
return lemmas
|