Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use top 5 in extractor
  • Loading branch information
Yiorgis Gozadinos committed Jul 9, 2010
1 parent ad11d7f commit 2051fc9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/collective/classification/tests/test_extractor.py
Expand Up @@ -21,21 +21,21 @@ def test_extractor(self):
extractor = getUtility(ITermExtractor)
(simple_terms, np_terms) = extractor.extract(text, locale="en")

top_10_nouns = sorted(
top_5_nouns = sorted(
simple_terms.items(),
key = itemgetter(1),
reverse=True)[:10]
top_10_nouns = [term for (term, rank) in top_10_nouns]
reverse=True)[:5]
top_5_nouns = [term for (term, rank) in top_5_nouns]
for word in ['alice', 'rabbit', 'hatter', 'door', 'cat']:
self.failUnless(word in top_10_nouns)
self.failUnless(word in top_5_nouns)

top_10_nps = sorted(
top_5_nps = sorted(
np_terms.items(),
key = itemgetter(1),
reverse=True)[:10]
top_10_nps = [term for (term, rank) in top_10_nps]
reverse=True)[:5]
top_5_nps = [term for (term, rank) in top_5_nps]
for np in ['white rabbit', 'mock turtle', 'mad hatter', 'march hare']:
self.failUnless(np in top_10_nps)
self.failUnless(np in top_5_nps)


def test_suite():
Expand Down

0 comments on commit 2051fc9

Please sign in to comment.