NLTK corpus: List down all the corpus names
NLTK corpus: Exercise-1 with Solution
Write a Python NLTK program to list down all the corpus names.
Sample Solution:
Python Code :
import nltk.corpus
dir(nltk.corpus)
print("\nAvailable corpus names:")
print(dir(nltk.corpus))
Sample Output:
Available corpus names: ['_LazyModule__lazymodule_globals', '_LazyModule__lazymodule_import', '_LazyModule__lazymodule_init', '_LazyModule__lazymodule_loaded', '_LazyModule__lazymodule_locals', '_LazyModule__lazymodule_name', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: NLTK Corpus Exercises Home.
Next: Write a Python NLTK program to get a list of common stop words in various languages in Python.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/nltk/nltk-corpus-exercise-1.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics