Exemplo n.º 1
0
 def test_combination(self):
     score0 = MultipleScore()
     score0.add_score(1, None, None)
     score1 = MultipleScore()
     score1.add_score(0.5, None, None)
     score2 = MultipleScore()
     score2.add_score(0.7, None, None)
     generated_fact0 = GeneratedFact("lion", "eat", "zebra", "", False, score0,
                                     MultipleSourceOccurrence.from_raw("lions eat zebras", None, 1))
     mso = MultipleSourceOccurrence()
     mso.add_raw("lions eat zebras", None, 2)
     mso.add_raw("lions eat small zebras", None, 1)
     generated_fact1 = GeneratedFact("lion", "eat", "zebra", "", False, score1,
                                     mso)
     generated_fact2 = GeneratedFact("lion", "eat", "zebra", "", False, score2,
                                     MultipleSourceOccurrence.from_raw("lions eat small zebras", None, 1))
     new_gfs = [generated_fact0, generated_fact1, generated_fact2]
     inputs = self.empty_input.add_generated_facts(new_gfs)
     fact_combinor = FactCombinor(None)
     inputs = fact_combinor.process(inputs)
     self.assertEqual(1, len(inputs.get_generated_facts()))
     self.assertEqual(3, len(inputs.get_generated_facts()[0].get_score().scores))
     sentence = str(inputs.get_generated_facts()[0].get_sentence_source())
     self.assertIn("lions eat zebras", sentence)
     self.assertIn("lions eat small zebras", sentence)
     self.assertIn("x#x3", sentence)
     self.assertIn("x#x2", sentence)
Exemplo n.º 2
0
 def test_not_remove(self):
     inputs = Inputs()
     mso = MultipleSourceOccurrence()
     mso.add_raw("elephants eat big bananas", None, 2)
     gfs = [
         GeneratedFact("elephant", "eat", "bananas", "TBC[big bananas]", 0,
                       MultipleScore(), mso)
     ]
     inputs = inputs.add_generated_facts(gfs)
     tbc_cleaner = TBCCleaner(None)
     inputs = tbc_cleaner.process(inputs)
     self.assertEqual(len(inputs.get_generated_facts()), 1)
Exemplo n.º 3
0
 def test_beach(self):
     score0 = MultipleScore()
     score0.add_score(1, None, None)
     mso = MultipleSourceOccurrence()
     mso.add_raw("beaches have sand", "Google Autocomplete", 4)
     mso.add_raw("some beaches have sand", "Google Autocomplete", 2)
     mso.add_raw("some beaches have sand and some rocks", "Google "
                                                          "Autocomplete", 1)
     mso.add_raw("all beaches have sand", "Google Autocomplete", 4)
     mso.add_raw("beach have sand", "Google Autocomplete", 1)
     generated_fact0 = GeneratedFact("beach", "have", "sand",
                                     "some[subj/some] x#x3 // "
                                     "some[subj/all] x#x4",
                                     False,
                                     score0,
                                     mso)
     inputs = self.empty_input.add_generated_facts([generated_fact0])
     fact_combinor = FactCombinor(None)
     inputs = fact_combinor.process(inputs)
     self.assertEqual(1, len(inputs.get_generated_facts()))