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

Method __init__

pattern/text/search.py:909–922  ·  view source on GitHub ↗

Search result returned from Pattern.match(sentence), containing a sequence of Word objects.

(self, pattern, words=[], map={})

Source from the content-addressed store, hash-verified

907class Match(object):
908
909 def __init__(self, pattern, words=[], map={}):
910 """ Search result returned from Pattern.match(sentence),
911 containing a sequence of Word objects.
912 """
913 self.pattern = pattern
914 self.words = words
915 self._map1 = dict() # Word index to Constraint.
916 self._map2 = dict() # Constraint index to list of Word indices.
917 for w in self.words:
918 self._map1[w.index] = map[w.index]
919 for k,v in self._map1.items():
920 self._map2.setdefault(self.pattern.sequence.index(v),[]).append(k)
921 for k,v in self._map2.items():
922 v.sort()
923
924 def __len__(self):
925 return len(self.words)

Callers

nothing calls this directly

Calls 5

itemsMethod · 0.45
appendMethod · 0.45
setdefaultMethod · 0.45
indexMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected