MCPcopy Create free account
hub / github.com/debjitpaul/refiner / get_overlap

Function get_overlap

data_preprocessing/utils.py:108–112  ·  view source on GitHub ↗
(source: str, target: str, ignore_stopwords: bool = False, ignore_entities: bool = False)

Source from the content-addressed store, hash-verified

106 return set([token.lemma_.lower() for token in tokens])
107
108def get_overlap(source: str, target: str, ignore_stopwords: bool = False, ignore_entities: bool = False):
109 source_words = get_words(source, ignore_stopwords=ignore_stopwords, ignore_entities=ignore_entities)
110 target_words = get_words(target, ignore_stopwords=ignore_stopwords, ignore_entities=ignore_entities)
111 overlap = target_words.intersection(source_words)
112 return overlap, (len(overlap) / len(target_words)) if overlap else 0, (len(overlap) / len(source_words)) if overlap else 0
113
114def has_overlap(source: str, target: str, threshold: float, ignore_stopwords: bool = False, ignore_entities: bool = False):
115 _, overlap_level1, overlap_level2 = get_overlap(source, target, ignore_stopwords=ignore_stopwords, ignore_entities=ignore_entities)

Callers 1

has_overlapFunction · 0.85

Calls 1

get_wordsFunction · 0.85

Tested by

no test coverage detected