def test_lowest_common_ancestor3(self): result = lowest_common_ancestor(self.taxonomy, ["'Sausage_and_Tortellini_Soup'", "'Zuppa_alla_modenese'", "'Spinach_Calzones'", "'Albanian_Vegetable_Pie'"], "'Rye_Bread'") assert result == (20, "'Spinach_recipes'")
def test_lowest_common_ancestor3(self): self.get_ancestor_categories("Main topic classifications") self.get_ancestor_categories("Science") self.get_ancestor_categories("Anthropology") self.get_ancestor_categories("Biology") self.get_ancestor_categories("Species") self.get_ancestor_categories("Dogs") result = lowest_common_ancestor(self.taxonomy, [ "Poodle", "Irish Water Spaniel", "Wetterhoun", "Lagotto Romagnolo" ], "Golden Retriever") print("Lowest common ancestor 3:", result) assert result == (4, "Water dogs")
def test_lowest_common_ancestor2(self): self.get_ancestor_categories("Main topic classifications") self.get_ancestor_categories("Science") self.get_ancestor_categories("Mind") self.get_ancestor_categories("Vision") self.get_ancestor_categories("Light") self.get_ancestor_categories("Colors") result = lowest_common_ancestor(self.taxonomy, ["Yellow", "Red", "Green", "Blue"], "Cyan") print("Lowest common ancestor 2:", result) assert result == (104999, "Contents")
def test_lowest_common_ancestor1(self): """ The first few calls to get_ancestor_categories warms up the taxonomy cache, making ancestors of a certain node easy to query so that calling lowest_common_ancestor takes less time, leaving less room for error due to the DBpedia endpoint being busy or Internet shorting out. This is common among all the test_lowest_common_ancestor methods. """ self.get_ancestor_categories("Main topic classifications") self.get_ancestor_categories("Science") self.get_ancestor_categories("Mind") self.get_ancestor_categories("Vision") self.get_ancestor_categories("Light") self.get_ancestor_categories("Colors") self.get_ancestor_categories("Anatomy") self.get_ancestor_categories("Branches of botany") self.get_ancestor_categories("Fruit") result = lowest_common_ancestor(self.taxonomy, ["Yellow", "Red", "Green", "Blue"], "Apple") print("Lowest common ancestor 1:", result) assert result == (168, "Rainbow colors")
def test_lowest_common_ancestor1(self): result = lowest_common_ancestor(self.taxonomy, ['orange', 'red', 'green', 'blue'], 'apple') assert result == (168, 'chromatic_color.n.01')
def test_lowest_common_ancestor4(self): result = lowest_common_ancestor(self.example, ['orange', 'peach'], 'red') assert result == (4, 'fruit')
def test_lowest_common_ancestor3(self): result = lowest_common_ancestor(self.example, ['orange', 'peach'], 'lemon') assert result == (4, 'color')
def test_lowest_common_ancestor2(self): result = lowest_common_ancestor(self.example, ['orange', 'lemon', 'peach'], 'apple') assert result == (6, 'entity')
def test_lowest_common_ancestor1(self): result = lowest_common_ancestor(self.example, ['orange', 'lemon'], 'apple') assert result == (2, 'citrus')
def test_lowest_common_ancestor2(self): result = lowest_common_ancestor(self.taxonomy, ["Yellow", "Red", "Green", "Blue"], "Cyan") assert result == (104999, "Contents")
def test_lowest_common_ancestor1(self): result = lowest_common_ancestor(self.taxonomy, ["'Chow_Mein'", "'Ghavoot'", "'Ragi_Dosa'", "'Vegan_Pate'"], "'Roasted_Brined_Turkey'") assert result == (229, "'Vegan_recipes'")
def __call__(self, word, other_words): spec, reason = lowest_common_ancestor(self.taxonomy, list(other_words), word) return 1.0 / spec, reason
def test_lowest_common_ancestor3(self): result = lowest_common_ancestor(self.taxonomy, ["Poodle", "Irish Water Spaniel", "Wetterhoun", "Lagotto Romagnolo"], "Golden Retriever") assert result == (4, "Water dogs")
def test_lowest_common_ancestor2(self): result = lowest_common_ancestor(self.taxonomy, ['orange', 'red', 'green', 'blue'], 'gold') assert result == (104363, 'entity.n.01')
def test_lowest_common_ancestor2(self): result = lowest_common_ancestor(self.taxonomy, ["'Chow_Mein'", "'Ghavoot'", "'Ragi_Dosa'", "'Vegan_Pate'"], "'Soy_Milk'") assert result == (3122, "'Recipes'")
def test_lowest_common_ancestor3(self): result = lowest_common_ancestor(self.taxonomy, ['large poodle', 'miniature poodle', 'standard poodle', 'toy poodle'], 'beagle') assert result == (4, 'poodle.n.01')
def test_lowest_common_ancestor1(self): result = lowest_common_ancestor(self.taxonomy, ["Yellow", "Red", "Green", "Blue"], "Apple") assert result == (168, "Rainbow colors")