Esempio n. 1
0
    def test_paraphrase_graph_one_context(self):
        self.assertItemsEqual(
            synonyms._paraphrase_graph(self.fake_graph, "A", ["foo"], True,
                                       False), ["B", "C", "E", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(self.fake_graph, "A", ["foo"], False,
                                       False), ["B", "C", "E", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(self.fake_graph, "A", ["foo"], True,
                                       True), ["B", "C", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(self.fake_graph, "A", ["foo"], False,
                                       True), ["B", "C", "D"])
Esempio n. 2
0
 def test_paraphrase_graph_too_large(self):
     self.fake_graph.add_mapping("foo", "X", "W", False)
     self.fake_graph.add_mapping("foo", "X", "Y", False)
     self.fake_graph.add_mapping("foo", "X", "Z", False)
     self.fake_graph.add_mapping("foo", "X", "G", False)
     self.assertTrue(len(self.fake_graph), 11)
     self.assertEqual(
         synonyms._paraphrase_graph(self.fake_graph, "A", ["foo", "bar"],
                                    False, True), [])
Esempio n. 3
0
 def test_paraphrase_graph_too_large(self):
     self.fake_graph.add_mapping("foo", "X", "W", False)
     self.fake_graph.add_mapping("foo", "X", "Y", False)
     self.fake_graph.add_mapping("foo", "X", "Z", False)
     self.fake_graph.add_mapping("foo", "X", "G", False)
     self.assertTrue(len(self.fake_graph), 11)
     self.assertEqual(
         synonyms._paraphrase_graph(
             self.fake_graph, "A", ["foo", "bar"], False, True), [])
Esempio n. 4
0
    def test_paraphrase_graph_one_context(self):
        self.assertItemsEqual(
            synonyms._paraphrase_graph(
                self.fake_graph, "A", ["foo"], True, False),
            ["B", "C", "E", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(
                self.fake_graph, "A", ["foo"], False, False),
            ["B", "C", "E", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(
                self.fake_graph, "A", ["foo"], True, True),
            ["B", "C", "D"])

        self.assertItemsEqual(
            synonyms._paraphrase_graph(
                self.fake_graph, "A", ["foo"], False, True),
            ["B", "C", "D"])
Esempio n. 5
0
 def test_paraphrase_graph_union_exclude(self):
     # union, excludes unrend
     self.assertItemsEqual(
         synonyms._paraphrase_graph(self.fake_graph, "A", ["foo", "bar"],
                                    False, True), ["B", "C", "D"])
Esempio n. 6
0
 def test_paraphrase_graph_intersect_exclude(self):
     # intersection, excludes unrend
     self.assertItemsEqual(
         synonyms._paraphrase_graph(self.fake_graph, "A", ["foo", "bar"],
                                    True, True), ["D"])
Esempio n. 7
0
 def test_paraphrase_graph_union_exclude(self):
     # union, excludes unrend
     self.assertItemsEqual(
         synonyms._paraphrase_graph(
             self.fake_graph, "A", ["foo", "bar"], False, True),
         ["B", "C", "D"])
Esempio n. 8
0
 def test_paraphrase_graph_intersect_exclude(self):
     # intersection, excludes unrend
     self.assertItemsEqual(
         synonyms._paraphrase_graph(
             self.fake_graph, "A", ["foo", "bar"], True, True),
         ["D"])