avichr commited on
Commit
4383aa7
1 Parent(s): b71aa52

Create colab_app.py

Browse files
Files changed (1) hide show
  1. colab_app.py +28 -0
colab_app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from HebEMO import HebEMO
2
+ from transformers import pipeline
3
+ import streamlit as st
4
+ import matplotlib.pyplot as plt
5
+ import pandas as pd
6
+ from spider_plot import spider_plot
7
+
8
+
9
+ @st.cache
10
+ def HebEMO_model():
11
+ st.title("Emotion Recognition in Hebrew Texts")
12
+ st.write("HebEMO is a tool to detect polarity and extract emotions from Hebrew user-generated content (UGC), which was trained on a unique Covid-19 related dataset that we collected and annotated. HebEMO yielded a high performance of weighted average F1-score = 0.96 for polarity classification. Emotion detection reached an F1-score of 0.78-0.97, with the exception of *surprise*, which the model failed to capture (F1 = 0.41). More information can be found in our git: https://github.com/avichaychriqui/HeBERT")
13
+ st.write("Write Hebrew sentences in the text box below to analyze (each sentence in a different rew). It takes a while, be patient :). An additional demo can be found in the Colab notebook: https://colab.research.google.com/drive/1Jw3gOWjwVMcZslu-ttXoNeD17lms1-ff ")
14
+
15
+ return HebEMO()
16
+
17
+ HebEMO_model = HebEMO_model()
18
+
19
+
20
+ sent = st.text_area("Text", "讛讞讬讬诐 讬驻讬诐 讜诪讗讜砖专讬诐", height = 20)
21
+ # interact(HebEMO_model.hebemo, text='讛讞讬讬诐 讬驻讬诐 讜诪讗讜砖专讬', plot=fixed(True), input_path=fixed(False), save_results=fixed(False),)
22
+
23
+ hebEMO_df = HebEMO_model.hebemo(sent, read_lines=True, plot=False)
24
+ hebEMO = pd.DataFrame()
25
+ for emo in hebEMO_df.columns[1::2]:
26
+ hebEMO[emo] = abs(hebEMO_df[emo]-(1-hebEMO_df['confidence_'+emo]))
27
+
28
+ st.write (hebEMO)