Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def clean_input(text):
# first clean out symbols
text = re.sub(r'[^\w]', ' ', text)
# then tokenize
text = text.split()
# then correct all spellings
text = map(spell, text)
text = " ".join(text)
return text
# write the grayscale image to disk as a temporary file so we can
# apply OCR to it
filename = "scraper/{}.png".format(os.getpid())
cv2.imwrite(filename, gray)
# load the image as a PIL/Pillow image, apply OCR, and then delete
# the temporary file
text = pytesseract.image_to_string(Image.open(filename))
os.remove(filename)
text = text.strip().split()
chars_to_remove = ['.', '!', ':']
extracted = list()
for t in text:
for c in chars_to_remove:
t = t.replace(c, '')
extracted.append(spell(t))
return(' '.join(extracted))
except BaseException as e:
print(e)
def correct(self, phrase):
words = phrase.split()
correct = [spell(word).upper() for word in words]
return ' '.join(correct)
def spell_check(input_question):
pattern = "\w"
prog = re.compile(pattern)
input_question_word_list = input_question.split()
en_dict = enchant.Dict("en_US")
for word_index in input_question_word_list:
if (not en_dict.check(input_question_word_list[word_index]) and
prog.match(input_question_word_list[word_index]) is None):
correct_word = spell(input_question_word_list[word_index])
input_question_word_list[word_index] = correct_word
return " ".join(input_question_word_list)
def performSpellCorrection(featureObj):
checker = SpellChecker("en_US", featureObj.getText())
for word in checker:
word.replace(spell(word.word))
featureObj.getLexicalFeatures().setSpellCorrection(checker.get_text())
return featureObj
#for method in methods:
for i in s:
template = cv2.imread(i,0)
res = cv2.matchTemplate(cropped,template,eval(methods[5]))
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
if min_val
def spell_check():
text = request.form['text']
spells = [spell(w) for w in (nltk.word_tokenize(text))]
result = {
"result": " ".join(spells)
}
result = {str(key): value for key, value in result.items()}
return jsonify(result=result)