def test_parse_feat_str_parse_valid_2(self): feature_string = "jaccard(qgm_3(ltuple['zipcode']), qgm_3(ltuple['zipcode']))" p_dict = parse_feat_str(feature_string, get_tokenizers_for_matching(), get_sim_funs_for_matching()) self.assertEqual(p_dict['left_attr_tokenizer'], 'qgm_3') self.assertEqual(p_dict['right_attr_tokenizer'], 'qgm_3') self.assertEqual(p_dict['simfunction'], 'jaccard')
def test_parse_feat_str_parse_valid_1(self): feature_string = "jaccard(qgm_3(ltuple['zipcode']), qgm_3(rtuple['zipcode']))" p_dict = parse_feat_str(feature_string, get_tokenizers_for_matching(), get_sim_funs_for_matching()) self.assertEqual(p_dict['left_attr_tokenizer'], 'qgm_3') self.assertEqual(p_dict['right_attr_tokenizer'], 'qgm_3') self.assertEqual(p_dict['simfunction'], 'jaccard') self.assertEqual(p_dict['left_attribute'], 'zipcode') self.assertEqual(p_dict['right_attribute'], 'zipcode')
def test_parse_feat_str_parse_exp(self): feature_string = "jaccard~(qgm_3(ltuple[['zipcode']), qgm_3(rtuple['zipcode']))" p_dict = parse_feat_str(feature_string, get_tokenizers_for_matching(), get_sim_funs_for_matching()) for k, v in six.iteritems(p_dict): self.assertEqual(v, 'PARSE_EXP')
def test_parse_feat_str_invalid_tok(self): parse_feat_str("", dict(), None)
def test_parse_feat_str_invalid_sim(self): parse_feat_str("", None, dict())
def test_parse_feat_str_invalid(self): parse_feat_str(None, dict(), dict())
import magellan as mg from magellan.feature.addfeatures import parse_feat_str feature_string = 'jaccard(qgm_3(ltuple["zipcode"]), qgm_3(rtuple["zipcode"]))' tok = mg.get_tokenizers_for_matching() sim = mg.get_sim_funs_for_matching() d = parse_feat_str(feature_string, tok, sim) print(d)
def test_parse_feat_str_parse_exp(self): feature_string = "jaccard~(qgm_3(ltuple[['zipcode']), qgm_3(rtuple['zipcode']))" p_dict = parse_feat_str(feature_string, get_tokenizers_for_matching(), get_sim_funs_for_matching()) for k,v in six.iteritems(p_dict): self.assertEqual(v, 'PARSE_EXP')
def test_parse_feat_str_invalid_tok(self): parse_feat_str("", dict(), None)
def test_parse_feat_str_invalid_sim(self): parse_feat_str("", None, dict())
def test_parse_feat_str_invalid(self): parse_feat_str(None, dict(), dict())