Exemple #1
0
    def process_edge(self, edge, depth):
        hg = self.system.get_hg(self)

        if not edge.is_atom():
            ct = edge.connector_type()
            if ct[:2] == 'Pd':
                pred = edge[0]
                if (len(edge) > 2 and deep_lemma(hg, pred).root()
                        in CONFLICT_PRED_LEMMAS):
                    subjects = edge.edges_with_argrole('s')
                    objects = edge.edges_with_argrole('o')
                    if len(subjects) == 1 and len(objects) == 1:
                        subject = strip_concept(subjects[0])
                        obj = strip_concept(objects[0])
                        if (subject and obj and has_proper_concept(subject)
                                and has_proper_concept(obj)):
                            actor_orig = main_coref(hg, subject)
                            actor_targ = main_coref(hg, obj)
                            conflict_edge = hedge(
                                ('conflict/P/.', actor_orig, actor_targ, edge))
                            if (is_actor(hg, actor_orig)
                                    and is_actor(hg, actor_targ)):
                                yield create_op(conflict_edge)
                                for wedge in self._topics(
                                        hg, actor_orig, actor_targ, edge):
                                    yield wedge
                                self.conflicts += 1
 def input_edge(self, edge):
     if (not edge.is_atom() and
             len(edge) == 2 and
             edge[0].is_atom() and
             edge[0].root() == 'the' and
             has_proper_concept(edge[1])):
         make_corefs(self.hg, edge, edge[1])
         self.corefs += 1
Exemple #3
0
    def process_edge(self, edge, depth):
        hg = self.system.get_hg(self)

        if (not edge.is_atom() and len(edge) == 2 and edge[0].is_atom()
                and edge[0].root() == 'the' and has_proper_concept(edge[1])):
            self.corefs += 1
            for op in make_corefs_ops(hg, edge, edge[1]):
                yield op
Exemple #4
0
 def process_edge(self, edge, depth):
     if not edge.is_atom():
         conn = edge[0]
         ct = edge.connector_type()
         if ct[0] == 'B' and conn.atom().root() == '+':
             if len(edge) > 2:
                 concepts = edge.main_concepts()
                 if len(concepts) == 1 and has_proper_concept(concepts[0]):
                     self.seeds.add(concepts[0])
Exemple #5
0
    def process_edge(self, edge, depth):
        hg = self.system.get_hg(self)

        if not edge.is_atom():
            ct = edge.connector_type()
            if ct[:2] == 'Pd':
                subjects = edge.edges_with_argrole('s')
                if len(subjects) == 1:
                    subject = strip_concept(subjects[0])
                    if subject and has_proper_concept(subject):
                        pred = edge[0]
                        dlemma = deep_lemma(hg, pred).root()
                        if dlemma in ACTOR_PRED_LEMMAS:
                            try:
                                actor = main_coref(hg, subject)
                                self.actor_counter[actor] += 1
                            except Exception as e:
                                print(str(e))
Exemple #6
0
    def process_edge(self, edge, depth):
        hg = self.system.get_hg(self)

        if not edge.is_atom():
            ct = edge.connector_type()
            if ct[:2] == 'Pd':
                pred = edge[0]
                if (len(edge) > 2
                        and deep_lemma(hg, pred).root() in CLAIM_PRED_LEMMAS):
                    subjects = edge.edges_with_argrole('s')
                    claims = edge.edges_with_argrole('r')
                    if len(subjects) == 1 and len(claims) >= 1:
                        subject = strip_concept(subjects[0])
                        if subject and has_proper_concept(subject):
                            actor = main_coref(hg, subjects[0])
                            if self._is_actor(hg, actor):
                                for claim in claims:
                                    self._process_claim(actor, claim, edge)
Exemple #7
0
def conflict_topics(hg):
    global all_topics
    if all_topics is None:
        all_topics = Counter()
        topics = Counter()

        for conflict_edge in hg.search('(conflict/p/. * * *)'):
            actor1 = main_coref(hg, conflict_edge[1])
            actor2 = main_coref(hg, conflict_edge[2])
            if is_valid(hg, actor1) and is_valid(hg, actor2):
                edge = conflict_edge[3]
                for item in edge[1:]:
                    if item.type()[0] == 's':
                        if item[0].to_str() in conflict_topic_triggers:
                            for concept in all_concepts(item[1]):
                                topic = main_coref(hg, concept)
                                topics[topic] += 1
        for topic, weight in topics.most_common():
            if weight > 1 and has_proper_concept(topic):
                all_topics[topic] = weight
    return all_topics
Exemple #8
0
    def process_edge(self, edge, depth):
        hg = self.system.get_hg(self)

        if not edge.is_atom():
            ct = edge.connector_type()
            if ct[0] == 'P':
                pred = edge[0]
                if (len(edge) > 2
                        and deep_lemma(hg, pred, same_if_none=True).root()
                        in CLAIM_PRED_LEMMAS):
                    subjects = edge.edges_with_argrole('s')
                    claims = edge.edges_with_argrole('r')
                    if len(subjects) == 1 and len(claims) >= 1:
                        subject = strip_concept(subjects[0])
                        if subject and has_proper_concept(subject):
                            actor = main_coref(hg, subject)
                            self.actors.add(actor)
                            for claim in claims:
                                # if specificatin, claim is inside
                                if claim.type()[0] == 'S':
                                    self._process_claim(actor, claim[1], edge)
                                else:
                                    self._process_claim(actor, claim, edge)