MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / vectorize_text

Function vectorize_text

experiments/baselines/nl_profile/runner.py:181–190  ·  view source on GitHub ↗
(text: Any, idf: Dict[str, float])

Source from the content-addressed store, hash-verified

179
180
181def vectorize_text(text: Any, idf: Dict[str, float]) -> Dict[str, float]:
182 counts = Counter(tokenize(text))
183 if not counts:
184 return {}
185 default_idf = math.log(max(2.0, len(idf) + 1.0))
186 vector = {
187 token: (1.0 + math.log(freq)) * idf.get(token, default_idf)
188 for token, freq in counts.items()
189 }
190 return normalize_vector(vector)
191
192
193def normalize_vector(vector: Dict[str, float]) -> Dict[str, float]:

Callers 2

make_stateFunction · 0.70
score_rowFunction · 0.70

Calls 3

getMethod · 0.80
tokenizeFunction · 0.70
normalize_vectorFunction · 0.70

Tested by

no test coverage detected