/// <summary>
        /// Evaluates the specified chunk samples.
        /// </summary>
        /// <param name="samples">The chunk samples to be evaluated.</param>
        /// <param name="partitions">The partitions (folds).</param>
        public void Evaluate(IObjectStream<ChunkSample> samples, int partitions) {
            var partitioner = new CrossValidationPartitioner<ChunkSample>(samples, partitions);

            while (partitioner.HasNext) {

                var trainingSampleStream = partitioner.Next();

                var model = ChunkerME.Train(languageCode, trainingSampleStream, parameters, chunkerFactory);

                var evaluator = new ChunkerEvaluator(new ChunkerME(model), listeners);

                evaluator.Evaluate(trainingSampleStream.GetTestSampleStream());

                FMeasure.MergeInto(evaluator.FMeasure);
            }
        }
        public void TestEvaluatorNoError() {
            using (
                var predictedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true))
            using (
                var expectedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true)) {
                var dummyChunker = new DummyChunker(predictedSample);

                var evaluator = new ChunkerEvaluator(dummyChunker);

                evaluator.Evaluate(expectedSample);

                Assert.AreEqual(1d, evaluator.FMeasure.PrecisionScore, DELTA);
                Assert.AreEqual(1d, evaluator.FMeasure.RecallScore, DELTA);
            }
        }
Beispiel #3
0
        public void TestEvaluatorNoError()
        {
            using (
                var predictedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true))
                using (
                    var expectedSample =
                        new DummyChunkSampleStream(
                            new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true)) {
                    var dummyChunker = new DummyChunker(predictedSample);

                    var evaluator = new ChunkerEvaluator(dummyChunker);

                    evaluator.Evaluate(expectedSample);

                    Assert.AreEqual(1d, evaluator.FMeasure.PrecisionScore, DELTA);
                    Assert.AreEqual(1d, evaluator.FMeasure.RecallScore, DELTA);
                }
        }
        public void TestEvaluator() {
            using (
                var predictedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true))
            using (
                var expectedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), false)) {
                var dummyChunker = new DummyChunker(predictedSample);

                //var stream = new ByteArrayOutputStream();
                //ChunkerEvaluationMonitor listener = new ChunkEvaluationErrorListener(stream);
                var evaluator = new ChunkerEvaluator(dummyChunker);

                evaluator.Evaluate(expectedSample);

                Assert.AreEqual(0.8d, evaluator.FMeasure.PrecisionScore, DELTA);
                Assert.AreEqual(0.875d, evaluator.FMeasure.RecallScore, DELTA);

                //assertNotSame(stream.toString().length(), 0);
            }
        }
Beispiel #5
0
        public void TestEvaluator()
        {
            using (
                var predictedSample =
                    new DummyChunkSampleStream(
                        new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), true))
                using (
                    var expectedSample =
                        new DummyChunkSampleStream(
                            new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/chunker/output.txt")), false)) {
                    var dummyChunker = new DummyChunker(predictedSample);

                    //var stream = new ByteArrayOutputStream();
                    //ChunkerEvaluationMonitor listener = new ChunkEvaluationErrorListener(stream);
                    var evaluator = new ChunkerEvaluator(dummyChunker);

                    evaluator.Evaluate(expectedSample);

                    Assert.AreEqual(0.8d, evaluator.FMeasure.PrecisionScore, DELTA);
                    Assert.AreEqual(0.875d, evaluator.FMeasure.RecallScore, DELTA);

                    //assertNotSame(stream.toString().length(), 0);
                }
        }