Spaces:
Sleeping
Sleeping
| # setup.py | |
| import nltk | |
| import ssl | |
| import os | |
| try: | |
| _create_unverified_https_context = ssl._create_unverified_context | |
| except AttributeError: | |
| pass | |
| else: | |
| ssl._create_default_https_context = _create_unverified_https_context | |
| # Set NLTK data path to a writable location | |
| nltk.data.path.append(os.path.expanduser("~/nltk_data")) | |
| def download_nltk_data(): | |
| resources = [ | |
| 'stopwords', | |
| 'punkt', | |
| 'averaged_perceptron_tagger', | |
| 'maxent_ne_chunker', | |
| 'words' | |
| ] | |
| for resource in resources: | |
| try: | |
| nltk.download(resource, download_dir=os.path.expanduser("~/nltk_data")) | |
| print(f"Successfully downloaded {resource}") | |
| except Exception as e: | |
| print(f"Error downloading {resource}: {str(e)}") | |
| if __name__ == "__main__": | |
| download_nltk_data() |