使用SharpNL和OpenNLP的en-parser-chunking.bin,我尝试将一个句子解析成一棵树。SharpNL的一个测试表明,给定一个模型,您可以解析一个句子如下:
var model = SharpNL.Parser.TreeInsert.Parser.Train("en", parseSamples, headRules, 100, 0);
var parser = ParserFactory.Create(model);
// Tests parsing to make sure the code does not has
// a bug which fails always with a runtime exception
var p = parser.Parse(Parse.ParseParse("She was just another freighter from the " +
"States and she seemed as commonplace as her name ."));因此,我下载了en解析器-chunking.bin文件,从它以及解析器创建了一个模型,并试图解析相同的输入:
var parserModelStream = new FileStream(@"en-parser-chunking.bin", FileMode.Open, FileAccess.Read);
var parserModel = new ParserModel(parserModelStream);
var parser = ParserFactory.Create(parserModel);
var p = parser.Parse(Parse.ParseParse("She was just another freighter from the " +
"States and she seemed as commonplace as her name ."));这段代码会运行,但是当我在调试器中分析p时,它有一个顶部,没有子代码。这是我所使用的型号的问题吗?或者我是怎么用它的?
发布于 2016-06-10 04:34:57
而不是这样:
var p = parser.Parse(Parse.ParseParse("..."));我只需要使用这个:
var p = ParserTool.ParseLine("...", parser, 1);https://stackoverflow.com/questions/37672070
复制相似问题