Exemplo n.º 1
0
        public void TestDummyFactory() {

            var model = TrainModel(new DummyChunkerFactory());

            Assert.IsInstanceOf<DummyChunkerFactory>(model.Factory);
            Assert.IsInstanceOf<DummyChunkerFactory.DummyContextGenerator>(model.Factory.GetContextGenerator());
            Assert.IsInstanceOf<DummyChunkerFactory.DummySequenceValidator>(model.Factory.GetSequenceValidator());


            using (var stream = new MemoryStream()) {
                model.Serialize(new UnclosableStream(stream));
                stream.Seek(0, SeekOrigin.Begin);

                var fromSerialized = new ChunkerModel(stream);
                Assert.IsInstanceOf<DummyChunkerFactory>(model.Factory);
                Assert.IsInstanceOf<DummyChunkerFactory.DummyContextGenerator>(
                    fromSerialized.Factory.GetContextGenerator());
                Assert.IsInstanceOf<DummyChunkerFactory.DummySequenceValidator>(
                    fromSerialized.Factory.GetSequenceValidator());
            }

            var chunker = new ChunkerME(model);

            String[] toks1 = {
                "Rockwell", "said", "the", "agreement", "calls", "for",
                "it", "to", "supply", "200", "additional", "so-called", "shipsets",
                "for", "the", "planes", "."
            };

            String[] tags1 = {
                "NNP", "VBD", "DT", "NN", "VBZ", "IN", "PRP", "TO", "VB",
                "CD", "JJ", "JJ", "NNS", "IN", "DT", "NNS", "."
            };

            chunker.Chunk(toks1, tags1);
        }