public void TestTreeInsertParserTraining() { var parseSamples = ParserTestUtil.CreateParseTrainStream(); var headRules = ParserTestUtil.CreateTestHeadRules(); 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 .")); ParserModel deserialized; using (var data = new MemoryStream()) { model.Serialize(new UnclosableStream(data)); data.Seek(0, SeekOrigin.Begin); deserialized = new ParserModel(data); } Assert.NotNull(deserialized); // TODO: compare both models }
public void TestChunkingParserTraining() { var parseSamples = ParserTestUtil.CreateParseTestStream(); //var testSamples = ParserTestUtil.CreateParseTestStream(); var headRules = ParserTestUtil.CreateTestHeadRules(); var model = SharpNL.Parser.Chunking.Parser.Train("en", parseSamples, headRules, 100, 0); Assert.NotNull(model); var parser = ParserFactory.Create(model); Assert.NotNull(parser); ParserModel deserialized; using (var stream = new MemoryStream()) { model.Serialize(new UnclosableStream(stream)); stream.Seek(0, SeekOrigin.Begin); deserialized = new ParserModel(stream); } Assert.NotNull(deserialized); // TODO: compare both models }
public static IParser Create(ParserModel model) { if (model == null) { throw new ArgumentNullException("model"); } return(Create(model, AbstractBottomUpParser.DefaultBeamSize, AbstractBottomUpParser.DefaultAdvancePercentage)); }
public static IParser Create(ParserModel model, int beamSize, double advancePercentage) { if (model == null) throw new ArgumentNullException("model"); switch (model.ParserType) { case ParserType.Chunking: return new Chunking.Parser(model, beamSize, advancePercentage); case ParserType.TreeInsert: return new TreeInsert.Parser(model, beamSize, advancePercentage); default: throw new InvalidOperationException("Unexpected model parser."); } }
public static IParser Create(ParserModel model, int beamSize, double advancePercentage) { if (model == null) { throw new ArgumentNullException("model"); } switch (model.ParserType) { case ParserType.Chunking: return(new Chunking.Parser(model, beamSize, advancePercentage)); case ParserType.TreeInsert: return(new TreeInsert.Parser(model, beamSize, advancePercentage)); default: throw new InvalidOperationException("Unexpected model parser."); } }
public static IParser Create(ParserModel model) { if (model == null) throw new ArgumentNullException("model"); return Create(model, AbstractBottomUpParser.DefaultBeamSize, AbstractBottomUpParser.DefaultAdvancePercentage); }