Spaces:
Build error
Build error
Sam Passaglia
commited on
Commit
•
65d65b7
1
Parent(s):
94492dd
update column name
Browse files
app.py
CHANGED
@@ -68,13 +68,15 @@ def get_stats():
|
|
68 |
|
69 |
# if reading != '<OTHER>'
|
70 |
|
71 |
-
df = pd.DataFrame(
|
|
|
|
|
72 |
|
73 |
df = df[df["readings"].str.contains("、")]
|
74 |
|
75 |
df["readings"] = df["readings"].str.replace("<OTHER>", "Other")
|
76 |
|
77 |
-
df = df.rename(columns={"readings": "readings (
|
78 |
|
79 |
df = df.sort_values("accuracy", ascending=False, ignore_index=True)
|
80 |
|
@@ -113,7 +115,7 @@ def furigana_to_spacy(text_with_furigana):
|
|
113 |
}
|
114 |
|
115 |
|
116 |
-
st.title("Yomikata: Disambiguate Japanese Heteronyms
|
117 |
|
118 |
# Input text box
|
119 |
st.markdown("Input a Japanese sentence:")
|
@@ -137,10 +139,14 @@ label_colors = {
|
|
137 |
reading: colors[i % len(colors)]
|
138 |
for i, reading in enumerate(set([item["label"] for item in spacy_dict["ents"]]))
|
139 |
}
|
140 |
-
html = spacy.displacy.render(
|
|
|
|
|
141 |
|
142 |
if len(spacy_dict["ents"]) > 0:
|
143 |
-
st.markdown(
|
|
|
|
|
144 |
st.write(
|
145 |
f"{add_border(html)}",
|
146 |
unsafe_allow_html=True,
|
@@ -184,11 +190,15 @@ if st.button("🎲 Randomize the input sentence"):
|
|
184 |
global_accuracy, stats_df = get_stats()
|
185 |
|
186 |
st.subheader(
|
187 |
-
f"{len(stats_df)} heteronyms
|
188 |
)
|
189 |
|
190 |
st.dataframe(stats_df)
|
191 |
|
|
|
|
|
|
|
|
|
192 |
# Hide the footer
|
193 |
hide_streamlit_style = """
|
194 |
<style>
|
|
|
68 |
|
69 |
# if reading != '<OTHER>'
|
70 |
|
71 |
+
df = pd.DataFrame(
|
72 |
+
{"heteronym": heteronyms, "accuracy": accuracy, "readings": readings}
|
73 |
+
)
|
74 |
|
75 |
df = df[df["readings"].str.contains("、")]
|
76 |
|
77 |
df["readings"] = df["readings"].str.replace("<OTHER>", "Other")
|
78 |
|
79 |
+
df = df.rename(columns={"readings": "readings (correct/total)"})
|
80 |
|
81 |
df = df.sort_values("accuracy", ascending=False, ignore_index=True)
|
82 |
|
|
|
115 |
}
|
116 |
|
117 |
|
118 |
+
st.title("Yomikata: Disambiguate Japanese Heteronyms")
|
119 |
|
120 |
# Input text box
|
121 |
st.markdown("Input a Japanese sentence:")
|
|
|
139 |
reading: colors[i % len(colors)]
|
140 |
for i, reading in enumerate(set([item["label"] for item in spacy_dict["ents"]]))
|
141 |
}
|
142 |
+
html = spacy.displacy.render(
|
143 |
+
spacy_dict, style="ent", manual=True, options={"colors": label_colors}
|
144 |
+
)
|
145 |
|
146 |
if len(spacy_dict["ents"]) > 0:
|
147 |
+
st.markdown(
|
148 |
+
"**Yomikata** disambiguated the following words with multiple readings:"
|
149 |
+
)
|
150 |
st.write(
|
151 |
f"{add_border(html)}",
|
152 |
unsafe_allow_html=True,
|
|
|
190 |
global_accuracy, stats_df = get_stats()
|
191 |
|
192 |
st.subheader(
|
193 |
+
f"**Yomikata** supports {len(stats_df)} heteronyms, with a global accuracy of {global_accuracy:.0%}!"
|
194 |
)
|
195 |
|
196 |
st.dataframe(stats_df)
|
197 |
|
198 |
+
st.subheader(
|
199 |
+
"Check out **Yomikata** on [GitHub](https://github.com/passaglia/yomikata) today!"
|
200 |
+
)
|
201 |
+
|
202 |
# Hide the footer
|
203 |
hide_streamlit_style = """
|
204 |
<style>
|