Larisa Kolesnichenko commited on
Commit
a0be2a1
1 Parent(s): 7ded684

Update app.py to include markdown text

Browse files
Files changed (1) hide show
  1. app.py +45 -2
app.py CHANGED
@@ -29,5 +29,48 @@ def predict(text):
29
  return '\n'.join(results)
30
 
31
 
32
- iface = gr.Interface(fn=predict, inputs="text", outputs="text")
33
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  return '\n'.join(results)
30
 
31
 
32
+
33
+ markdown_text = '''
34
+ <br>
35
+ <br>
36
+ This space provides a gradio demo and an easy-to-run wrapper of the pre-trained model for structured sentiment analysis in Norwegian language, pre-trained on the [NoReC dataset](https://huggingface.co/datasets/norec).
37
+ This model is an implementation of the paper "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).
38
+
39
+ The current model uses the 'labeled-edge' graph encoding, and achieves the following results on the NoReC dataset:
40
+
41
+ | Unlabeled sentiment tuple F1 | Target F1 | Relative polarity precision |
42
+ |:----------------------------:|:----------:|:---------------------------:|
43
+ | 0.393 | 0.468 | 0.939 |
44
+
45
+
46
+ The model can be easily used for predicting sentiment tuples as follows:
47
+
48
+ ```python
49
+ >>> import model_wrapper
50
+ >>> model = model_wrapper.PredictionModel()
51
+ >>> model.predict(['vi liker svart kaffe'])
52
+ [{'sent_id': '0',
53
+ 'text': 'vi liker svart kaffe',
54
+ 'opinions': [{'Source': [['vi'], ['0:2']],
55
+ 'Target': [['svart', 'kaffe'], ['9:14', '15:20']],
56
+ 'Polar_expression': [['liker'], ['3:8']],
57
+ 'Polarity': 'Positive'}]}]
58
+ ```
59
+ '''
60
+
61
+
62
+
63
+ with gr.Blocks() as demo:
64
+ with gr.Row(equal_height=False) as row:
65
+ text_input = gr.Textbox(label="input")
66
+ text_output = gr.Textbox(label="output")
67
+ with gr.Row(scale=4) as row:
68
+ text_button = gr.Button("submit").style(full_width=True)
69
+
70
+ text_button.click(fn=predict, inputs=text_input, outputs=text_output)
71
+
72
+ gr.Markdown(markdown_text)
73
+
74
+
75
+
76
+ demo.launch()