brijw commited on
Commit
045dfb0
1 Parent(s): 4208e08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -1,12 +1,21 @@
1
- import requests
2
-
3
- API_URL = "https://api-inference.huggingface.co/models/spacy/en_core_web_sm"
4
- headers = {"Authorization": "Bearer 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"}
5
-
6
- def query(payload):
7
- response = requests.post(API_URL, headers=headers, json=payload)
8
- return response.json()
9
-
10
- output = query({
11
- "inputs": "where did Wandobire's laptop come from, was it africa or uganda?",
12
- })
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ #os is used to change the directory
3
+ #spacy is used for the NER
4
+ import spacy
5
+ from spacy import displacy
6
+ import en_core_web_sm
7
+
8
+
9
+ nlp = spacy.load("en_core_web_sm")
10
+ def ner_spacy(sentence):
11
+ doc = nlp(sentence)
12
+ ents = [(e.text, e.label_) for e in doc.ents]
13
+ return ents
14
+
15
+ examples = [
16
+ "where did Wandobire's laptop come from, was it africa or uganda?",
17
+ ]
18
+
19
+
20
+ gr.Interface(ner_spacy, gr.Textbox(placeholder="Enter sentence here..."),
21
+ gr.HighlightedText(), examples=examples).launch(share=True)