Mark7549 commited on
Commit
46e623d
·
1 Parent(s): 554cc8f

updated the way words are displayed in dictionary

Browse files
Files changed (2) hide show
  1. app.py +6 -2
  2. lsj_dict.py +19 -0
app.py CHANGED
@@ -185,8 +185,12 @@ elif active_tab == "Dictionary":
185
  data = lemma_dict[query_tag[0].capitalize()]
186
  else:
187
  st.error("Word not found in dictionary")
188
-
189
- st.write(data)
 
 
 
 
190
 
191
 
192
 
 
185
  data = lemma_dict[query_tag[0].capitalize()]
186
  else:
187
  st.error("Word not found in dictionary")
188
+
189
+ # Put text in readable format
190
+ text = format_text(data)
191
+
192
+ st.markdown(text)
193
+
194
 
195
 
196
 
lsj_dict.py CHANGED
@@ -104,6 +104,19 @@ def full_dictionary():
104
  return merged_info
105
 
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  def main():
108
  # xml_info = read_xml("LSJ_GreekUnicode/grc.lsj.perseus-eng2.xml")
109
 
@@ -137,7 +150,13 @@ def main():
137
 
138
 
139
 
 
 
 
 
140
 
 
 
141
 
142
 
143
 
 
104
  return merged_info
105
 
106
 
107
+ def format_text(data):
108
+ text = data['definitions']['text']
109
+
110
+ # Change <tr> tags to bold
111
+ text = text.replace("<tr>", "**").replace("</tr>", "**")
112
+
113
+ # Change [SENSE_SEPARATOR] to integers
114
+ for i in range(len(text.split("[SENSE_SEPARATOR]"))):
115
+ text = text.replace("[SENSE_SEPARATOR]", f"{i+1}.")
116
+
117
+ return text
118
+
119
+
120
  def main():
121
  # xml_info = read_xml("LSJ_GreekUnicode/grc.lsj.perseus-eng2.xml")
122
 
 
150
 
151
 
152
 
153
+ lemma_dict = json.load(open('lsj_dict.json', 'r'))
154
+
155
+ print_test(lemma_dict)
156
+
157
 
158
+ def print_test(lemma_dict):
159
+ print(lemma_dict["βομβάζω"])
160
 
161
 
162