def rightFormInEtSet(self, lemma, src_form, trg_form, solution): hasSolution = False if (src_form, trg_form) not in self.formToEt: return False for et in self.formToEt[(src_form, trg_form)]: if unicode(applyOnlyTree(lemma, et)) == solution: hasSolution = True return hasSolution
def correctResult(self, lemma, src_form, trg_form, word): # We cannot correct this. if (src_form, trg_form) not in self.formToEt: return word # Choose the form that has the mistake at an edit tree border (and maybe for doubling) for et in self.formToEt[(src_form, trg_form)]: newWord = unicode(applyOnlyTree(lemma, et)) if edit_distance(newWord, word) == 1: return newWord # TODO: perform some choice here # No fitting solution has been found: return word
def filterResult(self, lemma, src_form, trg_form, word): allRight = False if lemma == word or (src_form, trg_form) not in self.formToEt: #if form not in self.formToEt: return True for et in self.formToEt[(src_form, trg_form)]: #print(lemma) #print(et) #print(applyOnlyTree(lemma, et)) #print('****') if unicode(applyOnlyTree(lemma, et)) == word: allRight = True # Loose application, not THAT save, but at least not "verschlimmbessernd" ;): if verifyApplication(lemma, et, word): allRight = True #sys.exit(0) #if not allRight: # print("filtered: " + lemma + ' : ' + form + ' : ' + word) return allRight