MCPcopy Create free account
hub / github.com/clips/pattern / nearest_neighbors

Method nearest_neighbors

pattern/graph/commonsense.py:183–186  ·  view source on GitHub ↗

Returns the k most similar concepts from the given list.

(self, concept, concepts=[], k=3)

Source from the content-addressed store, hash-verified

181 return w / k
182
183 def nearest_neighbors(self, concept, concepts=[], k=3):
184 """ Returns the k most similar concepts from the given list.
185 """
186 return sorted(concepts, key=lambda candidate: self.similarity(concept, candidate, k), reverse=True)
187
188 similar = neighbors = nn = nearest_neighbors
189

Callers

nothing calls this directly

Calls 1

similarityMethod · 0.95

Tested by

no test coverage detected