I'm trying to use the solution code given in the following link: Unicode Tagging in Python NLTK
In the solution given by omerbp :
from nltk.corpus import indian
from nltk.tag import tnt
train_data = indian.tagged_sents('hindi.pos')
tnt_pos_tagger = tnt.TnT()
tnt_pos_tagger.train(train_data) #Training the tnt Part of speech tagger with hindi data
print tnt_pos_tagger.tag(nltk.word_tokenize(word_to_be_tagged))
I'm getting the following error:
'SyntaxError: Non-ASCII character '\\xe0' in file q12.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details' in line 1.
Add these two lines on the top of your file:
#!/usr/bin/python
# -*- coding: utf-8 -*-
They will instruct the interpreter to encode every charater as UTF-8 instead of ASCII.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.