Spaces:
Runtime error
Runtime error
Commit
·
2168cf5
1
Parent(s):
21fb1ca
Create new file
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
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 |
+
)
|
| 12 |
+
|
| 13 |
+
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()
|