New_Coder New_Coder - 15 days ago 7
Python Question

How to print Hindi words in NLTK's Indian corpus?

Code:

from nltk.corpus import indian

nltk.corpus.indian.words('hindi.pos')


Output:

[u'\u092a\u0942\u0930\u094d\u0923', u'\u092a\u094d\u0930\u0924\u093f\u092c\u0902\u0927', ...]


But, I need output to be:
['पूर्ण', 'प्रतिबंध', 'हटाओ', ':', 'इराक', 'संयुक्त', ...]

Like shown in: http://www.nltk.org/book/ch02.html

Could you please tell how can I print the actual words instead of unicode.
Any help is appreciated.

cat cat
Answer

Python 2 doesn't have VM-wide Unicode support. The prettyprinter isn't the same as printing one of the strings in the array -- but printing just one will work as expected.