-
Notifications
You must be signed in to change notification settings - Fork 58
-
I have imported the nltk package and also added it in the tags.
I need the nltk.corpus and nltk.tokenize to be imported as well which can be only imported if there is nltk_data which I have installed centrally.
How do I add the nltk_data that is required in this section?
The part of code from my index.html
`
<py-script>
import nltk
from nltk.corpus import stopwords
stop_words = set(stopwords.words('english'))
tokenized = sent_tokenize(txt)
for i in tokenized:
wordsList = nltk.word_tokenize(i)
wordsList = [w for w in wordsList if not w in stop_words]
tagged = nltk.pos_tag(wordsList)
print("\nThe POS list : ")
print(tagged)
</py-script>
`
The error message that is displayed:
[pyexec] Python exception:
Traceback (most recent call last):
File "/lib/python3.10/site-packages/nltk/corpus/util.py", line 84, in __load
root = nltk.data.find(f"{self.subdir}/{zip_name}")
File "/lib/python3.10/site-packages/nltk/data.py", line 583, in find
raise LookupError(resource_not_found)
LookupError:
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
import nltk >>> nltk.download('stopwords')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/stopwords.zip/stopwords/
Searched in:
- '/home/pyodide/nltk_data'
- '/nltk_data'
- '/share/nltk_data'
- '/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/lib/python3.10/_pyodide/_base.py", line 460, in eval_code
.run(globals, locals)
File "/lib/python3.10/_pyodide/_base.py", line 306, in run
coroutine = eval(self.code, globals, locals)
File "", line 9, in
File "/lib/python3.10/site-packages/nltk/corpus/util.py", line 121, in getattr
self.__load()
File "/lib/python3.10/site-packages/nltk/corpus/util.py", line 86, in __load
raise e
File "/lib/python3.10/site-packages/nltk/corpus/util.py", line 81, in __load
root = nltk.data.find(f"{self.subdir}/{self.__name}")
File "/lib/python3.10/site-packages/nltk/data.py", line 583, in find
raise LookupError(resource_not_found)
LookupError:
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
import nltk >>> nltk.download('stopwords')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/stopwords
Searched in:
- '/home/pyodide/nltk_data'
- '/nltk_data'
- '/share/nltk_data'
- '/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
Beta Was this translation helpful? Give feedback.