我想导入wordnet字典但是当我导入字典表单时,wordnet我看到这个错误:
for l in open(WNSEARCHDIR+'/lexnames').readlines():
IOError: [Errno 2] No such file or directory: 'C:\\Program Files\\WordNet\\2.0\\dict/lexnames'
Run Code Online (Sandbox Code Playgroud)
我在这个目录中安装wordnet2.1但是我不能导入请帮我解决这个问题
import nltk
from nltk import *
from nltk.corpus import wordnet
from wordnet import Dictionary
print '-----------------------------------------'
print Dictionary.length
Run Code Online (Sandbox Code Playgroud) 在使用R中的NLP时,有没有办法在词干中获得基本词而不是词根?
码:
> #Loading libraries
> library(tm)
> library(slam)
>
> #Vector
> Vec=c("happyness happies happys","sky skies")
>
> #Creating Corpus
> Txt=Corpus(VectorSource(Vec))
>
> #Stemming
> Txt=tm_map(Txt, stemDocument)
>
> #Checking result
> inspect(Txt)
A corpus with 2 text documents
The metadata consists of 2 tag-value pairs and a data frame
Available tags are:
create_date creator
Available variables in the data frame are:
MetaID
[[1]]
happi happi happi
[[2]]
sky sky
>
Run Code Online (Sandbox Code Playgroud)
我可以使用R得到"happyness happies happys"的基本单词"happy"(基本单词)而不是"happi"(根单词)
我试图在R中做一些干预,但它似乎只适用于单个文档.我的最终目标是一个术语文档矩阵,显示文档中每个术语的频率.
这是一个例子:
require(RWeka)
require(tm)
require(Snowball)
worder1<- c("I am taking","these are the samples",
"He speaks differently","This is distilled","It was placed")
df1 <- data.frame(id=1:5, words=worder1)
> df1
id words
1 1 I am taking
2 2 these are the samples
3 3 He speaks differently
4 4 This is distilled
5 5 It was placed
Run Code Online (Sandbox Code Playgroud)
此方法适用于词干部分,但不适用于术语文档矩阵部分:
> corp1 <- Corpus(VectorSource(df1$words))
> inspect(corp1)
A corpus with 5 text documents
The metadata consists of 2 tag-value pairs and a data frame
Available tags are: …Run Code Online (Sandbox Code Playgroud) 我正在对TM包进行大量分析.我最大的问题之一是与词干和词干变换有关.
假设我有几个与会计相关的术语(我知道拼写问题).
在阻止后我们有:
accounts -> account
account -> account
accounting -> account
acounting -> acount
acount -> acount
acounts -> acount
accounnt -> accounnt
Run Code Online (Sandbox Code Playgroud)
结果:3个条款(帐户,帐户,帐户)我希望1(帐户),因为所有这些都与同一个词有关.
1)纠正拼写是一种可能性,但我从来没有在R中尝试过.这是否可能?
2)另一种选择是建立一个参考列表,即账户=(账户,账户,会计,会计,账户,账户,账户),然后将所有事件替换为主条款.我怎么会在R?
再一次,任何帮助/建议将不胜感激.
术语频率(TF)和反向文档频率(IDF)如何受到停用词删除和词干的影响?
谢谢!
我正在寻找阿拉伯语的Java词干分析器.我发现了一个名为"AraMorph"的lib,但它的输出是无法控制的,它会形成不需要的单词.
阿拉伯语还有其他的词干吗?
我正在搜索一个java库或其他东西,以阻止意大利语单词串.
目标是比较意大利语单词.在这一刻,像"attacco","attacchi","attaccare"等词被认为是不同的,而我想要回到真正的比较.
我找到了类似Lucene,snowball.tartarus.org等的东西.还有其他有用的东西,或者我如何在java中使用它们?
谢谢你的回答.
我有txt文件,如下所示:
word, 23
Words, 2
test, 1
tests, 4
Run Code Online (Sandbox Code Playgroud)
我希望它们看起来像这样:
word, 23
word, 2
test, 1
test, 4
Run Code Online (Sandbox Code Playgroud)
我希望能够在Python中获取一个txt文件并将多个单词转换为单数.这是我的代码:
import nltk
f = raw_input("Please enter a filename: ")
def openfile(f):
with open(f,'r') as a:
a = a.read()
a = a.lower()
return a
def stem(a):
p = nltk.PorterStemmer()
[p.stem(word) for word in a]
return a
def returnfile(f, a):
with open(f,'w') as d:
d = d.write(a)
#d.close()
print openfile(f)
print stem(openfile(f))
print returnfile(f, stem(openfile(f)))
Run Code Online (Sandbox Code Playgroud)
我也尝试过这两个定义而不是stem定义:
def singular(a):
for line in …Run Code Online (Sandbox Code Playgroud)