Spaces:
Running
Running
aisyahhrazak
commited on
Commit
•
25bff98
1
Parent(s):
077f67f
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,11 @@ from nltk import bigrams
|
|
15 |
import malaya
|
16 |
from collections import Counter
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
with open('en.json') as fopen:
|
19 |
en = json.load(fopen)
|
20 |
|
@@ -373,9 +378,13 @@ with gr.Blocks(css=css + """
|
|
373 |
tpb_output = gr.Textbox(lines=3, label="TPB Classification")
|
374 |
sentiment_output = gr.Textbox(lines=3, label="Sentiment Analysis")
|
375 |
decision_output = gr.Textbox(lines=3, label="Purchase Prediction")
|
|
|
|
|
376 |
classify_button = gr.Button("Analyze")
|
377 |
-
classify_button.click(fn=text_classification_and_sentiment, inputs=input_text, outputs=[tpb_output, sentiment_output, decision_output])
|
378 |
gr.Examples(examples=examples, inputs=input_text)
|
|
|
|
|
379 |
|
380 |
with gr.TabItem("Company View", id=1):
|
381 |
gr.Markdown("# Sentiment Analysis and Purchase Decision Factor for Halal Food Acquisition")
|
|
|
15 |
import malaya
|
16 |
from collections import Counter
|
17 |
|
18 |
+
|
19 |
+
HF_TOKEN = os.getenv('hf_token')
|
20 |
+
|
21 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN,'aisyahhrazak/tpb-crowdsourced-dataset')
|
22 |
+
|
23 |
with open('en.json') as fopen:
|
24 |
en = json.load(fopen)
|
25 |
|
|
|
378 |
tpb_output = gr.Textbox(lines=3, label="TPB Classification")
|
379 |
sentiment_output = gr.Textbox(lines=3, label="Sentiment Analysis")
|
380 |
decision_output = gr.Textbox(lines=3, label="Purchase Prediction")
|
381 |
+
# This needs to be called at some point prior to the first call to callback.flag()
|
382 |
+
hf_writer.setup([input_text,tpb_output, sentiment_output], "flagged_data_points")
|
383 |
classify_button = gr.Button("Analyze")
|
384 |
+
classify_button.click(lambda *args: hf_writer.flag(list(args)),fn=text_classification_and_sentiment, inputs=input_text, outputs=[tpb_output, sentiment_output, decision_output])
|
385 |
gr.Examples(examples=examples, inputs=input_text)
|
386 |
+
|
387 |
+
|
388 |
|
389 |
with gr.TabItem("Company View", id=1):
|
390 |
gr.Markdown("# Sentiment Analysis and Purchase Decision Factor for Halal Food Acquisition")
|