def test_03(self): dict_value2texts = DictTool.append_key2values({"ReD": ["scarleTT", "radish"]}) gazetteer = GazetteerMatcher(dict_value2texts) span_value_list = list(gazetteer.text2span_value_iter("ReD scarlett blue radish")) hyp = span_value_list ref = [((0, 3), 'ReD'), ((18, 24), 'ReD')] # pprint(hyp) self.assertEqual(hyp, ref)
def test_01(self): dict_value2texts = DictTool.append_key2values( {"ReD": ["scarleTT", "radish"]}) matcher = FulltextMatcher(dict_value2texts, config={"normalizer": str2lower}) hyp1 = list(matcher.text2values("scarlett")) self.assertEqual(hyp1, ["ReD"]) hyp2 = list(matcher.text2values("red scarlett")) self.assertEqual(hyp2, [])
def test_01(self): dict_value2texts = DictTool.append_key2values({"ReD": ["scarleTT", "radish"]}) gazetteer = GazetteerMatcher(dict_value2texts, config={"normalizer":str2lower}) span_value_list = list(gazetteer.text2span_value_iter("red scarlett blue radish")) hyp = span_value_list ref = [((0, 3), 'ReD'), ((4, 12), 'ReD'), ((18, 24), 'ReD')] # pprint(hyp) self.assertEqual(hyp, ref)