Beispiel #1
0
        public void NounSetProcessNounSet()
        {
            Assert.AreEqual(this.SentenceGraph.Vertices.Count(), 1);
            Assert.AreEqual(this.SentenceGraph.Edges.Count(), 1);
            var noun    = new Noun(2, "noun2", "_", this.EdgeFactory, this.ElementFactory, this.ImageManager, WIDTH, HEIGHT);
            var nounSet = new NounSet(this.ElementFactory, this.EdgeFactory, this.SentenceGraph, noun);

            this.Noun.Process(nounSet, this.SentenceGraph);

            Assert.AreEqual(this.SentenceGraph.Vertices.Count(), 6);
            Assert.AreEqual(this.SentenceGraph.Edges.Count(), 7);
            Assert.AreEqual(this.SentenceGraph.Vertices.ToList()[1], nounSet);
            Assert.AreEqual(this.SentenceGraph[this.Noun].ToList()[0].Right, nounSet);

            this.SentenceGraph = new SentenceGraph();
            Assert.AreEqual(this.SentenceGraph.Vertices.Count(), 0);
            Assert.AreEqual(this.SentenceGraph.Edges.Count(), 0);
            nounSet = new NounSet(this.ElementFactory, this.EdgeFactory, this.SentenceGraph, noun)
            {
                DependencyType = "nsubj"
            };
            noun.Image = null;

            this.Noun.Process(nounSet, this.SentenceGraph);
            Assert.AreEqual(this.SentenceGraph.Vertices.Count(), 5);
            Assert.AreEqual(this.SentenceGraph.Edges.Count(), 6);
            Assert.AreEqual(this.SentenceGraph.Vertices.ToList()[0], nounSet);
            Assert.AreEqual(this.SentenceGraph[nounSet].ToList().Find(e => e.Right == this.Noun).Right, this.Noun);
        }
Beispiel #2
0
        public void VerbProcessNounSet()
        {
            var noun    = new Noun(0, "noun", "dobj", this.EdgeFactory, this.ElementFactory, this.ImageManager, WIDTH, HEIGHT);
            var nounSet = new NounSet(this.ElementFactory, this.EdgeFactory, this.SentenceGraph, noun);

            this.Verb.Process(nounSet, this.SentenceGraph);
            Assert.AreEqual(this.Verb.Object, nounSet);
            this.Verb.Object = null;

            nounSet.DependencyType = "_";
            this.Verb.Process(nounSet, this.SentenceGraph);
            Assert.AreEqual(this.Verb.DependingDrawables.Count, 1);
            Assert.AreEqual(this.Verb.DependingDrawables[0], nounSet);
            this.Verb.DependingDrawables.Clear();

            nounSet.DependencyType = "nsubj";
            this.Verb.Process(nounSet, this.SentenceGraph);
            nounSet.Nouns.ForEach(n =>
            {
                Assert.AreEqual(n.Actions.Count, 1);
                Assert.AreEqual(n.Actions[0], this.Verb);
            });
        }