def multi_iter_search_with_keep(words, texts, ms=None): from itertools import chain if ms is None: ms = MultiSearch(words) results = [] for text in texts: results.extend(ms.iter_search(text, keep=True)) results.sort() return results
def multi_iter_search(words, text, ms=None): if ms is None: ms = MultiSearch(words) results = list(ms.iter_search(text)) results.sort() return results