Exemplo n.º 1
0
 def test_categories(self):
     self.assertEqual(
         ptb.categories(),
         [
             'adventure',
             'belles_lettres',
             'fiction',
             'humor',
             'lore',
             'mystery',
             'news',
             'romance',
             'science_fiction',
         ],
     )
Exemplo n.º 2
0
 def test_categories(self):
     self.assertEqual(
         ptb.categories(),
         [
             "adventure",
             "belles_lettres",
             "fiction",
             "humor",
             "lore",
             "mystery",
             "news",
             "romance",
             "science_fiction",
         ],
     )
Exemplo n.º 3
0
 def test_categories(self):
     self.assertEqual(
         ptb.categories(),
         [
             "adventure",
             "belles_lettres",
             "fiction",
             "humor",
             "lore",
             "mystery",
             "news",
             "romance",
             "science_fiction",
         ],
     )
Exemplo n.º 4
0
def verify_ptb_install():
    # Download PTB metadata
    assert (nltk.download('ptb'))

    import hashlib
    from nltk.corpus import ptb
    # Be sure we have the category list
    assert ('news' in ptb.categories())

    m = hashlib.md5()  # NOT SECURE!
    m.update(','.join(ptb.fileids()).encode('utf8'))
    if m.hexdigest() == 'e3b49c6df5529560b2945e6a4715f9b0':
        print('Penn Treebank succesfully installed!')
        return True
    else:
        print('Error installing Penn Treebank (hash mismatch).')
        print('It may still work - try loading it in NLTK.')
        return False
Exemplo n.º 5
0
def verify_ptb_install():
    # Download PTB metadata
    assert(nltk.download('ptb'))

    import hashlib
    from nltk.corpus import ptb
    # Be sure we have the category list
    assert('news' in ptb.categories())

    m = hashlib.md5()  # NOT SECURE!
    m.update(','.join(ptb.fileids()).encode('utf8'))
    if m.hexdigest() == 'e3b49c6df5529560b2945e6a4715f9b0':
        print('Penn Treebank succesfully installed!')
        return True
    else:
        print('Error installing Penn Treebank (hash mismatch).')
        print('It may still work - try loading it in NLTK.')
        return False
 def test_categories(self):
     self.assertEqual(
         ptb.categories(),
         ['adventure', 'belles_lettres', 'fiction', 'humor', 'lore', 'mystery', 'news', 'romance', 'science_fiction']
     )