Spaces:
Running
Running
Updated layout :)
Browse files
app.py
CHANGED
@@ -13,8 +13,8 @@ except Exception:
|
|
13 |
os.system("python -m spacy download pt_core_news_sm")
|
14 |
nlp = spacy.load("pt_core_news_sm")
|
15 |
|
16 |
-
model = AutoModelForTokenClassification.from_pretrained("Emanuel/
|
17 |
-
tokenizer = AutoTokenizer.from_pretrained("Emanuel/
|
18 |
logger = logging.getLogger()
|
19 |
logger.setLevel(logging.DEBUG)
|
20 |
|
@@ -64,7 +64,13 @@ def text_analysis(text):
|
|
64 |
for token, label in zip(tokens, labels):
|
65 |
pos_tokens.extend([(token, label), (" ", None)])
|
66 |
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
css = open("style.css").read()
|
@@ -73,13 +79,7 @@ bottom_html = open("bottom.html").read()
|
|
73 |
|
74 |
with gr.Blocks(css=css) as demo:
|
75 |
gr.HTML(top_html)
|
76 |
-
text = gr.Textbox(placeholder="
|
77 |
-
output_highlighted = gr.HighlightedText()
|
78 |
-
output_df = gr.Dataframe()
|
79 |
-
submit_btn = gr.Button("Enviar")
|
80 |
-
submit_btn.click(
|
81 |
-
fn=text_analysis, inputs=text, outputs=[output_highlighted, output_df]
|
82 |
-
)
|
83 |
examples = gr.Examples(
|
84 |
examples=[
|
85 |
[
|
@@ -88,9 +88,15 @@ with gr.Blocks(css=css) as demo:
|
|
88 |
["Filme 'Star Wars : Os Últimos Jedi' ganha trailer definitivo; assista."],
|
89 |
],
|
90 |
inputs=[text],
|
91 |
-
label="
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
)
|
93 |
gr.HTML(bottom_html)
|
94 |
|
95 |
|
96 |
-
demo.launch()
|
|
|
13 |
os.system("python -m spacy download pt_core_news_sm")
|
14 |
nlp = spacy.load("pt_core_news_sm")
|
15 |
|
16 |
+
model = AutoModelForTokenClassification.from_pretrained("Emanuel/porttagger-news-base")
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained("Emanuel/porttagger-news-base")
|
18 |
logger = logging.getLogger()
|
19 |
logger.setLevel(logging.DEBUG)
|
20 |
|
|
|
64 |
for token, label in zip(tokens, labels):
|
65 |
pos_tokens.extend([(token, label), (" ", None)])
|
66 |
|
67 |
+
output_highlighted.update(visible=True)
|
68 |
+
output_df.update(visible=True)
|
69 |
+
|
70 |
+
return {
|
71 |
+
output_highlighted: output_highlighted.update(visible=True, value=(pos_tokens)),
|
72 |
+
output_df: output_df.update(visible=True, value=pos_count),
|
73 |
+
}
|
74 |
|
75 |
|
76 |
css = open("style.css").read()
|
|
|
79 |
|
80 |
with gr.Blocks(css=css) as demo:
|
81 |
gr.HTML(top_html)
|
82 |
+
text = gr.Textbox(placeholder="Enter your text here...", label="Input")
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
examples = gr.Examples(
|
84 |
examples=[
|
85 |
[
|
|
|
88 |
["Filme 'Star Wars : Os Últimos Jedi' ganha trailer definitivo; assista."],
|
89 |
],
|
90 |
inputs=[text],
|
91 |
+
label="Select an example",
|
92 |
+
)
|
93 |
+
output_highlighted = gr.HighlightedText(label="Colorful output", visible=False)
|
94 |
+
output_df = gr.Dataframe(label="Tabular output", visible=False)
|
95 |
+
submit_btn = gr.Button("Send")
|
96 |
+
submit_btn.click(
|
97 |
+
fn=text_analysis, inputs=text, outputs=[output_highlighted, output_df]
|
98 |
)
|
99 |
gr.HTML(bottom_html)
|
100 |
|
101 |
|
102 |
+
demo.launch(debug=True)
|
bottom.html
CHANGED
@@ -8,4 +8,7 @@
|
|
8 |
<img class="column" alt="ICMC-USP logo"
|
9 |
src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Webysther_20170627_-_Logo_ICMC-USP.svg/2560px-Webysther_20170627_-_Logo_ICMC-USP.svg.png" />
|
10 |
</div>
|
|
|
|
|
|
|
11 |
</div>
|
|
|
8 |
<img class="column" alt="ICMC-USP logo"
|
9 |
src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Webysther_20170627_-_Logo_ICMC-USP.svg/2560px-Webysther_20170627_-_Logo_ICMC-USP.svg.png" />
|
10 |
</div>
|
11 |
+
</div>
|
12 |
+
<div style="text-align: center;">
|
13 |
+
<p>This app was made with ☕ by <a href="https://github.com/huberemanuel">Emanuel Huber</a> 🤗</p>
|
14 |
</div>
|
style.css
CHANGED
@@ -65,5 +65,6 @@ a {
|
|
65 |
|
66 |
.column {
|
67 |
flex: 33.33%;
|
68 |
-
padding:
|
|
|
69 |
}
|
|
|
65 |
|
66 |
.column {
|
67 |
flex: 33.33%;
|
68 |
+
padding-left: 40px;
|
69 |
+
padding-right: 40px;
|
70 |
}
|
top.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
2 |
<div>
|
3 |
<h1 style="font-weight: 900; font-size: 3rem; margin: 20px;">
|
4 |
-
|
5 |
</h1>
|
6 |
<p class="slogan">A Brazilian Portuguese part-of-speech tagger according to Universal
|
7 |
Dependencies</p>
|
@@ -11,7 +11,7 @@
|
|
11 |
href="https://sites.google.com/icmc.usp.br/poetisa/resources-and-tools">Porttinari-base</a> corpus which is
|
12 |
a collection of news extracted from the Folha de São Paulo newspaper site. The trained model is a fine-tuned
|
13 |
version
|
14 |
-
of <a
|
15 |
outputs part-of-speech tags. Since the model expects a sequence of
|
16 |
tokens
|
17 |
for its inputs, <a src="https://spacy.io/models/pt">Spacy's</a> tokenization is used to tokenize the input text.
|
|
|
1 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
2 |
<div>
|
3 |
<h1 style="font-weight: 900; font-size: 3rem; margin: 20px;">
|
4 |
+
PorttTagger tagger
|
5 |
</h1>
|
6 |
<p class="slogan">A Brazilian Portuguese part-of-speech tagger according to Universal
|
7 |
Dependencies</p>
|
|
|
11 |
href="https://sites.google.com/icmc.usp.br/poetisa/resources-and-tools">Porttinari-base</a> corpus which is
|
12 |
a collection of news extracted from the Folha de São Paulo newspaper site. The trained model is a fine-tuned
|
13 |
version
|
14 |
+
of <a href="https://huggingface.co/neuralmind/bert-base-portuguese-cased">Bertimbau</a> that receives tokens and
|
15 |
outputs part-of-speech tags. Since the model expects a sequence of
|
16 |
tokens
|
17 |
for its inputs, <a src="https://spacy.io/models/pt">Spacy's</a> tokenization is used to tokenize the input text.
|