internal static POSSample CreatePredSample() { const string sentence = "the_DT stories_NNS about_NNS well-heeled_JJ " + "communities_NNS and_CC developers_CC"; return(POSSample.Parse(sentence)); }
public virtual void add(POSSample reference, POSSample prediction) { int length = reference.Sentence.Length; averageSentenceLength.add(length); if (minimalSentenceLength > length) { minimalSentenceLength = length; } if (maximumSentenceLength < length) { maximumSentenceLength = length; } string[] toks = reference.Sentence; string[] refs = reference.Tags; string[] preds = prediction.Tags; updateTagFMeasure(refs, preds); for (int i = 0; i < toks.Length; i++) { add(toks[i], refs[i], preds[i]); } }
public void TestParse() { const string sentence = "the_DT stories_NNS about_IN well-heeled_JJ " + "communities_NNS and_CC developers_NNS"; var sample = POSSample.Parse(sentence); Assert.AreEqual(sentence, sample.ToString()); }
public void TestParseEmptyString() { var sample = POSSample.Parse(string.Empty); Assert.AreEqual(0, sample.Sentence.Length); Assert.AreEqual(0, sample.Tags.Length); var value = sample.ToString(); Assert.IsEmpty(value); }
public override void run(string[] args) { if (args.Length != 1) { Console.WriteLine(Help); } else { ChunkerModel model = (new ChunkerModelLoader()).load(new File(args[0])); ChunkerME chunker = new ChunkerME(model, ChunkerME.DEFAULT_BEAM_SIZE); ObjectStream <string> lineStream = new PlainTextByLineStream(new InputStreamReader(Console.OpenStandardInput)); PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent"); perfMon.start(); try { string line; while ((line = lineStream.read()) != null) { POSSample posSample; try { posSample = POSSample.parse(line); } catch (InvalidFormatException) { Console.Error.WriteLine("Invalid format:"); Console.Error.WriteLine(line); continue; } string[] chunks = chunker.chunk(posSample.Sentence, posSample.Tags); Console.WriteLine((new ChunkSample(posSample.Sentence, posSample.Tags, chunks)).nicePrint()); perfMon.incrementCounter(); } } catch (IOException e) { CmdLineUtil.handleStdinIoError(e); } perfMon.stopAndPrintFinalResult(); } }
public void TestOutcomesForSingleSentence() { const string sentence = "That_DT sounds_VBZ good_JJ ._."; var sample = POSSample.Parse(sentence); var eventStream = new POSSampleEventStream(new GenericObjectStream <POSSample>(sample)); Assert.AreEqual("DT", eventStream.Read().Outcome); Assert.AreEqual("VBZ", eventStream.Read().Outcome); Assert.AreEqual("JJ", eventStream.Read().Outcome); Assert.AreEqual(".", eventStream.Read().Outcome); Assert.Null(eventStream.Read()); }
public override void run(string[] args) { if (args.Length != 1) { Console.WriteLine(Help); } else { POSModel model = (new POSModelLoader()).load(new File(args[0])); POSTaggerME tagger = new POSTaggerME(model); ObjectStream <string> lineStream = new PlainTextByLineStream(new InputStreamReader(Console.OpenStandardInput)); PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent"); perfMon.start(); try { string line; while ((line = lineStream.read()) != null) { string[] whitespaceTokenizerLine = WhitespaceTokenizer.INSTANCE.tokenize(line); string[] tags = tagger.tag(whitespaceTokenizerLine); POSSample sample = new POSSample(whitespaceTokenizerLine, tags); Console.WriteLine(sample.ToString()); perfMon.incrementCounter(); } } catch (IOException e) { CmdLineUtil.handleStdinIoError(e); } perfMon.stopAndPrintFinalResult(); } }
public void TestParseWithError() { Assert.Throws <InvalidFormatException> (() => { POSSample.Parse("the_DT stories"); }); }
public void TestParseEmptyToken() { var sample = POSSample.Parse("the_DT _NNS"); Assert.AreEqual(string.Empty, sample.Sentence[1]); }
public void TestParseEmptyTag() { var sample = POSSample.Parse("the_DT stories_"); Assert.AreEqual(string.Empty, sample.Tags[1]); }
public virtual void correctlyClassified(POSSample reference, POSSample prediction) { stats.add(reference, prediction); }
// methods inherited from EvaluationMonitor public virtual void missclassified(POSSample reference, POSSample prediction) { stats.add(reference, prediction); }
public void TestParseWithError() { POSSample.Parse("the_DT stories"); }