Example #1
0
 def testIngInIngsRoughMatch1(self):
     ing = Ingredient({
         "ref": "#Zucker",
         "quantity": "1",
         "unit": "EL"
     }, ["Zucker"], (0, 0))
     self.assertTrue(
         ingInIngsRoughMatch(ing, getIngs(), getIngs(),
                             set(("ref", "quantity", "unit"))))
Example #2
0
 def testIngInIngsRoughMatch6(self):
     ing = Ingredient({"ref": "#Knollensellerie #Sellerieblätter"},
                      ["Sellerie"], (17, 17))
     goldenStandardIngs = [
         Ingredient({"ref": "#Knollensellerie"}, ["Knollensellerie"],
                    (0, 0))
     ]
     self.assertTrue(
         ingInIngsRoughMatch(ing, goldenStandardIngs,
                             [ing] + goldenStandardIngs, set(("ref", ))))
Example #3
0
def precisionOf2Recipes(ingsOfGoldenStandardRcp,
                        retrievedIngs,
                        attris,
                        debug=False):
    retrieved = len(retrievedIngs)
    retrievedAndRelevant = 0

    for ing in retrievedIngs:
        if ingInIngsExactMatch(ing, ingsOfGoldenStandardRcp, attris):
            retrievedAndRelevant += 1
        elif ingInIngsRoughMatch(ing, ingsOfGoldenStandardRcp, retrievedIngs,
                                 attris):
            retrieved -= 1
        elif debug:
            print("Not relevant but retrieved: {}".format(ing))

    return retrievedAndRelevant, retrieved
Example #4
0
 def testIngInIngsRoughMatch5(self):
     ing = Ingredient({"ref": "#asf"}, ["Biokleidung"], (0, 0))
     self.assertFalse(
         ingInIngsRoughMatch(ing, getIngs(), getIngs(),
                             set(("ref", "quantity", "unit"))))
Example #5
0
 def testIngInIngsRoughMatch4(self):
     ing = Ingredient({"ref": "#Kalsbrühe"}, ["Kalbsbrühe"], (0, 0))
     self.assertTrue(
         ingInIngsRoughMatch(ing, getIngs(), getIngs(),
                             set(("ref", "quantity", "unit"))))
Example #6
0
 def testIngInIngsRoughMatch3(self):
     ing = Ingredient({"ref": "#Zucker"}, ["Zucker"], (0, 0))
     ingsExtracted = [ing]
     self.assertFalse(
         ingInIngsRoughMatch(ing, getIngs(), ingsExtracted,
                             set(("ref", "quantity", "unit"))))