Julien Matuszak commited on
Commit
028169b
·
verified ·
1 Parent(s): 5d8402b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
  import spacy
4
- from textblob import TextBlob
5
  from gradio_client import Client
6
  import re
7
 
@@ -42,16 +41,17 @@ def preprocess_text(text: str):
42
  "corrected": capitalized_text
43
  })
44
  text = capitalized_text # Update text for further processing
45
-
46
  # Transformer spell check
47
  spell_checked = spell_checker(text, max_length=512)[0]['generated_text']
48
- if spell_checked != text and spell_checked != corrected:
49
  result["spell_suggestions"].append({
50
  "original": text,
51
  "corrected": spell_checked
52
  })
53
 
54
  # Add entities and tags
 
55
  result["entities"] = [{"text": ent.text, "label": ent.label_} for ent in doc.ents]
56
  result["tags"] = [token.text for token in doc if token.text.startswith(('#', '@'))]
57
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
  import spacy
 
4
  from gradio_client import Client
5
  import re
6
 
 
41
  "corrected": capitalized_text
42
  })
43
  text = capitalized_text # Update text for further processing
44
+
45
  # Transformer spell check
46
  spell_checked = spell_checker(text, max_length=512)[0]['generated_text']
47
+ if spell_checked != text:
48
  result["spell_suggestions"].append({
49
  "original": text,
50
  "corrected": spell_checked
51
  })
52
 
53
  # Add entities and tags
54
+ doc = nlp(text)
55
  result["entities"] = [{"text": ent.text, "label": ent.label_} for ent in doc.ents]
56
  result["tags"] = [token.text for token in doc if token.text.startswith(('#', '@'))]
57