def instance(review): # "Great book!" # [("Great", "JJ"), ("book", "NN"), ("!", "!")] v = tag(review) v = [word for (word, pos) in v if pos in ("JJ", "RB") or word in ("!")] v = [predicative(word) for word in v] # ["great", "!", "!"] v = count(v) # {"great": 1, "!": 1} return v
def test_tag(self): # Assert [("zwarte", "JJ"), ("panters", "NNS")]. v = nl.tag("zwarte panters") self.assertEqual(v, [("zwarte", "JJ"), ("panters", "NNS")]) print("pattern.nl.tag()")