KarthikaRajagopal commited on
Commit
09e9c24
·
verified ·
1 Parent(s): 1bd70e1

Upload Models.py

Browse files
Files changed (1) hide show
  1. Models.py +31 -0
Models.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from textblob import TextBlob
2
+ from gingerit.gingerit import GingerIt
3
+
4
+ class SpellCheckerModule:
5
+ def __init__(self):
6
+ self.spell_check = TextBlob("")
7
+ self.grammar_check = GingerIt()
8
+ def correct_spell(self,text):
9
+ # Helo,World, subscribe, to my channel
10
+ words = text.split()
11
+ corrected_words = []
12
+ for word in words:
13
+ corrected_word = str(TextBlob(word).correct())
14
+ corrected_words.append(corrected_word)
15
+ return " ".join(corrected_words)
16
+
17
+ def correct_grammar(self,text):
18
+ matches = self.grammar_check.parse(text)
19
+
20
+ foundmistakes = []
21
+ for error in matches['corrections']:
22
+ foundmistakes.append(error['text'])
23
+ foundmistakes_count = len(foundmistakes)
24
+ return foundmistakes,foundmistakes_count
25
+
26
+
27
+ if __name__ == "__main__":
28
+ obj = SpellCheckerModule()
29
+ message = "Hello world. I like mashine learning. appple. bananana"
30
+ print(obj.correct_spell(message))
31
+ print(obj.correct_grammar(message))