public void NewGlossExistingLexEntryAllomorphNewLexSense()
        {
            int hvoCba0_0 = GetCbaHvo(0, 0, 0);

            m_sandbox.SwitchWord(hvoCba0_0, false);
            string    formLexEntry     = "xxxab";
            ITsString tssLexEntryForm  = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
            string    formAllomorph    = "xxxa";
            ITsString tssAllomorphForm = StringUtils.MakeTss(formAllomorph, Cache.DefaultVernWs);

            // first create an entry with a matching allomorph that doesn't match 'verb' POS we will be selecting in the sandbox
            ILexEntry lexEntry_NounPos;
            ILexSense lexSense_NounPos;

            SetupLexEntryAndSense("xxxab", "0.0.xxxab_NounPos", "noun", out lexEntry_NounPos, out lexSense_NounPos);
            IMoStemAllomorph allomorph0 = lexEntry_NounPos.AlternateFormsOS.Append(new MoStemAllomorph()) as IMoStemAllomorph;

            allomorph0.Form.SetAlternativeTss(tssAllomorphForm);

            // now create the entry we want to match, that has a 'verb' POS.
            ILexEntry lexEntry1_Entry;
            ILexSense lexEntry1_Sense1;

            SetupLexEntryAndSense("xxxab", "0.0.xxxab_VerbPos", "verb", out lexEntry1_Entry, out lexEntry1_Sense1);
            IMoStemAllomorph allomorph = lexEntry1_Entry.AlternateFormsOS.Append(new MoStemAllomorph()) as IMoStemAllomorph;

            allomorph.Form.SetAlternativeTss(tssAllomorphForm);

            // mark the count of LexEntries
            int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count;

            // add a new word gloss
            ITsString   tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa");
            int         hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0);
            WfiWordform wf    = new WfiWordform(Cache, hvoWf);
            // set word pos to verb
            int hvoSbWordPos = m_sandbox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, "transitive verb");

            m_sandbox.SelectItemInCombo(InterlinLineChoices.kflidWordPos, 0, hvoSbWordPos);

            // confirm the analysis (making a real analysis and a LexSense)
            int      hvoGloss = m_sandbox.ConfirmAnalysis();
            WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss);

            // make sure we didn't add entries to the Lexicon.
            int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count;

            Assert.AreEqual(cEntriesOrig, cEntriesAfter);

            // confirm we have only one analysis and that it is monomorphemic
            WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis;

            Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform.");
            Assert.AreEqual(1, wf.AnalysesOC.Count);
            Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count);
            Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count);

            // make sure the strings of the wfi gloss matches the strings of the lex gloss.
            ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos, true, allomorph);
        }
        private IWfiAnalysis SetupAnalysisForEntry(int hvoCba0_0, string gloss, ILexSense lexEntry1_Sense1, out WfiWordform wf)
        {
            int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0);

            wf = new WfiWordform(Cache, hvoWf);
            IWfiAnalysis analysis = wf.AnalysesOC.Add(new WfiAnalysis());

            analysis.CategoryRA = (lexEntry1_Sense1.MorphoSyntaxAnalysisRA as MoStemMsa).PartOfSpeechRA;
            IWfiGloss wfigloss = analysis.MeaningsOC.Add(new WfiGloss());

            wfigloss.Form.SetAlternative(gloss, Cache.DefaultAnalWs);
            return(analysis);
        }
        public void NewGlossNewLexEntryNewLexSense()
        {
            // load sandbox for first 'xxxa'
            int hvoCba0_0 = GetCbaHvo(0, 0, 0);

            m_sandbox.SwitchWord(hvoCba0_0, false);

            // verify that the word gloss is empty
            ITsString tssEmpty     = StringUtils.MakeTss("", Cache.DefaultAnalWs);
            ITsString tssWordGloss = m_sandbox.GetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs);

            CompareTss(tssEmpty, tssWordGloss);
            // add a new word gloss and confirm the analysis.
            ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa");
            // mark the count of LexEntries
            int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count;
            // verify no analyses exist for this wordform;
            int         hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0);
            WfiWordform wf    = new WfiWordform(Cache, hvoWf);

            Assert.AreEqual(0, wf.AnalysesOC.Count);

            // set word pos, to first possibility (e.g. 'adjunct')
            int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0);

            Assert.IsFalse(hvoSbWordPos == 0);                   // select nonzero pos

            // confirm the analysis (making a real analysis and a LexSense)
            int hvoGloss = m_sandbox.ConfirmAnalysis();

            WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss);

            CompareTss(tssWordGlossInSandbox, wfiGloss.Form.GetAlternativeTss(Cache.DefaultAnalWs));
            // confirm we have only one analysis and that it is monomorphemic
            WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis;

            Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform.");
            Assert.AreEqual(1, wf.AnalysesOC.Count);
            Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count);
            Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count);

            // make sure the strings of the wfi gloss matches the strings of the lex gloss.
            ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos);

            // make sure a new entry is in the Lexicon.
            int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count;

            Assert.AreEqual(cEntriesOrig + 1, cEntriesAfter);
        }
        public void PickLexGlossCreatingNewAnalysis()
        {
            int hvoCba0_0 = GetCbaHvo(0, 0, 0);

            m_sandbox.SwitchWord(hvoCba0_0, false);
            ILexEntry lexEntry1_Entry;
            ILexSense lexEntry1_Sense1;

            SetupLexEntryAndSense("xxxa", "0.0.xxxa", out lexEntry1_Entry, out lexEntry1_Sense1);

            // mark the count of LexEntries
            int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count;

            // add a new word gloss
            ITsString   tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa");
            int         hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0);
            WfiWordform wf    = new WfiWordform(Cache, hvoWf);
            // set word pos, to first possibility (e.g. 'adjunct')
            int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0);

            // confirm the analysis (making a real analysis and a LexSense)
            int      hvoGloss = m_sandbox.ConfirmAnalysis();
            WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss);

            // make sure we didn't add entries or senses to the Lexicon.
            int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count;

            Assert.AreEqual(cEntriesOrig, cEntriesAfter);
            Assert.AreEqual(1, lexEntry1_Entry.SensesOS.Count);

            // make sure the sense matches the existing one.
            ILexSense sense = m_sandbox.GetLexSenseForWord();

            Assert.AreEqual(lexEntry1_Sense1.Hvo, sense.Hvo);
            // make sure the morph is linked to our lexicon sense, msa, and part of speech.
            ValidateSenseWithAnalysis(sense, wfiGloss, hvoSbWordPos);

            // confirm we have created a new analysis and that it is monomorphemic
            WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis;

            Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform.");
            Assert.AreEqual(1, wf.AnalysesOC.Count);
            Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count);
            Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count);
        }
        public void NewGlossExistingLexEntryNewLexSense()
        {
            int hvoCba0_0 = GetCbaHvo(0, 0, 0);

            m_sandbox.SwitchWord(hvoCba0_0, false);
            string    formLexEntry    = "xxxa";
            ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
            int       clsidForm;
            ILexEntry lexEntry1_Entry = LexEntry.CreateEntry(Cache,
                                                             MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
                                                             "xxxa.existingsense1", null);
            ILexSense lexEntry1_Sense1 = lexEntry1_Entry.SensesOS[0];

            // mark the count of LexEntries
            int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count;

            // add a new word gloss
            ITsString   tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa");
            int         hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0);
            WfiWordform wf    = new WfiWordform(Cache, hvoWf);
            // set word pos, to first possibility (e.g. 'adjunct')
            int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0);

            // confirm the analysis (making a real analysis and a LexSense)
            int      hvoGloss = m_sandbox.ConfirmAnalysis();
            WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss);

            // make sure we didn't add entries to the Lexicon.
            int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count;

            Assert.AreEqual(cEntriesOrig, cEntriesAfter);

            // confirm we have only one analysis and that it is monomorphemic
            WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis;

            Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform.");
            Assert.AreEqual(1, wf.AnalysesOC.Count);
            Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count);
            Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count);

            // make sure the strings of the wfi gloss matches the strings of the lex gloss.
            ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos);
        }