예제 #1
0
func otag(t *testing.T, classifier *fuz.Classifier, tag string, inputs string) {
	for _, input := range strings.Split(inputs, "\n") {
		input = strings.TrimSpace(input)
		if input == "" {
			continue
		}
		if strings.HasPrefix(input, "#") {
			continue
		}

		r := classifier.Process(input)
		actual, _ := r.GetTagMatchString(tag, fuz.Raw)

		inputAdjusted := fuz.CanonicalString(input)

		if actual != inputAdjusted {
			if actual != "" {
				t.Errorf("In %#v only matched %#v", input, actual)
			} else {
				t.Errorf("In %#v no match", input)
			}
			t.Logf("Result =\n%v", r.Description())
		}
	}
}
예제 #2
0
		matcher := rp.NewMatcher()

		incorrect := new(UniqueStringList)
		matched := new(UniqueStringList)
		partial := new(UniqueStringList)
		unmatched := new(UniqueStringList)
		problematic := new(UniqueStringList)
		problematicDirections := new(UniqueStringList)

		for _, recipe := range recipes {
			totalIngredients := 0
			matchedIngredients := 0

			var problematicHere []string
			for _, ingred := range recipe.Ingredients {
				s := fuz.CanonicalString(ingred.Text)

				subheadm := matcher.MatchIngredientSubhead(s)
				im := matcher.MatchIngredient(s)
				dm := matcher.MatchDirection(s)

				if subheadm.Confidence >= rp.Likely {
					continue
				}

				switch im.Confidence {
				case rp.Negative:
					incorrect.Add(s)
				case rp.Perfect:
					matchedIngredients++
					matched.Add(s + "\n")