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); }
/// <summary/> internal static void SetupLexEntryAndSense(string formLexEntry, string senseGloss, string partOfSpeech, LcmCache cache, SandboxForTests testSandBox, out ILexEntry lexEntry, out ILexSense lexSense) { ITsString tssLexEntryForm = TsStringUtils.MakeString(formLexEntry, cache.DefaultVernWs); // create a sense with a matching gloss var entryComponents = MorphServices.BuildEntryComponents(cache, tssLexEntryForm); int hvoSenseMsaPos = testSandBox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, partOfSpeech); if (hvoSenseMsaPos != 0) { entryComponents.MSA.MainPOS = cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoSenseMsaPos); } entryComponents.GlossAlternatives.Add(TsStringUtils.MakeString(senseGloss, cache.DefaultAnalWs)); ILexEntry newEntry = cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(entryComponents); lexEntry = newEntry; lexSense = newEntry.SensesOS[0]; }
public void NewGlossExistingLexEntryAllomorphNewLexSense() { var cba0_0 = GetNewAnalysisOccurence(m_text1, 0, 0, 0); m_sandbox.SwitchWord(cba0_0); string formLexEntry = "xxxab"; ITsString tssLexEntryForm = TsStringUtils.MakeString(formLexEntry, Cache.DefaultVernWs); string formAllomorph = "xxxa"; ITsString tssAllomorphForm = TsStringUtils.MakeString(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); var stemFactory = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>(); var allomorph0 = stemFactory.Create(); lexEntry_NounPos.AlternateFormsOS.Add(allomorph0); allomorph0.Form.set_String(TsStringUtils.GetWsAtOffset(tssAllomorphForm, 0), 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 = stemFactory.Create(); lexEntry1_Entry.AlternateFormsOS.Add(allomorph); allomorph.MorphTypeRA = lexEntry1_Entry.LexemeFormOA.MorphTypeRA; allomorph.Form.set_String(TsStringUtils.GetWsAtOffset(tssAllomorphForm, 0), tssAllomorphForm); // mark the count of LexEntries int cEntriesOrig = Cache.LangProject.LexDbOA.Entries.Count(); // add a new word gloss ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa"); IWfiWordform wf = cba0_0.Analysis.Wordform; // 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) var wag = m_sandbox.ConfirmAnalysis(); IWfiGloss wfiGloss = wag.Gloss; // make sure we didn't add entries to the Lexicon. int cEntriesAfter = Cache.LangProject.LexDbOA.Entries.Count(); Assert.AreEqual(cEntriesOrig, cEntriesAfter); // confirm we have only one analysis and that it is monomorphemic IWfiAnalysis wfiAnalysis = wag.WfiAnalysis; Assert.AreEqual(wf, wag.Wordform, "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); }