def print_unicode(items, to_unicode=None): for item_i in items: if (to_unicode == None): item_i = decode_digraphs(item_i) print(unicode(item_i)) else: print(to_unicode(item_i))
def print_unicode(items, to_unicode=None): for item_i in items: if to_unicode == None: item_i = decode_digraphs(item_i) print(unicode(item_i)) else: print(to_unicode(item_i))
def get_ending(self,new_word,n=7): begin=self.nearest_begin(new_word) words=self.full_words(begin) words=tools.unique_list(words) if(len(words)<n): n=len(words) nearest_words=knn.nearest_k(new_word,words,k=n) nearest_words=[distance.decode_digraphs(word_i) for word_i in nearest_words] return nearest_words
def get_word(correction): raw_text = raw_input("Enter sentences ").decode('utf-8') if(raw_text=="quit"): return False #new_word=distance.code_digraphs(raw_text) prob_pairs=correction.correct(raw_text) n=15 if(len(prob_pairs)>n): prob_pairs=prob_pairs[0:n] tools.print_unicode(prob_pairs,to_unicode=lambda p: decode_digraphs(p[0]) +' ' + unicode(p[1])) return True