For each word in WordNet that is not in Brill's lexicon, test if the given tagger((word, "NN")) yields an improved (word, tag). Returns the relative scores for nouns, verbs, adjectives and adverbs.
(self, function=en.lexicon.morphology.apply)
| 289 | print "pattern.en.tokenize()" |
| 290 | |
| 291 | def _test_morphological_rules(self, function=en.lexicon.morphology.apply): |
| 292 | """ For each word in WordNet that is not in Brill's lexicon, |
| 293 | test if the given tagger((word, "NN")) yields an improved (word, tag). |
| 294 | Returns the relative scores for nouns, verbs, adjectives and adverbs. |
| 295 | """ |
| 296 | scores = [] |
| 297 | for tag, lexicon in ( |
| 298 | ("NN", en.wordnet.NOUNS), |
| 299 | ("VB", en.wordnet.VERBS), |
| 300 | ("JJ", en.wordnet.ADJECTIVES), |
| 301 | ("RB", en.wordnet.ADVERBS)): |
| 302 | i, n = 0, 0 |
| 303 | for word in lexicon: |
| 304 | word = word.form |
| 305 | if word not in en.lexicon: |
| 306 | if function([word, "NN"])[1].startswith(tag): |
| 307 | i += 1 |
| 308 | n += 1 |
| 309 | scores.append(float(i) / n) |
| 310 | return scores |
| 311 | |
| 312 | def test_default_suffix_rules(self): |
| 313 | # Assert part-of-speech tag for unknown tokens. |
no test coverage detected