Colorier les Tags autres que "O"
Browse files
app.py
CHANGED
@@ -92,8 +92,16 @@ def tag_sentence(text):
|
|
92 |
# Remplacez les étiquettes par des valeurs numériques
|
93 |
df['tag'] = df['tag'].map(id2tag)
|
94 |
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
96 |
|
|
|
|
|
|
|
97 |
|
98 |
st.title("📘 Named Entity Recognition Wolof")
|
99 |
|
@@ -129,7 +137,7 @@ if submit_button:
|
|
129 |
c1, c2, c3 = st.columns([1, 3, 1])
|
130 |
|
131 |
with c2:
|
132 |
-
st.
|
133 |
|
134 |
st.header("")
|
135 |
st.header("")
|
@@ -142,4 +150,4 @@ with st.expander("ℹ️ - About this app", expanded=True):
|
|
142 |
- The app uses the [XLMRoberta model](https://huggingface.co/xlm-roberta-base), fine-tuned on the [masakhaNER](https://huggingface.co/datasets/masakhane/masakhaner2) dataset.
|
143 |
- The model uses the **byte-level BPE tokenizer**. Each sentence is first tokenized.
|
144 |
"""
|
145 |
-
|
|
|
92 |
# Remplacez les étiquettes par des valeurs numériques
|
93 |
df['tag'] = df['tag'].map(id2tag)
|
94 |
|
95 |
+
# Appliquez une mise en forme conditionnelle pour colorier les tags dans le texte
|
96 |
+
def color_tags(tag):
|
97 |
+
if tag == 'O':
|
98 |
+
return ''
|
99 |
+
else:
|
100 |
+
return 'color: blue'
|
101 |
|
102 |
+
df['word'] = df.apply(lambda row: f'<span style="{color_tags(row["tag"])}">{row["word"]}</span>', axis=1)
|
103 |
+
|
104 |
+
return df
|
105 |
|
106 |
st.title("📘 Named Entity Recognition Wolof")
|
107 |
|
|
|
137 |
c1, c2, c3 = st.columns([1, 3, 1])
|
138 |
|
139 |
with c2:
|
140 |
+
st.write(results.to_html(escape=False), unsafe_allow_html=True)
|
141 |
|
142 |
st.header("")
|
143 |
st.header("")
|
|
|
150 |
- The app uses the [XLMRoberta model](https://huggingface.co/xlm-roberta-base), fine-tuned on the [masakhaNER](https://huggingface.co/datasets/masakhane/masakhaner2) dataset.
|
151 |
- The model uses the **byte-level BPE tokenizer**. Each sentence is first tokenized.
|
152 |
"""
|
153 |
+
)
|