python - python中有更好的预处理库或实现吗?

标签 python preprocessor nlp data-mining web-mining

我需要预处理一些文本文档,以便我可以应用 fcm 等分类技术和其他主题建模技术(例如潜在狄利克雷分配等)

为了详细说明预处理,我需要删除停用词、提取名词和关键字并执行词干提取。我用于此目的的代码是:

#--------------------------------------------------------------------------
#Extracting nouns
#--------------------------------------------------------------------------
for i in range (0,len(a)) :
    x=a[i]          
    text=nltk.pos_tag(nltk.Text(nltk.word_tokenize(x)))
    for noun in text:
        if(noun[1]=="NN" or noun[1]=="NNS"):
            temp+=noun[0]
            temp+=' '
documents.append(temp)
print documents

#--------------------------------------------------------------------------
#remove unnecessary words and tags
#--------------------------------------------------------------------------

texts = [[word for word in document.lower().split() if word not in stoplist]for    document in documents]
allTokens = sum(texts, [])
tokensOnce = set(word for word in set(allTokens) if allTokens.count(word)== 0)
texts = [[word for word in text if word not in tokensOnce]for text in texts]
print texts

#--------------------------------------------------------------------------
#Stemming
#--------------------------------------------------------------------------

for i in texts:
    for j in range (0,len(i)):        
        k=porter.stem(i[j])
        i[j]=k
print texts

我上面提到的代码的问题是

  1. 用于提取名词和关键字的 nltk 模块缺少许多单词。 例如,对某些文档进行了预处理,“Sachin”等名称在预处理后未被识别为关键字并被遗漏。
  2. 这些词的词干不正确。要么词干太多(网络和网络到网络),有时名词也被词干化。

对于所需的功能是否有更好的模块或者同一模块有更好的实现吗? 请帮忙

最佳答案

尝试一下 Pattern,我真的很喜欢它:http://www.clips.ua.ac.be/pages/pattern

关于python - python中有更好的预处理库或实现吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10281215/

相关文章:

java - 针对不同版本的 Java 代码或预处理进行细微更改?

java - 使用 Apache Solr 的半自然语言搜索

nlp - 当使用fast_align等单词对齐工具时,句子越多是否意味着准确性越高?

python - 将多个值的元组列表转换为 Python 中的字典

python - 根据在特定列中找到的值删除行

c - 带有 "%"符号的表达式的 gcc 字符串化

c - 在预处理器指令中使用枚举值

language-agnostic - POS标记等中的缩写是什么意思?

python - 如何格式化 CSV 中的字典列表? - Python

python - MongoDB:更新文档中数组中的字典