我可以在PyEnchant中从字典中排除单词吗?

时间:2014-07-17 18:17:59

标签: python pyenchant

使用PyEnchant时,是否可以从字典中排除某些单词?例如,我想检查单词是英语(在我的情况下是'en_EN')还是法语('fr_FR')。但是,当我检查两个词典的字符串"de时,都返回true。

1 个答案:

答案 0 :(得分:0)

您可以尝试在传递给Pyenchant之前删除停用词

from nltk.corpus import stopwords

    def remove_stop_words(self, tokenized_docs_no_punctuation):
        """

        :param tokenized_docs_no_punctuation:
        :return:
        """
        # print 'CleanupText.remove_stop_words()'
        tokenized_docs_no_stopwords = []
        for token in tokenized_docs_no_punctuation:
            if not token in stopwords.words('english'):
                tokenized_docs_no_stopwords.append(token)

        return tokenized_docs_no_stopwords

然后这些代币将它们传递给Pyenchant