Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
import csv
|
4 |
|
5 |
# Load and parse the CSV file from Hugging Face
|
6 |
def load_data():
|
@@ -9,12 +8,12 @@ def load_data():
|
|
9 |
current_lemma = None
|
10 |
|
11 |
with open(url, 'r', encoding='iso-8859-10') as file:
|
12 |
-
reader =
|
13 |
-
for row in reader:
|
14 |
-
if len(row)
|
15 |
print(f"Skipping problematic line {reader.line_num}: {row}")
|
16 |
continue
|
17 |
-
orto, ppos, phon1, phon2, comm = row
|
18 |
if orto == '---':
|
19 |
current_lemma = None
|
20 |
elif current_lemma is None:
|
@@ -26,7 +25,8 @@ def load_data():
|
|
26 |
'PPOS': ppos.replace("PPOS:", "") if ppos else "",
|
27 |
'PHON1': phon1.replace("PHON:", "") if phon1 else "",
|
28 |
'PHON2': phon2.replace("PHON:", "") if phon2 else "",
|
29 |
-
'COMM': comm if comm else ""
|
|
|
30 |
}
|
31 |
lemmas[current_lemma].append(lemma_data)
|
32 |
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
# Load and parse the CSV file from Hugging Face
|
5 |
def load_data():
|
|
|
8 |
current_lemma = None
|
9 |
|
10 |
with open(url, 'r', encoding='iso-8859-10') as file:
|
11 |
+
reader = pd.read_csv(file, delimiter='\t', encoding='iso-8859-10', dtype=str, quoting=csv.QUOTE_NONE)
|
12 |
+
for row in reader.itertuples(index=False, name=None):
|
13 |
+
if len(row) < 5:
|
14 |
print(f"Skipping problematic line {reader.line_num}: {row}")
|
15 |
continue
|
16 |
+
orto, ppos, phon1, phon2, comm, *pronunciations = row
|
17 |
if orto == '---':
|
18 |
current_lemma = None
|
19 |
elif current_lemma is None:
|
|
|
25 |
'PPOS': ppos.replace("PPOS:", "") if ppos else "",
|
26 |
'PHON1': phon1.replace("PHON:", "") if phon1 else "",
|
27 |
'PHON2': phon2.replace("PHON:", "") if phon2 else "",
|
28 |
+
'COMM': comm if comm else "",
|
29 |
+
'pronunciations': pronunciations
|
30 |
}
|
31 |
lemmas[current_lemma].append(lemma_data)
|
32 |
|