def getBaseWord(self, word): try: return analyze(word)[0]['analysis'][0]['lemma'] except Exception as msg: pprint(word) print(analyze(word)) print(msg)
def run_test(self, guess, phonetic, compound): text_output = analyze(self.text(), guess=guess, phonetic=phonetic, compound=compound ) list_output = analyze(self.text().split(), guess=guess, phonetic=phonetic, compound=compound ) self.assertListEqual(text_output, list_output)
def sona(sisend, s): ### kas on sõna? if len(sisend) >= len(s): ### kas on lühem kui sisend if s: if analyze(s, guess=False, phonetic=False, compound=False)[0]['analysis']: # on sõna? if sisaldab( sisend, s): ### kui kõik uue sõna tähed sisalduvad sisendis return True
def get_freq(data): words = {} for word in data.split(): word = word.lower() word = filter(unicode.isalpha, unicode(word, "utf-8")) if len(word) < 3: continue res = analyze(word) ins_or_add(res[0]['analysis'][0], words) return sorted(words.items(), key=lambda x: x[1], reverse=True)
def get_sums(data): sums = [] latest = collections.deque(maxlen=5) for word in data.split(): word = word.lower() if word in ("eur", "€"): print "EUR" sss = get_sum_from_latest(latest) if sss is not None: sums.append(sss) latest.append(word) continue word = filter(unicode.isalnum, unicode(word, "utf-8")) #pprint(word) if len(word) == 0: continue res = analyze(word) ins_or_add(res[0]['analysis'][0], sums, latest) latest.append(word) return sorted(sums, reverse=True)
def getBaseWord(self, word): return analyze(word)[0]['analysis'][0]['lemma']
def compute_single(self): return [analyze(text) for text in self.indata()]