Esempio n. 1
0
 def get_classes_for_lexkey(self, lexkey, this_wn_version=None):
     if this_wn_version is None:
         #Then it's assumed to be using the proper wnversion for the selected semantic class (wn30 for BLC and wn21 for WND)
         pass
     elif this_wn_version != self.wn_version:
         #We need to map the synset from this_wn_Version to self.wn_version.
         if self.wn_mapper is None:
             from libs.WordNetMapper import WordNetMapper
             self.wn_mapper = WordNetMapper()
         o = lexkey
         lexkey = self.wn_mapper.map_lexkey_to_lexkey(
             lexkey, this_wn_version, self.wn_version)
     ######
     #We get the pos from the lexkey: rock_hopper%1:05:00:
     p = lexkey.find('%') + 1
     pos = self.normalise_pos(lexkey[p])
     this_class = None
     if pos is None:
         print >> sys.stderr, 'Pos %s not recognized' % this_pos
     else:
         if pos in self.map_synset_pos_to_class:
             synset = self.synset_for_lexkey.get(lexkey)
             if synset is not None:
                 this_class = self.map_synset_pos_to_class[pos].get(synset)
     return this_class
Esempio n. 2
0
    def get_classes_for_synset_pos(self,
                                   synset,
                                   this_pos,
                                   this_wn_version=None):
        if this_wn_version is None:
            #Then it's assumed to be using the proper wnversion for the selected semantic class (wn30 for BLC and wn21 for WND)
            pass
        elif this_wn_version != self.wn_version:
            #We need to map the synset from this_wn_Version to self.wn_version.
            if self.wn_mapper is None:
                from libs.WordNetMapper import WordNetMapper
                self.wn_mapper = WordNetMapper()
            synset, another_pos = self.wn_mapper.map_offset_to_offset(
                synset, this_wn_version, self.wn_version)
            #print 'Mapped synset wn30', synset

        pos = self.normalise_pos(this_pos)
        if pos is None:
            print >> sys.stderr, 'Pos %s not recognized' % this_pos
            return None
        else:
            if pos in self.map_synset_pos_to_class:
                return self.map_synset_pos_to_class[pos].get(synset)