mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
texting pyspellchecker in lambda
This commit is contained in:
parent
d84b463771
commit
9af1a0f6a8
2 changed files with 5 additions and 4 deletions
|
|
@ -29,4 +29,5 @@ watchfiles==0.19.0
|
|||
websockets==11.0.3
|
||||
sqlalchemy==2.0.19
|
||||
psycopg2-binary
|
||||
pytz==2023.3
|
||||
pytz==2023.3
|
||||
pyspellchecker==0.7.2
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import re
|
||||
from textblob import TextBlob
|
||||
from spellchecker import SpellChecker
|
||||
|
||||
# Pre-compile the regular expression
|
||||
PERCENTAGE_PATTERN = re.compile(r'^\d+%?$')
|
||||
|
|
@ -18,8 +18,8 @@ def correct_spelling(text):
|
|||
if is_percentage_or_number(word):
|
||||
corrected_words.append(word)
|
||||
else:
|
||||
blob = TextBlob(word) # create a TextBlob object
|
||||
corrected_word = blob.correct() # use the correct method to correct spelling
|
||||
spell = SpellChecker()
|
||||
corrected_word = spell.correction(text)
|
||||
corrected_words.append(str(corrected_word)) # convert corrected word back to string
|
||||
|
||||
corrected_text = ' '.join(corrected_words)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue