def _load(self, parsed_entities): entities = [] for group in parsed_entities.keys(): for element in parsed_entities[group].keys(): fuzzy = FuzzySet() for x in [element] + parsed_entities[group][element]: fuzzy.add(x) entity = { "group": group, "canonical": element, "fuzzy": fuzzy } entities.append(entity) return entities
def __init__(self, **kwargs): super().__init__(**kwargs) self._fuzzy = FuzzySet([self.title, *self.aliases])
#!/user/bin/env python # coding:utf-8 from cfuzzyset import cFuzzySet as FuzzySet import re ceo_list = [] ceo_edu_dic = {} a = FuzzySet() count = 0 def check_name(name): name_tmp = name.strip().split() if len(name) <= 5: return False if len(name_tmp) == 1: return False if name_tmp[0] == name_tmp[1]: return False else: return True def clean_name(name): todel = [i.start() for i in re.finditer('"', name)] if len(todel) == 2: myString = name[0:todel[0]] + name[todel[1] + 2:-1] #print name + ' ---> ' + myString return myString