def __init__(self): self.morpher = MorphIt(os.path.join("data", "morph-it.txt")) self.morph_to_wn = { "VER": 'v', "DET-INDEF": 'a', "NOUN-M": 'n', "NOUN-F": 'n', }
class SimpleSplitter(Splitter): def __init__(self): self.morpher = MorphIt(os.path.join("data", "morph-it.txt")) self.morph_to_wn = { "VER": 'v', "DET-INDEF": 'a', "NOUN-M": 'n', "NOUN-F": 'n', } def get_type(self, features): try: return self.morph_to_wn[features.split(':')[0]] except: return None def iter_words(self, sentence): for word, indices in iter_words(sentence): ret = self.morpher.find(word) if ret: word, lemma, features = ret wn_type = self.get_type(features) else: word, lemma, features = word, word, 'n' wn_type = 'n' yield word, lemma, features, wn_type, indices
class SimpleSplitter(Splitter): def __init__(self): self.morpher = MorphIt(os.path.join("data", "morph-it.txt")) self.morph_to_wn = { "VER" : 'v', "DET-INDEF": 'a', "NOUN-M": 'n', "NOUN-F": 'n', } def get_type(self, features): try: return self.morph_to_wn[features.split(':')[0]] except: return None def iter_words(self, sentence): for word, indices in iter_words(sentence): ret = self.morpher.find(word) if ret: word, lemma, features = ret wn_type = self.get_type(features) else: word, lemma, features = word, word, 'n' wn_type = 'n' yield word, lemma, features, wn_type, indices
def __init__(self): self.morpher = MorphIt(os.path.join("data", "morph-it.txt")) self.morph_to_wn = { "VER" : 'v', "DET-INDEF": 'a', "NOUN-M": 'n', "NOUN-F": 'n', }