Esempio n. 1
0
 def apply(self, sentence, mention, features):
     # head_index = HeadFeature.get_head(sentence, mention)
     # for dep_type, gov, dep in sentence.dep:
     #     if head_index == gov:
     #         token = 'root'
     #         if dep >= 0:
     #             token = get_lemma(sentence.tokens[dep], sentence.pos[dep])
     #         features.append('ROLE_gov:%s' % dep_type)
     #         features.append('PARENT_%s' % token)
     #     if head_index == dep:
     #         token = 'root'
     #         if gov >= 0:
     #             token = get_lemma(sentence.tokens[dep], sentence.pos[gov])
     #         features.append('ROLE_dep:%s' % dep_type)
     #         features.append('PARENT_%s' % token)
     start = mention.start
     end = mention.end
     for dep_type, gov, dep in sentence.dep:
         if start <= gov < end:
             if 0 <= dep < sentence.size():
                 token = get_lemma(sentence.tokens[dep], sentence.pos[dep])
                 pos = sentence.pos[dep]
                 if self.accept_pos(pos) and self.accept_dep(dep_type):
                     key = "gov:" + dep_type + ":" + token + "=" + pos[0]
                     features.append(("DEP_" + key))
         if start <= dep < end:
             if 0 <= gov < sentence.size():
                 token = get_lemma(sentence.tokens[gov], sentence.pos[gov])
                 pos = sentence.pos[gov]
                 if self.accept_pos(pos) and self.accept_dep(dep_type):
                     key = "dep:" + dep_type + ":" + token + "=" + pos[0]
                     features.append(("DEP_" + key))
Esempio n. 2
0
 def apply(self, sentence, mention, features):
     # head_index = HeadFeature.get_head(sentence, mention)
     # for dep_type, gov, dep in sentence.dep:
     #     if head_index == gov:
     #         token = 'root'
     #         if dep >= 0:
     #             token = get_lemma(sentence.tokens[dep], sentence.pos[dep])
     #         features.append('ROLE_gov:%s' % dep_type)
     #         features.append('PARENT_%s' % token)
     #     if head_index == dep:
     #         token = 'root'
     #         if gov >= 0:
     #             token = get_lemma(sentence.tokens[dep], sentence.pos[gov])
     #         features.append('ROLE_dep:%s' % dep_type)
     #         features.append('PARENT_%s' % token)
     start = mention.start
     end = mention.end
     for dep_type, gov, dep in sentence.dep:
         if start <= gov < end:
             if 0 <= dep <sentence.size():
                 token = get_lemma(sentence.tokens[dep], sentence.pos[dep])
                 pos = sentence.pos[dep]
                 if self.accept_pos(pos) and self.accept_dep(dep_type):
                     key = "gov:" + dep_type + ":" + token + "=" + pos[0]
                     features.append(("DEP_" + key))
         if start <= dep < end:
             if 0 <= gov < sentence.size():
                 token = get_lemma(sentence.tokens[gov], sentence.pos[gov])
                 pos = sentence.pos[gov]
                 if self.accept_pos(pos) and self.accept_dep(dep_type):
                     key = "dep:" + dep_type + ":" + token + "=" + pos[0]
                     features.append(("DEP_" + key))
Esempio n. 3
0
 def apply(self, sentence, mention, features):
     for i in xrange(len(sentence.tokens)):
         word = get_lemma(sentence.tokens[i], sentence.pos[i])
         if word in self.mapping:
             cluster = self.mapping[word]
             for l in self.len:
                 if len(cluster) >= l:
                     features.append('BROWN_%d_%s' % (l, cluster[0:l]))
             features.append('BROWN_ALL_%s' % cluster)
Esempio n. 4
0
 def apply(self, sentence, mention, features):
     for i in xrange(mention.start,mention.end):
         word = get_lemma(sentence.tokens[i], sentence.pos[i])
         if word in self.mapping:
             cluster = self.mapping[word]
             for l in self.len:
                 if len(cluster) >= l:
                     features.append('BROWN_%d_%s' % (l, cluster[0:l]))
             features.append('BROWN_ALL_%s' % cluster)