Most dishes, most recently for the first time to understand NLTK, and would like to learn the code below
nltk.tokenize import sent_tokenize
mytext = "Hello Mr. Adam, how are you? I hope everything is going well. Today is a good day, see you dude."
sent_tokenize(mytext)
出现报错,
Resource punkt not found.
Please use the NLTK Downloader to obtain the resource:
import nltk
nltk.download('punkt')
But in fact it exists
Look closely,
mistakes Search C under the C drive: \ Users \ Hu / nltk_data
Searched in:
- 'C:\Users\Hu/nltk_data'
- 'D:\ProgramData\Miniconda3\envs\tensorflow\nltk_data'
- 'D:\ProgramData\Miniconda3\envs\tensorflow\share\nltk_data'
- 'D:\ProgramData\Miniconda3\envs\tensorflow\lib\nltk_data'
- 'C:\Users\Hu\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
- ''
View Source can be seen
tokenizer=load('tokenizers/punkt/{0}.pickle'.format(language))
Looking at data from a load nltk
def load(
resource_url,
format='auto',
cache=True,
verbose=False,
logic_parser=None,
fstruct_reader=None,
encoding=None,
From here, my first reaction was resource_url, it was quickly discovered later found
resource_url = normalize_resource_url(resource_url)
resource_url = add_py3_data(resource_url)
First saw masked caption windows = sys.platform.startswith ( 'win')
So I found earlier
path += [
os.path.join(sys.prefix, str('nltk_data')),
os.path.join(sys.prefix, str('share'), str('nltk_data')),
os.path.join(sys.prefix, str('lib'), str('nltk_data')),
os.path.join(os.environ.get(str('APPDATA'), str('C:\')), str('nltk_data')),
str(r'C:\nltk_data'),
str(r'D:\nltk_data'),
str(r'E:\nltk_data'),
So I changed = nltk.data.path [ 'D: \ the Users / Hu / AppData / Roaming / nltk_data']
the OK to run successfully
['Hello Mr. Adam, how are you?', 'I hope everything is going well.', 'Today is a good day, see you dude.']
Process finished with exit code 0