【问题标题】:Any better pre processing library or implementation in python?python中有更好的预处理库或实现吗?
【发布时间】:2023-03-09 17:59:01
【问题描述】:

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

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

#--------------------------------------------------------------------------
#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. 词干不正确。词干过多(网络和网络到网络),有时名词也会被词干。

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

【问题讨论】:

    标签: python preprocessor nlp data-mining web-mining


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-08-01
      • 2019-01-20
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 2012-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多