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

Method search

pattern/text/search.py:742–754  ·  view source on GitHub ↗

Returns a list of all matches found in the given sentence.

(self, sentence)

Source from the content-addressed store, hash-verified

740 return P
741
742 def search(self, sentence):
743 """ Returns a list of all matches found in the given sentence.
744 """
745 if sentence.__class__.__name__ == "Text":
746 a=[]; [a.extend(self.search(s)) for s in sentence]; return a
747 a = []
748 v = self._variations()
749 u = {}
750 m = self.match(sentence, _v=v)
751 while m:
752 a.append(m)
753 m = self.match(sentence, start=m.words[-1].index+1, _v=v, _u=u)
754 return a
755
756 def match(self, sentence, start=0, _v=None, _u=None):
757 """ Returns the first match found in the given sentence, or None.

Callers 7

test_matchMethod · 0.95
_matchFunction · 0.45
searchFunction · 0.45
indefinite_articleFunction · 0.45
pluralizeFunction · 0.45
singularizeFunction · 0.45
find_lemmaMethod · 0.45

Calls 4

_variationsMethod · 0.95
matchMethod · 0.95
extendMethod · 0.45
appendMethod · 0.45

Tested by 1

test_matchMethod · 0.76