处理多语言数据时,需要遵循哪些数据准备步骤或技术?

时间:2019-04-12 18:43:38

标签: nlp word-embedding

我正在开发多语言单词嵌入代码,需要在英语上训练我的数据并在西班牙语上对其进行测试。我将使用Facebook的MUSE库进行单词嵌入。 我正在寻找一种以相同方式预处理我的两个数据的方法。我研究了变音符号的修复以应对这种口音。

我在想出一种方法时遇到了麻烦,我可以小心地删除停用词,标点符号和天气,否则我不应该加以形容。

如何统一预处理这两种语言以创建词汇表,以后可以与MUSE库一起使用。

1 个答案:

答案 0 :(得分:1)

您好Chandana,我希望您一切都好。我会考虑使用spaCy https://spacy.io/api/doc库来创建该库的人有一个youtube视频,他在其中讨论了其他语言的NLP实现。在下面,您将找到将停用词去除词缀的代码。至于标点符号,您始终可以设置要忽略的特定字符(例如重音符号)。我个人使用KNIME(这是免费的开放源代码)进行预处理。您将必须安装nlp扩展,但是它们对不同的语言具有不同的扩展名,您可以在此处安装:https://www.knime.com/knime-text-processing停用词过滤器(自2.9版开始)和Snowball stemmer节点可以用于西班牙语。确保在节点的对话框中选择正确的语言。不幸的是,到目前为止,西班牙语还没有语音标记节点。

# Create functions to lemmatize stem, and preprocess

# turn beautiful, beautifuly, beautified into stem beauti 
def lemmatize_stemming(text):
    stemmer = PorterStemmer()
    return stemmer.stem(WordNetLemmatizer().lemmatize(text, pos='v'))

# parse docs into individual words ignoring words that are less than 3 letters long
# and stopwords: him, her, them, for, there, ect since "their" is not a topic.
# then append the tolkens into a list
def preprocess(text):
    result = []
    for token in gensim.utils.simple_preprocess(text):
        newStopWords = ['your_stopword1', 'your_stop_word2']
        if token not in gensim.parsing.preprocessing.STOPWORDS and token not in newStopWords and len(token) > 3:
            nltk.bigrams(token)
            result.append(lemmatize_stemming(token))
    return result

希望您有任何问题时,我可以帮助我告诉我:)