<commit_before>import math
from common.string import strip_accents

class SpellChecker():
	def __init__(self, allWords):
		self.allWords = allWords

	def checkWords(self, words):
		suggestions = {x:self.check(x) for x in words}
		suggestions = {k:v for k,v in suggestions.items() if k != v}
		return suggestions

	def check(self, word):
		word = strip_accents(word)

		if word in self.allWords:
			return word

		lword = len(word)
		prefix = word[:2]
		suffix = word[::-1][:2]
		candidates = {x for x in self.allWords if x[0] in prefix and x[len(x)-1] in suffix and lword == len(x)}
		maxDiffs = max(1, math.floor(lword / 5))
		diffs = {x for x in candidates if self.diffRank(word, x) <= maxDiffs}
		bubbles = {x for x in candidates if self.bubbleRank(word, x)}

		intersection = diffs & bubbles
		if intersection:
			return list(intersection)[0]<commit_msg>empty string bug fixed<commit_after>import math
from common.string import strip_accents

class SpellChecker():
	def __init__(self, allWords):
		self.allWords = allWords

	def checkWords(self, words):
		suggestions = {x:self.check(x) for x in words}
		suggestions = {k:v for k,v in suggestions.items() if k != v}
		return suggestions

	def check(self, word):
		word = strip_accents(word)

		if word in self.allWords:
			return word

		lword = len(word)
		prefix = word[:2]
		suffix = word[::-1][:2]
		candidates = {x for x in self.allWords if x != "" and x[0] in prefix and x[len(x)-1] in suffix and lword == len(x)}
		maxDiffs = max(1, math.floor(lword / 5))
		diffs = {x for x in candidates if self.diffRank(word, x) <= maxDiffs}
		bubbles = {x for x in candidates if self.bubbleRank(word, x)}

		intersection = diffs & bubbles
		if intersection:
			return list(intersection)[0]
{'fraction_non_alphanumeric': 0.12320092112838227, 'fraction_numerical': 0.009211283822682787, 'mean_word_length': 3.9942528735632186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493220', 'n_tokens_mistral': 677, 'n_tokens_neox': 606, 'n_words': 198}