Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -38,34 +38,11 @@ def predict(text):
|
|
38 |
markdown_text = '''
|
39 |
<br>
|
40 |
<br>
|
41 |
-
This space provides a gradio demo
|
42 |
-
This space containt an implementation of method described in "Direct parsing to sentiment graphs" (Samuel _et al._, ACL 2022). The main repository that also contains the scripts for training the model, can be found on the project [github](https://github.com/jerbarnes/direct_parsing_to_sent_graph).
|
43 |
|
44 |
-
The sentiment
|
45 |
-
The proposed method suggests three different ways to encode the sentiment graph: "node-centric", "labeled-edge", and "opinion-tuple".
|
46 |
-
The current model
|
47 |
-
- uses "labeled-edge" graph encoding
|
48 |
-
- does not use character-level embedding
|
49 |
-
- all other hyperparameters are set to [default values](https://github.com/jerbarnes/direct_parsing_to_sent_graph/blob/main/perin/config/edge_norec.yaml)
|
50 |
-
, and it achieves the following results on the held-out set of the NoReC dataset:
|
51 |
|
52 |
-
|
53 |
-
|:----------------------------:|:----------:|:---------------------------:|
|
54 |
-
| 0.434 | 0.541 | 0.926 |
|
55 |
-
|
56 |
-
|
57 |
-
In "Word Substitution with Masked Language Models as Data Augmentation for Sentiment Analysis", we analyzed data augmentation strategies for improving performance of the model. Using masked-language modeling (MLM), we augmented the sentences with MLM-substituted words inside, outside, or inside+outside the actual sentiment tuples. The results below show that augmentation may be improve the model performance. This space, however, runs the original model trained without augmentation.
|
58 |
-
|
59 |
-
| | Augmentation rate | Unlabeled sentiment tuple F1 | Target F1 | Relative polarity precision |
|
60 |
-
|----------------|-------------------|------------------------------|-----------|-----------------------------|
|
61 |
-
| Baseline | 0% | 43.39 | 54.13 | 92.59 |
|
62 |
-
| Outside | 59% | **45.08** | 56.18 | 92.95 |
|
63 |
-
| Inside | 9% | 43.38 | 55.62 | 92.49 |
|
64 |
-
| Inside+Outside | 27% | 44.12 | **56.44** | **93.19** |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
The model can be easily used for predicting sentiment tuples as follows:
|
69 |
|
70 |
```python
|
71 |
>>> import model_wrapper
|
@@ -78,9 +55,9 @@ The model can be easily used for predicting sentiment tuples as follows:
|
|
78 |
'Polar_expression': [['liker'], ['3:8']],
|
79 |
'Polarity': 'Positive'}]}]
|
80 |
```
|
81 |
-
'''
|
82 |
-
|
83 |
|
|
|
|
|
84 |
|
85 |
with gr.Blocks() as demo:
|
86 |
with gr.Row() as row:
|
|
|
38 |
markdown_text = '''
|
39 |
<br>
|
40 |
<br>
|
41 |
+
This space provides a gradio demo of a [pretrained model](https://huggingface.co/ltg/ssa-perin) (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.
|
|
|
42 |
|
43 |
+
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
See the code below for an example of how you can use the model yourself for predicting such sentiment tuples (along with character offsets in the text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
```python
|
48 |
>>> import model_wrapper
|
|
|
55 |
'Polar_expression': [['liker'], ['3:8']],
|
56 |
'Polarity': 'Positive'}]}]
|
57 |
```
|
|
|
|
|
58 |
|
59 |
+
To download the model and find more in-depth documentation, please see (https://huggingface.co/ltg/ssa-perin)[https://huggingface.co/ltg/ssa-perin]
|
60 |
+
'''
|
61 |
|
62 |
with gr.Blocks() as demo:
|
63 |
with gr.Row() as row:
|