Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ 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 |
df = pd.read_csv(url, delimiter='\t', encoding='iso-8859-10', names=["#ORTO", "#PPOS", "#PHON1", "#PHON2", "#COMM"], dtype=str)
|
| 8 |
lemmas = {}
|
| 9 |
current_lemma = None
|
|
@@ -31,16 +31,16 @@ lemmas = load_data()
|
|
| 31 |
|
| 32 |
def create_noun_table(lemma, forms):
|
| 33 |
table_data = {
|
| 34 |
-
'
|
| 35 |
-
'
|
| 36 |
-
'
|
| 37 |
-
'
|
| 38 |
}
|
| 39 |
|
| 40 |
for form in forms:
|
| 41 |
-
ppos = form['PPOS']
|
| 42 |
word = form['word']
|
| 43 |
-
key = ppos[
|
| 44 |
print(f"Processing: word={word}, ppos={ppos}, key={key}") # Debugging output
|
| 45 |
if key in table_data:
|
| 46 |
table_data[key] = word
|
|
@@ -63,28 +63,28 @@ def create_noun_table(lemma, forms):
|
|
| 63 |
</thead>
|
| 64 |
<tbody>
|
| 65 |
<tr>
|
| 66 |
-
<td>{table_data['
|
| 67 |
-
<td>{table_data['
|
| 68 |
-
<td>{table_data['
|
| 69 |
-
<td>{table_data['
|
| 70 |
</tr>
|
| 71 |
<tr>
|
| 72 |
-
<td>{table_data['
|
| 73 |
-
<td>{table_data['
|
| 74 |
-
<td>{table_data['
|
| 75 |
-
<td>{table_data['
|
| 76 |
</tr>
|
| 77 |
<tr>
|
| 78 |
-
<td>{table_data['
|
| 79 |
-
<td>{table_data['
|
| 80 |
-
<td>{table_data['
|
| 81 |
-
<td>{table_data['
|
| 82 |
</tr>
|
| 83 |
<tr>
|
| 84 |
-
<td>{table_data['
|
| 85 |
-
<td>{table_data['
|
| 86 |
-
<td>{table_data['
|
| 87 |
-
<td>{table_data['
|
| 88 |
</tr>
|
| 89 |
</tbody>
|
| 90 |
</table>
|
|
@@ -98,7 +98,7 @@ def search_lemma(lemma):
|
|
| 98 |
print(f"No results found for {lemma}") # Debugging output
|
| 99 |
return f"No results found for {lemma}"
|
| 100 |
|
| 101 |
-
if '
|
| 102 |
table = create_noun_table(lemma, results)
|
| 103 |
else:
|
| 104 |
table = "Only noun tables are currently supported."
|
|
|
|
| 3 |
|
| 4 |
# Load and parse the CSV file from Hugging Face
|
| 5 |
def load_data():
|
| 6 |
+
url = "https://huggingface.co/datasets/unijoh/RAVNlex/blob/main/RAVNlex_small.csv"
|
| 7 |
df = pd.read_csv(url, delimiter='\t', encoding='iso-8859-10', names=["#ORTO", "#PPOS", "#PHON1", "#PHON2", "#COMM"], dtype=str)
|
| 8 |
lemmas = {}
|
| 9 |
current_lemma = None
|
|
|
|
| 31 |
|
| 32 |
def create_noun_table(lemma, forms):
|
| 33 |
table_data = {
|
| 34 |
+
'ncmns': '', 'ncmsn==duu': '', 'ncmsa': '', 'ncmsa==duu': '',
|
| 35 |
+
'ncmsd': '', 'ncmsd==duu': '', 'ncmsg': '', 'ncmsg==dou': '',
|
| 36 |
+
'ncmpn': '', 'ncmpn==duu': '', 'ncmpa': '', 'ncmpa==duu': '',
|
| 37 |
+
'ncmpd': '', 'ncmpd==duu': '', 'ncmpg': '', 'ncmpg==dou': ''
|
| 38 |
}
|
| 39 |
|
| 40 |
for form in forms:
|
| 41 |
+
ppos = form['PPOS'].lower() # Normalize to lowercase
|
| 42 |
word = form['word']
|
| 43 |
+
key = ppos.split('=')[0] # Extracting relevant part of PPOS
|
| 44 |
print(f"Processing: word={word}, ppos={ppos}, key={key}") # Debugging output
|
| 45 |
if key in table_data:
|
| 46 |
table_data[key] = word
|
|
|
|
| 63 |
</thead>
|
| 64 |
<tbody>
|
| 65 |
<tr>
|
| 66 |
+
<td>{table_data['ncmns']}</td>
|
| 67 |
+
<td>{table_data['ncmsn==duu']}</td>
|
| 68 |
+
<td>{table_data['ncmpn']}</td>
|
| 69 |
+
<td>{table_data['ncmpn==duu']}</td>
|
| 70 |
</tr>
|
| 71 |
<tr>
|
| 72 |
+
<td>{table_data['ncmsa']}</td>
|
| 73 |
+
<td>{table_data['ncmsa==duu']}</td>
|
| 74 |
+
<td>{table_data['ncmpa']}</td>
|
| 75 |
+
<td>{table_data['ncmpa==duu']}</td>
|
| 76 |
</tr>
|
| 77 |
<tr>
|
| 78 |
+
<td>{table_data['ncmsd']}</td>
|
| 79 |
+
<td>{table_data['ncmsd==duu']}</td>
|
| 80 |
+
<td>{table_data['ncmpd']}</td>
|
| 81 |
+
<td>{table_data['ncmpd==duu']}</td>
|
| 82 |
</tr>
|
| 83 |
<tr>
|
| 84 |
+
<td>{table_data['ncmsg']}</td>
|
| 85 |
+
<td>{table_data['ncmsg==dou']}</td>
|
| 86 |
+
<td>{table_data['ncmpg']}</td>
|
| 87 |
+
<td>{table_data['ncmpg==dou']}</td>
|
| 88 |
</tr>
|
| 89 |
</tbody>
|
| 90 |
</table>
|
|
|
|
| 98 |
print(f"No results found for {lemma}") # Debugging output
|
| 99 |
return f"No results found for {lemma}"
|
| 100 |
|
| 101 |
+
if 'n' in results[0]['PPOS'].lower():
|
| 102 |
table = create_noun_table(lemma, results)
|
| 103 |
else:
|
| 104 |
table = "Only noun tables are currently supported."
|