Beispiel #1
0
    def handle_cop_with_adjp(self, relations, index, context, engine, info):
        """Handle copular verbs with ADJP complements."""

        subjs = self.process_subj(relations, index, context, engine, info)

        cop_index = Relation.get_children_with_dep('cop', relations, index)[0]
        cop = engine.analyze(relations, cop_index, context + [index])

        auxs = self.process_auxs(relations, index, context, engine, info)

        verb = ' '.join([word for word in auxs + [cop] if word is not None])

        self.process_ignorables(relations, index, context, engine, info)

        self.process_npadvmod(relations, index, context, engine, info)

        this = AdjectivalPhraseRuleset.extract(self, relations, index, context,
                                               engine, info)

        prop_ids = []
        for subj in subjs['return_list']:
            for word in this:
                prop_id = engine.emit((verb, subj, word), 'P')
                prop_ids.append(prop_id)

        self.subjs = subjs
        self.auxs = auxs

        return {'return_value': None, 'prop_ids': prop_ids}
Beispiel #2
0
    def handle_cop_with_adjp(self, relations, index, context, engine, info):

        """Handle copular verbs with ADJP complements."""

        subjs = self.process_subj(relations, index, context, engine, info)

        try:
            cop_index = Relation.get_children_with_dep('cop', relations, index)[0]
            cop = engine.analyze(relations, cop_index, context + [index])
        except IndexError:
            return {'return_value': None, 'prop_ids': []}
            # print(relations[index])
            # raise

        auxs = self.process_auxs(relations, index, context, engine, info)

        verb = ' '.join([word for word in auxs + [cop] if word is not None])

        self.process_ignorables(relations, index, context, engine, info)

        self.process_npadvmod(relations, index, context, engine, info)

        this = AdjectivalPhraseRuleset.extract(self, relations, index, context,
                                               engine, info)

        prop_ids = []
        for subj in subjs['return_list']:
            for word in this:
                prop_id = engine.emit((verb, subj, word), 'P')
                prop_ids.append(prop_id)

        self.subjs = subjs
        self.auxs = auxs

        return {'return_value': None, 'prop_ids': prop_ids}
Beispiel #3
0
 def extract(self, relations, index, context, engine, info={}):
     if relations[index].tag in ('NN', 'NNS', 'NNP', 'NNPS'):
         this = NounPhraseRuleset.extract(self, relations, index, context,
                                          engine, info)
         for noun in this['return_list']:
             engine.emit((noun, ), 'WHAT')
     elif relations[index].tag == 'JJ':
         this = AdjectivalPhraseRuleset.extract(self, relations, index,
                                                context, engine, info)
         for adj in this:
             engine.emit((adj, ), 'WHAT')
     else:
         # In case something weird happens, we just emit the word.
         engine.emit((relations[index].word, ), 'WHAT')
Beispiel #4
0
 def extract(self, relations, index, context, engine, info={}):
     if relations[index].tag in ('NN', 'NNS', 'NNP', 'NNPS'):
         this = NounPhraseRuleset.extract(self, relations, index, context,
                                          engine, info)
         for noun in this['return_list']:
             engine.emit((noun,), 'WHAT')
     elif relations[index].tag == 'JJ':
         this = AdjectivalPhraseRuleset.extract(self, relations, index,
                                                context, engine, info)
         for adj in this:
             engine.emit((adj,), 'WHAT')
     else:
         # In case something weird happens, we just emit the word.
         engine.emit((relations[index].word,), 'WHAT')