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

Method test_group

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

Source from the content-addressed store, hash-verified

475 print "pattern.search.Match"
476
477 def test_group(self):
478 # Assert Match groups.
479 s = Sentence(parse("the big black cat eats a tasty fish"))
480 m = search.search("DT {JJ+} NN", s)
481 self.assertEqual(m[0].group(1).string, "big black")
482 self.assertEqual(m[1].group(1).string, "tasty")
483 # Assert nested groups (and syntax with additional spaces).
484 m = search.search("DT { JJ { JJ { NN }}}", s)
485 self.assertEqual(m[0].group(1).string, "big black cat")
486 self.assertEqual(m[0].group(2).string, "black cat")
487 self.assertEqual(m[0].group(3).string, "cat")
488 # Assert chunked groups.
489 m = search.search("NP {VP NP}", s)
490 v = m[0].group(1, chunked=True)
491 self.assertEqual(v[0].string, "eats")
492 self.assertEqual(v[1].string, "a tasty fish")
493 print "pattern.search.Match.group()"
494
495 def test_group_ordering(self):
496 # Assert group parser ordering (opened-first).

Callers

nothing calls this directly

Calls 4

parseFunction · 0.90
SentenceClass · 0.50
searchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected