I am using pyenchant in python for spell checking. My code is working properly for English but now I want to make it universal for other languages also. For this, First I need to confirm that a particular word belongs the selected language or not. For example, tree
could be english word or not, i.e., all the characters in this word belongs to english
so it could be a valid english word. I can use python's isalpha
function to check its belongingness with english.
isalpha
will return false for tree's
because '
is not an english character.
In this case, I will split the word from any character which is not in the english dictionary. For this, I am using below code:
import enchant
d = enchant.request_dict("en_US")
word = "tree's"
for a in word:
print a
I will again use isalpha
function for each character and split if function returns false.
Unfortunately, I didn't get any function similar to isalpha
for other languages. Secondly, if I am using above code for other language then it is printing odd values in the output. For example, if I want to run it for hindi
language,
# coding: utf-8
import enchant
d = enchant.request_dict("hi_IN")
word = "अभिमन्यु"
for a in word:
print a
Output of this code is printing ?
in each line.
I have two questions to ask,
1) What is the right way to read characters of languages other than english ?
2) Is there any alternate function of isalpha
for languages other than english ?