Beispiel #1
0
 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',
     }
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
 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',
     }