MCPcopy Index your code
hub / github.com/clips/pattern / dfs

Method dfs

pattern/text/search.py:320–330  ·  view source on GitHub ↗
(term, recursive=False, visited={}, **kwargs)

Source from the content-addressed store, hash-verified

318 If recursive=True, traverses parents up to the root.
319 """
320 def dfs(term, recursive=False, visited={}, **kwargs):
321 if term in visited: # Break on cyclic relations.
322 return []
323 visited[term], a = True, []
324 if dict.__contains__(self, term):
325 a = self[term][0].keys()
326 for classifier in self.classifiers:
327 a.extend(classifier.parents(term, **kwargs) or [])
328 if recursive:
329 for w in a: a += dfs(w, recursive, visited, **kwargs)
330 return a
331 return unique(dfs(self._normalize(term), recursive, {}, **kwargs))
332
333 def children(self, term, recursive=False, **kwargs):

Callers

nothing calls this directly

Calls 5

parentsMethod · 0.80
__contains__Method · 0.45
keysMethod · 0.45
extendMethod · 0.45
childrenMethod · 0.45

Tested by

no test coverage detected