Ejemplo n.º 1
0
        public void SetAgentOpinion()
        {
            ICmAgent     agent = Cache.LangProject.DefaultComputerAgent;
            IWfiWordform wf    = WfiWordformServices.FindOrCreateWordform(Cache,
                                                                          TsStringUtils.MakeTss("xxxyyyzzz12234", Cache.DefaultVernWs));
            IWfiAnalysis wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create();

            wf.AnalysesOC.Add(wa);
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.approves);
            Assert.AreEqual(Opinions.approves, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.disapproves);
            Assert.AreEqual(Opinions.disapproves, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.noopinion);
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));
        }
Ejemplo n.º 2
0
        public void Analysis_IsComplete()
        {
            // Make a fully complete analysis, then try altering one thing at a time.
            var           wf = MakeAWordform();
            IPartOfSpeech pos;
            ICmAgent      human;
            IWfiGloss     wg;
            IWfiAnalysis  wa = MakeCompleteAnalysis(wf, out pos, out human, out wg);

            Assert.IsTrue(wa.IsComplete);

            // - gloss is incomplete
            wg.Form.AnalysisDefaultWritingSystem = Cache.TsStrFactory.EmptyString(Cache.DefaultAnalWs);
            Assert.IsFalse(wa.IsComplete);
            // - no gloss
            wa.MeaningsOC.Remove(wg);
            Assert.IsFalse(wa.IsComplete);
            // - multiple glosses, one incomplete
            wg = MakeCompleteGloss(wa);
            var wg2 = MakeGloss(wa);

            Assert.IsFalse(wa.IsComplete);
            wa.MeaningsOC.Remove(wg2);
            // - restore completeness, as far as glosses are concerned, and verify
            Assert.IsTrue(wa.IsComplete);

            // - bundles are incomplete
            wa.MorphBundlesOS[0].SenseRA = null;
            Assert.IsFalse(wa.IsComplete);
            // - no bundles
            wa.MorphBundlesOS.RemoveAt(0);
            Assert.IsFalse(wa.IsComplete);
            // - multiple bundles, not all complete
            MakeCompleteBundle(wa);
            MakeBundle(wa);
            Assert.IsFalse(wa.IsComplete);
            // - restore bundles to complete and verify
            wa.MorphBundlesOS.RemoveAt(1);
            Assert.IsTrue(wa.IsComplete);

            // - Category missing
            wa.CategoryRA = null;
            Assert.IsFalse(wa.IsComplete);
            wa.CategoryRA = pos;
            Assert.IsTrue(wa.IsComplete);

            // - Conflicting parser analysis
            var parser = Cache.LangProject.DefaultParserAgent;

            wa.SetAgentOpinion(parser, Opinions.disapproves);
            Assert.IsFalse(wa.IsComplete);
            // - But two opinions agreeing is OK.
            wa.SetAgentOpinion(parser, Opinions.approves);
            Assert.IsTrue(wa.IsComplete);
            // - however the human must have an opinion
            wa.SetAgentOpinion(human, Opinions.noopinion);
            Assert.IsFalse(wa.IsComplete);
            wa.SetAgentOpinion(human, Opinions.approves);

            // - It occurs.
            var text = MakeText("some words");

            MakeFirstSegReferenceAnalysis(text, wa);
            Assert.IsFalse(wa.IsComplete);
            RemoveReferenceAnalysisFromFirstSeg(text, wa);

            // But it's OK if one of its glosses occurs.
            MakeFirstSegReferenceAnalysis(text, wg);
            Assert.IsTrue(wa.IsComplete);
        }