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