unijoh commited on
Commit
971f291
·
verified ·
1 Parent(s): 5b716cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
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/resolve/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,16 +31,16 @@ lemmas = load_data()
31
 
32
  def create_noun_table(lemma, forms):
33
  table_data = {
34
- 'Nsns': '', 'Nsnst': '', 'Nsas': '', 'Nsast': '',
35
- 'Nsds': '', 'Nsdst': '', 'Nsgs': '', 'Nsgst': '',
36
- 'Npns': '', 'Npnst': '', 'Npas': '', 'Npast': '',
37
- 'Npds': '', 'Npdt': '', 'Npgs': '', 'Npgst': ''
38
  }
39
 
40
  for form in forms:
41
- ppos = form['PPOS']
42
  word = form['word']
43
- key = ppos[1:5] # 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,28 +63,28 @@ def create_noun_table(lemma, forms):
63
  </thead>
64
  <tbody>
65
  <tr>
66
- <td>{table_data['Nsns']}</td>
67
- <td>{table_data['Nsnst']}</td>
68
- <td>{table_data['Npns']}</td>
69
- <td>{table_data['Npnst']}</td>
70
  </tr>
71
  <tr>
72
- <td>{table_data['Nsas']}</td>
73
- <td>{table_data['Nsast']}</td>
74
- <td>{table_data['Npas']}</td>
75
- <td>{table_data['Npast']}</td>
76
  </tr>
77
  <tr>
78
- <td>{table_data['Nsds']}</td>
79
- <td>{table_data['Nsdst']}</td>
80
- <td>{table_data['Npds']}</td>
81
- <td>{table_data['Npdt']}</td>
82
  </tr>
83
  <tr>
84
- <td>{table_data['Nsgs']}</td>
85
- <td>{table_data['Nsgst']}</td>
86
- <td>{table_data['Npgs']}</td>
87
- <td>{table_data['Npgst']}</td>
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 'N' in results[0]['PPOS']:
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."