Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,29 +36,19 @@ def predict(text):
|
|
36 |
|
37 |
|
38 |
markdown_text = '''
|
|
|
|
|
|
|
|
|
39 |
<br>
|
40 |
-
This space provides a gradio demo of a <a href="https://huggingface.co/ltg/ssa-perin">pretrained model</a> (with an easy-to-run wrapper) for structured sentiment analysis (SSA) of Norwegian text, trained on the [NoReC_fine](https://github.com/ltgoslo/norec_fine) dataset. It implements a method described in the paper [Direct parsing to sentiment graphs](https://aclanthology.org/2022.acl-short.51/) by Samuel et al. 2022.
|
41 |
-
|
42 |
The model will attempt to identify the following components for a given sentence it deems to be sentiment-bearing: _source expressions_ (the opinion holder), _target expressions_ (what the opinion is directed towards), _polar expressions_ (the part of the text indicating that an opinion is expressed), and finally the _polarity_ (positive or negative).
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
```python
|
47 |
-
>>> import model_wrapper
|
48 |
-
>>> model = model_wrapper.PredictionModel()
|
49 |
-
>>> model.predict(['vi liker svart kaffe'])
|
50 |
-
[{'sent_id': '0',
|
51 |
-
'text': 'vi liker svart kaffe',
|
52 |
-
'opinions': [{'Source': [['vi'], ['0:2']],
|
53 |
-
'Target': [['svart', 'kaffe'], ['9:14', '15:20']],
|
54 |
-
'Polar_expression': [['liker'], ['3:8']],
|
55 |
-
'Polarity': 'Positive'}]}]
|
56 |
-
```
|
57 |
-
|
58 |
-
To download the model and find more in-depth documentation, please see https://huggingface.co/ltg/ssa-perin
|
59 |
'''
|
60 |
|
61 |
with gr.Blocks() as demo:
|
|
|
62 |
with gr.Row() as row:
|
63 |
text_input = gr.Textbox(label="input")
|
64 |
text_output = gr.Textbox(label="output")
|
@@ -67,7 +57,5 @@ with gr.Blocks() as demo:
|
|
67 |
|
68 |
text_button.click(fn=predict, inputs=text_input, outputs=text_output)
|
69 |
|
70 |
-
gr.Markdown(markdown_text)
|
71 |
-
|
72 |
|
73 |
demo.launch()
|
|
|
36 |
|
37 |
|
38 |
markdown_text = '''
|
39 |
+
<h1>Structured Sentiment Analysis for Norwegian</h1>
|
40 |
+
<p align="left">
|
41 |
+
<br>
|
42 |
+
This space provides a gradio demo of a <a href="https://huggingface.co/ltg/ssa-perin">pretrained model</a> for structured sentiment analysis (SSA) of Norwegian text, trained on the [NoReC_fine](https://github.com/ltgoslo/norec_fine) dataset by the <a href"https://www.mn.uio.no/ifi/english/research/groups/ltg/">Language Technology Group</a> at the University of Oslo. It implements a method described in the paper <a href="https://aclanthology.org/2022.acl-short.51/">Direct parsing to sentiment graphs</a> by Samuel et al. 2022.
|
43 |
<br>
|
|
|
|
|
44 |
The model will attempt to identify the following components for a given sentence it deems to be sentiment-bearing: _source expressions_ (the opinion holder), _target expressions_ (what the opinion is directed towards), _polar expressions_ (the part of the text indicating that an opinion is expressed), and finally the _polarity_ (positive or negative).
|
45 |
+
<br>
|
46 |
+
To download the model and find more in-depth documentation, please see <a href="https://huggingface.co/ltg/ssa-perin">https://huggingface.co/ltg/ssa-perin</a>
|
47 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
'''
|
49 |
|
50 |
with gr.Blocks() as demo:
|
51 |
+
gr.Markdown(markdown_text)
|
52 |
with gr.Row() as row:
|
53 |
text_input = gr.Textbox(label="input")
|
54 |
text_output = gr.Textbox(label="output")
|
|
|
57 |
|
58 |
text_button.click(fn=predict, inputs=text_input, outputs=text_output)
|
59 |
|
|
|
|
|
60 |
|
61 |
demo.launch()
|