Spaces:
Runtime error
Runtime error
Commit
·
7dc42f7
1
Parent(s):
3b4bac2
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
import re
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
# I've added optional lines for text cleaning
|
10 |
-
# note that the sentiment-analysis pipeline returns 2 values - a label and a score
|
11 |
-
def sentiment_analysis(text):
|
12 |
-
text = text.encode("ascii", errors="ignore").decode(
|
13 |
-
"ascii"
|
14 |
-
) # remove non-ascii, Chinese characters
|
15 |
-
text = text.lower() # lower case
|
16 |
-
text = re.sub(r"\n", " ", text)
|
17 |
-
text = re.sub(r"\n\n", " ", text)
|
18 |
-
text = re.sub(r"\t", " ", text)
|
19 |
-
text = text.strip(" ")
|
20 |
-
text = re.sub(r"[^\w\s]", "", text) # remove punctuation and special characters
|
21 |
-
text = re.sub(
|
22 |
-
" +", " ", text
|
23 |
-
).strip() # get rid of multiple spaces and replace with a single
|
24 |
-
results = sentiment(text)
|
25 |
-
return results[0]["label"], round(results[0]["score"], 5)
|
26 |
-
###gr.Interface(batch=True)
|
27 |
-
grui=gr.Interface(fn=sentiment_analysis,
|
28 |
-
inputs=[gr.inputs.Textbox(lines=10, label="Paste some text here"), gr.inputs.Textbox(lines=10, label="Paste some text here")],
|
29 |
-
outputs=[ gr.outputs.Textbox(label="Sentiment Label"), gr.outputs.Textbox(label="Sentiment Label")],
|
30 |
-
batch=True,
|
31 |
-
max_batch_size=2)
|
32 |
-
grui.launch()
|
33 |
-
|
34 |
-
##gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
35 |
##import requests
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
4 |
+
gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
5 |
+
gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
6 |
+
gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
7 |
+
gr.Interface.load("models/Ammar-alhaj-ali/arabic-MARBERT-sentiment").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
##import requests
|