from nltk.tokenize import sent_tokenize, word_tokenize
example_txt= "Hello, My name is Akash. The weather is good and python is Awesome."
print(sent_tokenize(example_txt))
print("=====================================")
print(word_tokenize(example_txt))
print("=====================================")
for i in word_tokenize(example_txt):
print(i)
错误: 当我试图运行该程序时,它给我一个错误,我应该怎么做?
Traceback (most recent call last):
File "A:/Sem 2/Testing_project/NLP_NLTK_Sentdex/tokenize.py", line 1, in <module>
from nltk.tokenize import sent_tokenize, word_tokenize
File "C:\Users\Akash\Anaconda3\lib\site-packages\nltk\__init__.py", line 89, in <module>
from nltk.internals import config_java
File "C:\Users\Akash\Anaconda3\lib\site-packages\nltk\internals.py", line 11, in <module>
import subprocess
File "C:\Users\Akash\Anaconda3\lib\subprocess.py", line 126, in <module>
import threading
File "C:\Users\Akash\Anaconda3\lib\threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "C:\Users\Akash\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\Akash\Anaconda3\lib\linecache.py", line 11, in <module>
import tokenize
File "A:\Sem 2\Testing_project\NLP_NLTK_Sentdex\tokenize.py", line 1, in <module>
from nltk.tokenize import sent_tokenize, word_tokenize
File "C:\Users\Akash\Anaconda3\lib\site-packages\nltk\tokenize\__init__.py", line 64, in <module>
from nltk.tokenize.mwe import MWETokenizer
File "C:\Users\Akash\Anaconda3\lib\site-packages\nltk\tokenize\mwe.py", line 31, in <module>
from nltk.util import Trie
File "C:\Users\Akash\Anaconda3\lib\site-packages\nltk\util.py", line 13, in <module>
import pydoc
File "C:\Users\Akash\Anaconda3\lib\pydoc.py", line 72, in <module>
from traceback import format_exception_only
ImportError: cannot import name 'format_exception_only'