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

Method test_search

test/test_search.py:374–392  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

372 print "pattern.search.Pattern.match()"
373
374 def test_search(self):
375 # Assert one match containing all words.
376 v = search.Pattern.fromstring("*+")
377 v = v.search("one two three")
378 self.assertEqual(v[0].string, "one two three")
379 # Assert one match for each word.
380 v = search.Pattern.fromstring("*")
381 v = v.search("one two three")
382 self.assertEqual(v[0].string, "one")
383 self.assertEqual(v[1].string, "two")
384 self.assertEqual(v[2].string, "three")
385 # Assert all variations are matched (sentence starts with a NN* which must be caught).
386 v = search.Pattern.fromstring("(DT) JJ?+ NN*")
387 v = v.search(Sentence(parse("dogs, black cats and a big white rabbit")))
388 self.assertEqual(v[0].string, "dogs")
389 self.assertEqual(v[1].string, "black cats")
390 self.assertEqual(v[2].string, "a big white rabbit")
391 v = search.Pattern.fromstring("NN*")
392 print "pattern.search.Pattern.search()"
393
394 def test_convergence(self):
395 # Test with random sentences and random patterns to see if it crashes.

Callers

nothing calls this directly

Calls 4

parseFunction · 0.90
SentenceClass · 0.50
fromstringMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected