Exemple #1
0
    def look_up(self, anaphor, antecedent):
        """ Look up strings of the mentions in the pair list.

        Args:
            anaphor (Mention): A mention.
            antecedent (Mention): Another mention, the candidate antecedent
                for anaphor.

        Returns:
            True if the pair of strings corresponding to anaphor of
            antecedent, stripped determiners and possessive s, can be found
            in the list of pairs.
        """
        # whole string
        anaphor_cleaned = " ".join(
            util.clean_via_pos(anaphor.attributes["tokens"],
                          anaphor.attributes["pos"]))
        antecedent_cleaned = " ".join(
            util.clean_via_pos(antecedent.attributes["tokens"],
                               antecedent.attributes["pos"]))

        return (
            (anaphor_cleaned, antecedent_cleaned) in self.pairs
            or (antecedent_cleaned, anaphor_cleaned) in self.pairs
        )
Exemple #2
0
def non_pronominal_string_match(anaphor, antecedent):
    if anaphor.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    elif antecedent.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    else:
        return (" ".join(util.clean_via_pos(anaphor.attributes["tokens"],
                                            anaphor.attributes["pos"])).lower()
                == " ".join(util.clean_via_pos(
                            antecedent.attributes["tokens"],
                            antecedent.attributes["pos"])).lower())
Exemple #3
0
def non_pronominal_string_match(anaphor, antecedent):
    if anaphor.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    elif antecedent.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    else:
        return (" ".join(
            util.clean_via_pos(anaphor.attributes["tokens"],
                               anaphor.attributes["pos"])).lower() == " ".join(
                                   util.clean_via_pos(
                                       antecedent.attributes["tokens"],
                                       antecedent.attributes["pos"])).lower())
Exemple #4
0
def not_compatible(anaphor, antecedent):
    if (" ".join(
            util.clean_via_pos(anaphor.attributes["tokens"],
                               anaphor.attributes["pos"])).lower() == " ".join(
                                   util.clean_via_pos(
                                       antecedent.attributes["tokens"],
                                       antecedent.attributes["pos"])).lower()):
        return False

    gender = (anaphor.attributes["gender"] == "UNKNOWN"
              or antecedent.attributes["gender"] == "UNKNOWN" or
              anaphor.attributes["gender"] == antecedent.attributes["gender"])

    number = (anaphor.attributes["number"] == "UNKNOWN"
              or antecedent.attributes["number"] == "UNKNOWN" or
              anaphor.attributes["number"] == antecedent.attributes["number"])

    semantic_class = (anaphor.attributes["semantic_class"] == "UNKNOWN"
                      or antecedent.attributes["semantic_class"] == "UNKNOWN"
                      or anaphor.attributes["semantic_class"]
                      == antecedent.attributes["semantic_class"])

    return not (gender and number and semantic_class)
Exemple #5
0
def not_compatible(anaphor, antecedent):
    if (" ".join(util.clean_via_pos(anaphor.attributes["tokens"],
                                    anaphor.attributes["pos"])).lower() ==
            " ".join(util.clean_via_pos(antecedent.attributes["tokens"],
                                        antecedent.attributes["pos"])).lower()):
        return False

    gender = (anaphor.attributes["gender"] == "UNKNOWN"
              or antecedent.attributes["gender"] == "UNKNOWN"
              or anaphor.attributes["gender"]
              == antecedent.attributes["gender"])

    number = (anaphor.attributes["number"] == "UNKNOWN"
              or antecedent.attributes["number"] == "UNKNOWN"
              or anaphor.attributes["number"]
              == antecedent.attributes["number"])

    semantic_class = (anaphor.attributes["semantic_class"] == "UNKNOWN"
                      or antecedent.attributes["semantic_class"] == "UNKNOWN"
                      or anaphor.attributes["semantic_class"]
                      == antecedent.attributes["semantic_class"])

    return not (gender and number and semantic_class)
    def look_up(self, anaphor, antecedent):
        """ Look up strings of the mentions in the pair list.

        Args:
            anaphor (Mention): A mention.
            antecedent (Mention): Another mention, the candidate antecedent
                for anaphor.

        Returns:
            True if the pair of strings corresponding to anaphor of
            antecedent, stripped determiners and possessive s, can be found
            in the list of pairs.
        """
        # whole string
        anaphor_cleaned = " ".join(
            util.clean_via_pos(anaphor.attributes["tokens"],
                               anaphor.attributes["pos"]))
        antecedent_cleaned = " ".join(
            util.clean_via_pos(antecedent.attributes["tokens"],
                               antecedent.attributes["pos"]))

        return ((anaphor_cleaned, antecedent_cleaned) in self.pairs
                or (antecedent_cleaned, anaphor_cleaned) in self.pairs)
Exemple #7
0
def substring(anaphor, antecedent):
    if anaphor.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    elif antecedent.attributes["type"] != "NAM":
        return False
    elif (anaphor.attributes["semantic_class"] == "NUMERIC"
          or antecedent.attributes["semantic_class"] == "NUMERIC"):
        return False
    elif anaphor.attributes["head"] == ["and"]:
        return False
    else:
        cleaned = util.clean_via_pos(anaphor.attributes["tokens"],
                                     anaphor.attributes["pos"])

        return (" ".join(cleaned).lower()
                in " ".join(antecedent.attributes["tokens"]).lower())
Exemple #8
0
def substring(anaphor, antecedent):
    if anaphor.attributes["type"] in ["PRO", "DEM", "VRB"]:
        return False
    elif antecedent.attributes["type"] != "NAM":
        return False
    elif (anaphor.attributes["semantic_class"] == "NUMERIC" or
          antecedent.attributes["semantic_class"] == "NUMERIC"):
        return False
    elif anaphor.attributes["head"] == ["and"]:
        return False
    else:
        cleaned = util.clean_via_pos(
            anaphor.attributes["tokens"],
            anaphor.attributes["pos"])

        return (" ".join(cleaned).lower()
                in " ".join(antecedent.attributes["tokens"]).lower())
Exemple #9
0
 def test_clean_via_pos(self):
     self.assertEqual(
         ["newly-elect", "leader", "wife"],
         clean_via_pos(["the", "newly-elect", "leader", "'s", "wife"],
                       ["DT", "JJ", "NN", "POS", "NN"]))
Exemple #10
0
 def test_clean_via_pos(self):
     self.assertEqual(
         ["newly-elect", "leader", "wife"],
         clean_via_pos(
             ["the", "newly-elect", "leader", "'s", "wife"],
             ["DT", "JJ", "NN", "POS", "NN"]))