Update
Browse files- app.py +13 -3
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import json
|
2 |
import time
|
3 |
import streamlit as st
|
|
|
|
|
|
|
4 |
|
5 |
from flair.data import Sentence
|
6 |
from flair.models import SequenceTagger
|
@@ -9,11 +12,11 @@ checkpoints = [
|
|
9 |
"qanastek/pos-french",
|
10 |
]
|
11 |
|
|
|
|
|
12 |
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
|
13 |
def get_model(model_name):
|
14 |
-
|
15 |
-
# Load the model
|
16 |
-
return SequenceTagger.load(model_name)
|
17 |
|
18 |
def getPos(s: Sentence):
|
19 |
texts = []
|
@@ -27,6 +30,9 @@ def getPos(s: Sentence):
|
|
27 |
def getDictFromPOS(texts, labels):
|
28 |
return [{ "text": t, "label": l } for t, l in zip(texts, labels)]
|
29 |
|
|
|
|
|
|
|
30 |
def main():
|
31 |
|
32 |
st.title("🥖 French-Part-Of-Speech-Tagging")
|
@@ -57,6 +63,10 @@ def main():
|
|
57 |
|
58 |
st.header("Labels:")
|
59 |
st.write(" ".join(labels))
|
|
|
|
|
|
|
|
|
60 |
|
61 |
st.header("JSON:")
|
62 |
st.json(getDictFromPOS(texts, labels))
|
|
|
1 |
import json
|
2 |
import time
|
3 |
import streamlit as st
|
4 |
+
from annotated_text import annotated_text
|
5 |
+
|
6 |
+
import matplotlib
|
7 |
|
8 |
from flair.data import Sentence
|
9 |
from flair.models import SequenceTagger
|
|
|
12 |
"qanastek/pos-french",
|
13 |
]
|
14 |
|
15 |
+
colors = list(matplotlib.colors.cnames.values())
|
16 |
+
|
17 |
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
|
18 |
def get_model(model_name):
|
19 |
+
return SequenceTagger.load(model_name) # Load the model
|
|
|
|
|
20 |
|
21 |
def getPos(s: Sentence):
|
22 |
texts = []
|
|
|
30 |
def getDictFromPOS(texts, labels):
|
31 |
return [{ "text": t, "label": l } for t, l in zip(texts, labels)]
|
32 |
|
33 |
+
def getAnnotatedFromPOS(texts, labels):
|
34 |
+
return [(t,l,"#8ef") for t, l in zip(texts, labels)]
|
35 |
+
|
36 |
def main():
|
37 |
|
38 |
st.title("🥖 French-Part-Of-Speech-Tagging")
|
|
|
63 |
|
64 |
st.header("Labels:")
|
65 |
st.write(" ".join(labels))
|
66 |
+
|
67 |
+
st.header("Labels:")
|
68 |
+
anns = getAnnotatedFromPOS(texts, labels)
|
69 |
+
annotated_text(*anns)
|
70 |
|
71 |
st.header("JSON:")
|
72 |
st.json(getDictFromPOS(texts, labels))
|
requirements.txt
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
flair==0.8.0.post1
|
|
|
|
|
|
1 |
+
flair==0.8.0.post1
|
2 |
+
st-annotated-text
|
3 |
+
matplotlib
|