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

Method test_find_chunks

test/test_en.py:362–393  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

360 print "pattern.en.parser.find_tags()"
361
362 def test_find_chunks(self):
363 # Assert chunk tag annotation.
364 v = en.parser.find_chunks([["black", "JJ"], ["cat", "NN"]])
365 self.assertEqual(v, [["black", "JJ", "B-NP", "O"], ["cat", "NN", "I-NP", "O"]])
366 # Assert the accuracy of the chunker.
367 # For example, in "The very black cat must be really meowing really loud in the yard.":
368 # - "The very black" (NP)
369 # - "must be really meowing" (VP)
370 # - "really loud" (ADJP)
371 # - "in" (PP)
372 # - "the yard" (NP)
373 v = en.parser.find_chunks([
374 ["","DT"], ["","RB"], ["","JJ"], ["","NN"],
375 ["","MD"], ["","RB"], ["","VBZ"], ["","VBG"],
376 ["","RB"], ["","JJ"],
377 ["","IN"],
378 ["","CD"], ["","NNS"]
379 ])
380 self.assertEqual(v, [
381 ["", "DT", "B-NP", "O"], ["", "RB", "I-NP", "O"], ["", "JJ", "I-NP", "O"], ["", "NN", "I-NP", "O"],
382 ["", "MD", "B-VP", "O"], ["", "RB", "I-VP", "O"], ["", "VBZ", "I-VP", "O"], ["", "VBG", "I-VP", "O"],
383 ["", "RB", "B-ADJP", "O"], ["", "JJ", "I-ADJP", "O"],
384 ["", "IN", "B-PP", "B-PNP"],
385 ["", "CD", "B-NP", "I-PNP"], ["", "NNS", "I-NP", "I-PNP"]])
386 # Assert cases for which we have written special rules.
387 # - "perhaps you" (ADVP + NP)
388 v = en.parser.find_chunks([["","RB"], ["","PRP"]])
389 self.assertEqual(v, [["","RB","B-ADVP", "O"], ["","PRP","B-NP", "O"]])
390 # - "very nice cats" (NP)
391 v = en.parser.find_chunks([["","RB"], ["","JJ"], ["","PRP"]])
392 self.assertEqual(v, [["","RB","B-NP", "O"], ["","JJ","I-NP", "O"], ["","PRP","I-NP", "O"]])
393 print "pattern.en.parser.find_chunks()"
394
395 def test_find_labels(self):
396 # Assert relation tag annotation (SBJ/OBJ).

Callers

nothing calls this directly

Calls 1

find_chunksMethod · 0.45

Tested by

no test coverage detected