nltk--nltk
3454a55636
cffconvert / validate (push) Has been cancelled
ci-workflow / pre-commit (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (macos-latest) (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (ubuntu-latest) (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (windows-latest) (push) Has been cancelled
ci-workflow / Python 3.10 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.11 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.12 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.13 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.14 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.14t on macos-latest (push) Has been cancelled
ci-workflow / Python 3.10 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.11 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.12 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.13 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.14 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.14t on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.10 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.11 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.12 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.13 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.14 on windows-latest (push) Has been cancelled
28 行
733 B
Python
28 行
733 B
Python
"""
|
|
Unit tests for nltk.corpus.nombank
|
|
"""
|
|
|
|
import unittest
|
|
|
|
from nltk.corpus import nombank
|
|
|
|
# Load the nombank once.
|
|
nombank.nouns()
|
|
|
|
|
|
class NombankDemo(unittest.TestCase):
|
|
def test_numbers(self):
|
|
# No. of instances.
|
|
self.assertEqual(len(nombank.instances()), 114574)
|
|
# No. of rolesets
|
|
self.assertEqual(len(nombank.rolesets()), 5577)
|
|
# No. of nouns.
|
|
self.assertEqual(len(nombank.nouns()), 4704)
|
|
|
|
def test_instance(self):
|
|
self.assertEqual(nombank.instances()[0].roleset, "perc-sign.01")
|
|
|
|
def test_framefiles_fileids(self):
|
|
self.assertEqual(len(nombank.fileids()), 4705)
|
|
self.assertTrue(all(fileid.endswith(".xml") for fileid in nombank.fileids()))
|