public void ParseSemiInvalidFile() { var reader = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/invalid.ptb")), true, null); var p1 = reader.Read(); var p2 = reader.Read(); var p3 = reader.Read(); Assert.True(CheckFormat(p1)); Assert.True(CheckFormat(p2)); Assert.IsNull(p3); Assert.AreEqual("one", p1.Type); Assert.AreEqual("three", p2.Type); }
public void TestSamples() { using ( var reader1 = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("/opennlp/tools/parser/test.parse")), false, null)) { using ( var reader2 = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("/opennlp/tools/parser/test.parse")), false, null)) { var stream1 = new PtbParseSampleStream(reader1); Parse p; while ((p = stream1.Read()) != null) { var t2 = reader2.Read(); var op = Parse.ParseParse(t2.ToString()); Assert.AreEqual(p.ToString(), op.ToString()); } } } }
public void NodeSpanTest() { var reader = new PtbStreamReader("pt", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/sample.ptb")), true, null); PtbNode node; while ((node = reader.Read()) != null) { var text = string.Join(" ", node.Tokens); CheckSpan(text, node); } }
public void ParseTest() { var reader = new PtbStreamReader("en", new PlainTextByLineStream( new StringReader(Parser.ParseTest.parseString)), true, null); var node = reader.Read(); Assert.NotNull(node); Assert.AreEqual(1, node.Children.Count); Assert.AreEqual(true, node.Children[0].HasChildren); Assert.AreEqual(5, node.Children[0].Children.Count); }
public void ParseTest() { var reader = new PtbStreamReader("en", new PlainTextByLineStream( new StringReader(Parser.ParseTest.ParseString)), true, null); var node = reader.Read(); Assert.NotNull(node); Assert.AreEqual(1, node.Children.Count); Assert.AreEqual(true, node.Children[0].HasChildren); Assert.AreEqual(5, node.Children[0].Children.Count); }
public void TestSamples() { using ( var reader1 = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("/opennlp/tools/parser/test.parse")), false, null)) { using ( var reader2 = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("/opennlp/tools/parser/test.parse")), false, null)) { var stream1 = new PtbParseSampleStream(reader1); Parse p; while ((p = stream1.Read()) != null) { var t2 = reader2.Read(); var op = Parse.ParseParse(t2.ToString()); Assert.AreEqual(p.ToString(), op.ToString()); } } } }
public void ParseSampleFile() { var reader = new PtbStreamReader("x-unspecified", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/sample.ptb")), true, null); var p1 = reader.Read(); var p2 = reader.Read(); var p3 = reader.Read(); var p4 = reader.Read(); var p5 = reader.Read(); var p6 = reader.Read(); var p7 = reader.Read(); Assert.True(CheckFormat(p1)); Assert.True(CheckFormat(p2)); Assert.True(CheckFormat(p3)); Assert.True(CheckFormat(p4)); Assert.True(CheckFormat(p5)); Assert.True(CheckFormat(p6)); Assert.IsNull(p7); Assert.AreEqual("(STA+fcl (SUBJ+np (>N+art O)(>N+adj próximo)(H+n adversário))(P+v-fin será)(SC+np (>N+art o)(«)(H+n artista)(»)(N<+prop Hicham_Arazi)(N<+fcl (SUBJ+pron-indp que)(P+v-fin garantiu)(ACC+np (>N+adj nova)(H+n presença)(N</ADVL[-1]+pp (H+prp em)(P<+np (>N+art os)(H+n quartos-de-final)(N<+pp (H+prp de)(P<+np (>N+art o)(H+prop Grand_Slam)(N<+adj francês))))))))(.))", p1.ToString()); Assert.AreEqual("(TOP (S (S (NP-SBJ (PRP She))(VP (VBD was)(ADVP (RB just))(NP-PRD (NP (DT another)(NN freighter))(PP (IN from)(NP (DT the)(NNPS States))))))(, ,)(CC and)(S (NP-SBJ (PRP she))(VP (VBD seemed)(ADJP-PRD (ADJP (RB as)(JJ commonplace))(PP (IN as)(NP (PRP$ her)(NN name))))))(. .)))", p2.ToString()); }
public void ParseSampleFile() { var reader = new PtbStreamReader("x-unspecified", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/sample.ptb")), true, null); var p1 = reader.Read(); var p2 = reader.Read(); var p3 = reader.Read(); var p4 = reader.Read(); var p5 = reader.Read(); var p6 = reader.Read(); var p7 = reader.Read(); Assert.True(CheckFormat(p1)); Assert.True(CheckFormat(p2)); Assert.True(CheckFormat(p3)); Assert.True(CheckFormat(p4)); Assert.True(CheckFormat(p5)); Assert.True(CheckFormat(p6)); Assert.IsNull(p7); Assert.AreEqual("(STA+fcl (SUBJ+np (>N+art O)(>N+adj próximo)(H+n adversário))(P+v-fin será)(SC+np (>N+art o)(«)(H+n artista)(»)(N<+prop Hicham_Arazi)(N<+fcl (SUBJ+pron-indp que)(P+v-fin garantiu)(ACC+np (>N+adj nova)(H+n presença)(N</ADVL[-1]+pp (H+prp em)(P<+np (>N+art os)(H+n quartos-de-final)(N<+pp (H+prp de)(P<+np (>N+art o)(H+prop Grand_Slam)(N<+adj francês))))))))(.))", p1.ToString()); Assert.AreEqual("(TOP (S (S (NP-SBJ (PRP She))(VP (VBD was)(ADVP (RB just))(NP-PRD (NP (DT another)(NN freighter))(PP (IN from)(NP (DT the)(NNPS States))))))(, ,)(CC and)(S (NP-SBJ (PRP she))(VP (VBD seemed)(ADJP-PRD (ADJP (RB as)(JJ commonplace))(PP (IN as)(NP (PRP$ her)(NN name))))))(. .)))", p2.ToString()); }
public void ParseSemiInvalidFile() { var reader = new PtbStreamReader("en", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/invalid.ptb")), true, null); var p1 = reader.Read(); var p2 = reader.Read(); var p3 = reader.Read(); Assert.True(CheckFormat(p1)); Assert.True(CheckFormat(p2)); Assert.IsNull(p3); Assert.AreEqual("one", p1.Type); Assert.AreEqual("three", p2.Type); }
public void NodeSpanTest() { var reader = new PtbStreamReader("pt", new PlainTextByLineStream(Tests.OpenFile("sharpnl/formats/ptb/sample.ptb")), true, null); PtbNode node; while ((node = reader.Read()) != null) { var text = string.Join(" ", node.Tokens); CheckSpan(text, node); } }