def build_matcher_from_lists(*collections: List[str]) -> StringMatcher: matcher = StringMatcher(MatchStrategy.TrieTree, NumberWithUnitTokenizer()) matcher_list = [] for collection in collections: list(map(lambda x: matcher_list.append(x.strip().lower()), collection)) matcher_list = TimeZoneUtility.distinct(matcher_list) matcher.init(matcher_list) return matcher
def build_matcher_from_lists(self, collections: []): matcher: StringMatcher = StringMatcher(MatchStrategy.TrieTree, NumberWithUnitTokenizer()) matcher_list = [] for collection in collections: list(map(lambda x: matcher_list.append(x.strip().lower()), collection)) matcher_list = self.distinct(matcher_list) matcher.init(matcher_list) return matcher
def _build_matcher_from_set(self, definitions) -> StringMatcher: matcher = StringMatcher(match_strategy=MatchStrategy.TrieTree, tokenizer=NumberWithUnitTokenizer()) match_term_list = list(map(lambda words: list(filter(lambda word: not str.isspace(word) and word is not None, str(words).strip().split('|'))), definitions)) match_terms = self.distinct(match_term_list) flatten = [item for sublist in match_terms for item in sublist] matcher.init(flatten) return matcher