Skip to content

Commit

Permalink
Update PyGrammar.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchellShibilski-Unkel authored Apr 22, 2024
1 parent 7ad89ce commit dd83dff
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions PyGrammar/PyGrammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ def correct(self):
words = str(s).split(" ")
for _, t in enumerate(words):
try:
nextValue = s[_+1]
if t == nextValue:
correctedText += t + " "
s.remove(nextValue), getPOS.remove(getPOS[_+1])
elif str(t).islower() and getPOS[_] == "NNP" or getPOS[_] == "NNPS":
if str(t).islower() and getPOS[_] == "NNP" or getPOS[_] == "NNPS":
correctedText += str(t).capitalize() + " "
else:
correctedText += t + " "
except Exception:
correctedText += t + "."

correctedText = str(re.sub(r'\b(\w+)\s+\1\b', r'\1', correctedText))

return self.lang.correct(correctedText.replace(" .", "."))
return self.lang.correct(correctedText.replace(" .", ".").replace("\'", ""))

0 comments on commit dd83dff

Please sign in to comment.