madhavkotecha commited on
Commit
6e1afd6
·
verified ·
1 Parent(s): bef4eb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -10,8 +10,7 @@ import re
10
  import gradio as gr
11
  lancaster = LancasterStemmer()
12
 
13
- nltk.download('brown')
14
- nltk.download('universal_tagset')
15
 
16
  class CRF_POS_Tagger:
17
  def __init__(self):
@@ -222,13 +221,20 @@ class CRF_POS_Tagger:
222
  features = [self.word_features(sentence_list, i) for i in range(len(sentence_list))]
223
 
224
  predicted_tags = self.crf_model.predict([features])
225
- output = "".join(f"{sentence[i]}[{predicted_tags[0][i]}] " for i in range(len(sentence)))
226
  return output
227
 
228
  tagger = CRF_POS_Tagger()
229
  interface = gr.Interface(fn = tagger.tagging,
230
- inputs = "text",
231
- outputs = "text",
232
- title = "CRF POS Tagger",
233
- description = "CS626 Assignment 1b by 24M0797, 24M0798, 24M0815, 24M0833")
234
- interface.launch(inline = False)
 
 
 
 
 
 
 
 
10
  import gradio as gr
11
  lancaster = LancasterStemmer()
12
 
13
+
 
14
 
15
  class CRF_POS_Tagger:
16
  def __init__(self):
 
221
  features = [self.word_features(sentence_list, i) for i in range(len(sentence_list))]
222
 
223
  predicted_tags = self.crf_model.predict([features])
224
+ output = "".join(f"{sentence[i]}[{predicted_tags[0][i]}] " for i in range(len(sentence)))
225
  return output
226
 
227
  tagger = CRF_POS_Tagger()
228
  interface = gr.Interface(fn = tagger.tagging,
229
+ inputs = gr.Textbox(
230
+ label="Input Sentence",
231
+ placeholder="Enter your sentence here...",
232
+ ),
233
+ outputs = gr.Textbox(
234
+ label="Tagged Output",
235
+ placeholder="Tagged sentence appears here...",
236
+ ),
237
+ title = "Conditional Random Field POS Tagger",
238
+ description = "CS626 Assignment 1B (Autumn 2024)",
239
+ theme=gr.themes.Soft())
240
+ interface.launch()