wiraindrak commited on
Commit
ef26fd6
1 Parent(s): b23854e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -2,10 +2,10 @@ from transformers import pipeline
2
 
3
  import gradio as gr
4
 
5
- pretrained_name = "cahya/bert-base-indonesian-NER"
6
 
7
- ner = pipeline(
8
- "ner",
9
  model=pretrained_name,
10
  tokenizer=pretrained_name
11
  )
@@ -14,14 +14,17 @@ examples = [
14
  "Ada apa dengan Jokowi di istana negara?",
15
  ]
16
 
17
- def ner(text):
18
- output = ner(text)
19
- return {"text": text, "entities": output}
 
20
 
21
- demo = gr.Interface(ner,
22
- gr.Textbox(placeholder="Enter sentence here..."),
23
- gr.HighlightedText(),
24
- examples=examples)
 
 
25
 
26
  if __name__ == "__main__":
27
  demo.launch()
 
2
 
3
  import gradio as gr
4
 
5
+ pretrained_name = "w11wo/indonesian-roberta-base-sentiment-classifier"
6
 
7
+ sentiment = pipeline(
8
+ "sentiment-analysis",
9
  model=pretrained_name,
10
  tokenizer=pretrained_name
11
  )
 
14
  "Ada apa dengan Jokowi di istana negara?",
15
  ]
16
 
17
+ def sentiment_analysis(text):
18
+ scores = sid.polarity_scores(text)
19
+ del scores["compound"]
20
+ return scores
21
 
22
+ demo = gr.Interface(
23
+ fn=sentiment_analysis,
24
+ inputs=gr.Textbox(placeholder="Enter a sentence here..."),
25
+ outputs="label",
26
+ interpretation="default",
27
+ examples=[examples])
28
 
29
  if __name__ == "__main__":
30
  demo.launch()