def __loadEntityFromClp(self, similar_form): entity = Entity() for id in plp.plp_rec(similar_form.encode(default_encoding())): entity.base = plp.plp_bform(id).decode(default_encoding()) entity.label = plp.plp_label(id).decode(default_encoding()) for form in plp.plp_forms(id): entity.forms.append(form.decode(default_encoding())) break entity.prefix = self.__getPrefix(entity.base, entity.forms) return entity
def __findSimilarForms(self, word): max = -1 similar_forms = [] for line in self.__fileCache.grabFile("formy.txt"): form = line.decode(default_encoding()) sameCharsCount = self.__getCountCommonLettersFromEnd(word, form) if sameCharsCount > max and sameCharsCount > 1: max = sameCharsCount similar_forms = [] if sameCharsCount == max: if form not in similar_forms: similar_forms.append(form) if max > 1: return similar_forms else: return None