【题目和解决】NLTK was unable to find the megam file!(1)
添加时间:2013-5-15 点击量:
在学到“练习基于分类器的分块器”这一末节的时辰,在测试代码之后碰到了题目。
class ConsecutiveNPChunkTagger(nltk.TaggerI):
def __init__(self, train_sents):
train_set = []
for tagged_sent in train_sents:
untagged_sent = nltk.tag.untag(tagged_sent)
history = []
for i, (word, tag) in enumerate(tagged_sent):
featureset = npchunk_features(untagged_sent, i, history)
train_set.append( (featureset, tag) )
history.append(tag)
self.classifier = nltk.MaxentClassifier.train(train_set, algorithm=megam, trace=0)
def tag(self, sentence):
history = []
for i, word in enumerate(sentence):
featureset = npchunk_features(sentence,i, history)
tag = self.classifier.classify(featureset)
history.append(tag)
return zip(sentence, history)
class ConsecutiveNPChunker(nltk.ChunkParserI):
def __init__(self, train_sents):
tagged_sents = [[((w,t),c) for (w,t,c) in
nltk.chunk.tree2conlltags(sent)]for sent in train_sents]
self.tagger = ConsecutiveNPChunkTagger(tagged_sents)
def parse(self, sentence):
tagged_sents = self.tagger.tag(sentence)
conlltags =[(w,t,c) for ((w,t),c) in tagged_sents]
return nltk.chunk.conlltags2tree(conlltags)
def npchunk_features(sentence,i, history):
... word,pos= sentence[i]
... return {pos: pos}
>>>chunker = ConsecutiveNPChunker(train_sents)
>>>print chunker.evaluate(test_sents)
以上是书上供给的代码,题目是,当在履行
chunker = ConsecutiveNPChunker(train_sents)并没有如期履行,反而呈现了一个错误。
Traceback (most recent call last):
File <pyshell#119>, line 1, in <module>
chunker = ConsecutiveNPChunker(train_sents)
File <pyshell#118>, line 5, in __init__
self.tagger = ConsecutiveNPChunkTagger(tagged_sents)
File <pyshell#116>, line 11, in __init__
self.classifier = nltk.MaxentClassifier.train(train_set, algorithm=megam, trace=0)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\maxent.py, line 319, in train
gaussian_prior_sigma, cutoffs)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\maxent.py, line 1522, in train_maxent_classifier_with_megam
stdout = call_megam(options)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\megam.py, line 163, in call_megam
config_megam()
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\megam.py, line 59, in config_megam
url=http://www.cs.utah.edu/~hal/megam/)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\internals.py, line 528, in find_binary
url, verbose)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\internals.py, line 512, in find_file
raise LookupError(\n\n%s\n%s\n%s % (div, msg, div))
LookupError:
===========================================================================
NLTK was unable to find the megam file!
Use software specific configuration paramaters or set the MEGAM environment variable.
For more information, on megam, see:
<http://www.cs.utah.edu/~hal/megam/>
===========================================================================
固然说给出了响应的提示,然则并不完全。
经由过程对谷歌的搜刮,找到了一些解决的端倪。
我的操纵体系是Windows8.
nltk说话对象的官网给出了提示:
https://sites.google.com/site/naturallanguagetoolkit/download
Megam为可选包,将来应用的时辰可以再来安装。的网址为:MegaM: http://hal3.name/megam/megam_src.tgz,直接我并没有成功,应用迅雷成功的。
然则打开之后发明,都是些源文件。然则在这个紧缩包里面有一个README文件,给出了如何应用的提示,发明,还须要装一个器材。
README中如许写到:ocaml(http://caml.inria.fr)
须要到这个网站源文件的编译器,于是我了和本身电脑体系相匹配的版本,然则看申明安装起来还是须要揣摩的,在安装过程中提示是病毒,然则我还是选择信赖,要不然没办法持续。
【如今Ocaml正在安装,我点的完全安装(可能实际傍边没有须要完全安装吧),等安装完成后,再持续摸索怎么解决这个题目】
我所有的自负皆来自我的自卑,所有的英雄气概都来自于我的软弱。嘴里振振有词是因为心里满是怀疑,深情是因为痛恨自己无情。这世界没有一件事情是虚空而生的,站在光里,背后就会有阴影,这深夜里一片寂静,是因为你还没有听见声音。—— 马良《坦白书》
在学到“练习基于分类器的分块器”这一末节的时辰,在测试代码之后碰到了题目。
class ConsecutiveNPChunkTagger(nltk.TaggerI):
def __init__(self, train_sents):
train_set = []
for tagged_sent in train_sents:
untagged_sent = nltk.tag.untag(tagged_sent)
history = []
for i, (word, tag) in enumerate(tagged_sent):
featureset = npchunk_features(untagged_sent, i, history)
train_set.append( (featureset, tag) )
history.append(tag)
self.classifier = nltk.MaxentClassifier.train(train_set, algorithm=megam, trace=0)
def tag(self, sentence):
history = []
for i, word in enumerate(sentence):
featureset = npchunk_features(sentence,i, history)
tag = self.classifier.classify(featureset)
history.append(tag)
return zip(sentence, history)
class ConsecutiveNPChunker(nltk.ChunkParserI):
def __init__(self, train_sents):
tagged_sents = [[((w,t),c) for (w,t,c) in
nltk.chunk.tree2conlltags(sent)]for sent in train_sents]
self.tagger = ConsecutiveNPChunkTagger(tagged_sents)
def parse(self, sentence):
tagged_sents = self.tagger.tag(sentence)
conlltags =[(w,t,c) for ((w,t),c) in tagged_sents]
return nltk.chunk.conlltags2tree(conlltags)
def npchunk_features(sentence,i, history):
... word,pos= sentence[i]
... return {pos: pos}
>>>chunker = ConsecutiveNPChunker(train_sents)
>>>print chunker.evaluate(test_sents)
以上是书上供给的代码,题目是,当在履行
chunker = ConsecutiveNPChunker(train_sents)并没有如期履行,反而呈现了一个错误。
Traceback (most recent call last):
File <pyshell#119>, line 1, in <module>
chunker = ConsecutiveNPChunker(train_sents)
File <pyshell#118>, line 5, in __init__
self.tagger = ConsecutiveNPChunkTagger(tagged_sents)
File <pyshell#116>, line 11, in __init__
self.classifier = nltk.MaxentClassifier.train(train_set, algorithm=megam, trace=0)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\maxent.py, line 319, in train
gaussian_prior_sigma, cutoffs)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\maxent.py, line 1522, in train_maxent_classifier_with_megam
stdout = call_megam(options)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\megam.py, line 163, in call_megam
config_megam()
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\classify\megam.py, line 59, in config_megam
url=http://www.cs.utah.edu/~hal/megam/)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\internals.py, line 528, in find_binary
url, verbose)
File D:\SpecialSoftware\Python25\Lib\site-packages\nltk\internals.py, line 512, in find_file
raise LookupError(\n\n%s\n%s\n%s % (div, msg, div))
LookupError:
===========================================================================
NLTK was unable to find the megam file!
Use software specific configuration paramaters or set the MEGAM environment variable.
For more information, on megam, see:
<http://www.cs.utah.edu/~hal/megam/>
===========================================================================
固然说给出了响应的提示,然则并不完全。
经由过程对谷歌的搜刮,找到了一些解决的端倪。
我的操纵体系是Windows8.
nltk说话对象的官网给出了提示:
https://sites.google.com/site/naturallanguagetoolkit/download
Megam为可选包,将来应用的时辰可以再来安装。的网址为:MegaM: http://hal3.name/megam/megam_src.tgz,直接我并没有成功,应用迅雷成功的。
然则打开之后发明,都是些源文件。然则在这个紧缩包里面有一个README文件,给出了如何应用的提示,发明,还须要装一个器材。
README中如许写到:ocaml(http://caml.inria.fr)
须要到这个网站源文件的编译器,于是我了和本身电脑体系相匹配的版本,然则看申明安装起来还是须要揣摩的,在安装过程中提示是病毒,然则我还是选择信赖,要不然没办法持续。
【如今Ocaml正在安装,我点的完全安装(可能实际傍边没有须要完全安装吧),等安装完成后,再持续摸索怎么解决这个题目】
我所有的自负皆来自我的自卑,所有的英雄气概都来自于我的软弱。嘴里振振有词是因为心里满是怀疑,深情是因为痛恨自己无情。这世界没有一件事情是虚空而生的,站在光里,背后就会有阴影,这深夜里一片寂静,是因为你还没有听见声音。—— 马良《坦白书》