protected override string AdjustText(out int addToSelection) { bool selWasAtEnd = m_tbForm.SelectionStart + m_tbForm.SelectionLength == m_tbForm.Text.Length; string fixedText = base.AdjustText(out addToSelection); // Only do the morpheme marker trick if the selection is at the end, a good sign the user just // typed it. This avoids the situation where it is impossible to delete one of a pair of tildes. if (!selWasAtEnd) { return(fixedText); } // Check whether we need to handle partial marking of a morphtype (suprafix in the // default case: see LT-6082). string sAdjusted; var mmt = MorphServices.GetTypeIfMatchesPrefix(m_cache, fixedText, out sAdjusted); if (mmt != null && fixedText != sAdjusted) { m_skipCheck = true; m_tbForm.Text = sAdjusted; m_skipCheck = false; return(sAdjusted); } return(fixedText); }
private IEnumerable <IMoInflAffixSlot> GetSlots() { if (m_morphType == null) { // Not called by InsertEntryDlg; need to figure out the morphtype(s) var lex = m_mediator.PropertyTable.GetValue("ActiveClerkSelectedObject") as ILexEntry; if (lex != null) { return(DomainObjectServices.GetSlots(m_cache, lex, m_selectedMainPOS)); } else { return(m_selectedMainPOS.AllAffixSlots); } } else { // Called by InsertEntryDlg so we know the morphtype bool fIsPrefixal = MorphServices.IsPrefixishType(m_cache, m_morphType.Hvo); bool fIsSuffixal = MorphServices.IsSuffixishType(m_cache, m_morphType.Hvo); if (fIsPrefixal && fIsSuffixal) { return(m_selectedMainPOS.AllAffixSlots); } else { return(DomainObjectServices.GetSomeSlots(m_cache, m_selectedMainPOS.AllAffixSlots, fIsPrefixal)); } } }
public void DifferentAnalyses_AreNotMerged() { var wf = MakeWordform("bank"); var wa1 = MakeAnalysis(wf); var entryBank = MakeEntry("bank", "side of river"); MakeBundle(wa1, entryBank.SensesOS[0]); var wa2 = MakeAnalysis(wf); var entryKick = MakeEntry("bank", "place for money"); MakeBundle(wa2, entryKick.SensesOS[0]); var wa3 = MakeAnalysis(wf); MakeBundle(wa3, entryBank.SensesOS[0]); var verb = MakePartOfSpeech("verb"); wa3.CategoryRA = verb; var wa4 = MakeAnalysis(wf); MakeBundle(wa4, "bank"); // analysis only to morpheme level var wa5 = MakeAnalysis(wf); MakeBundle(wa5, "bank0"); // analysis only to morpheme level var wa6 = MakeAnalysis(wf); var bundle6 = MakeBundle(wa6, "bank"); bundle6.MsaRA = MakeMsa(entryBank); var wa7 = MakeAnalysis(wf); var bundle7 = MakeBundle(wa7, "bank0"); bundle7.MorphRA = MorphServices.MakeMorph(entryBank, TsStringUtils.MakeTss("bank", Cache.DefaultVernWs)); var wa8 = MakeAnalysis(wf); MakeBundle(wa8, entryBank.SensesOS[0]); MakeBundle(wa8, entryBank.SensesOS[0]); // makes sure it handles different number of bundles WfiWordformServices.MergeDuplicateAnalyses(Cache, m_progress); // We could try for something stronger; the basic idea is that it should change nothing. // But the kind of changes it makes is deleting objects, so this should cover it. Assert.That(wa1.IsValidObject); Assert.That(wa2.IsValidObject); Assert.That(wa3.IsValidObject); Assert.That(wa4.IsValidObject); Assert.That(wa5.IsValidObject); Assert.That(wa6.IsValidObject); Assert.That(wa7.IsValidObject); Assert.That(wa8.IsValidObject); }
public static void WriteMsaElement(this XmlWriter writer, FdoCache cache, string formID, string msaID, string type, string wordType) { // Irregulary inflected forms can have a combination MSA hvo: the LexEntry hvo, a period, and an index to the LexEntryRef Tuple <int, int> msaTuple = ProcessMsaHvo(msaID); ICmObject obj = cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(msaTuple.Item1); switch (obj.GetType().Name) { default: throw new ApplicationException(String.Format("Invalid MSA type: {0}.", obj.GetType().Name)); case "MoStemMsa": WriteStemMsaXmlElement(writer, (IMoStemMsa)obj, Enumerable.Empty <ILexEntryRef>()); break; case "MoInflAffMsa": WriteInflectionClasses(writer, cache, int.Parse(formID, CultureInfo.InvariantCulture)); WriteInflMsaXmlElement(writer, (IMoInflAffMsa)obj, type); break; case "MoDerivAffMsa": WriteDerivMsaXmlElement(writer, (IMoDerivAffMsa)obj); break; case "MoUnclassifiedAffixMsa": WriteUnclassifedMsaXmlElement(writer, (IMoUnclassifiedAffixMsa)obj); break; case "LexEntry": // is an irregularly inflected form // get the MoStemMsa of its variant var entry = (ILexEntry)obj; if (entry.EntryRefsOS.Count > 0) { ILexEntryRef lexEntryRef = entry.EntryRefsOS[msaTuple.Item2]; ILexSense sense = MorphServices.GetMainOrFirstSenseOfVariant(lexEntryRef); WriteStemMsaXmlElement(writer, (IMoStemMsa)sense.MorphoSyntaxAnalysisRA, entry.VariantEntryRefs); } break; case "LexEntryInflType": // This is one of the null allomorphs we create when building the // input for the parser in order to still get the Word Grammar to have something in any // required slots in affix templates. WriteInflMsaForLexEntryInflType(writer, wordType, (ILexEntryInflType)obj); break; } }
/// <summary> /// </summary> /// <param name="formLexEntry"></param> /// <param name="senseGloss"></param> /// <param name="partOfSpeech"></param> /// <param name="lexEntry1_Entry"></param> /// <param name="lexEntry1_Sense1"></param> private void SetupLexEntryAndSense(string formLexEntry, string senseGloss, string partOfSpeech, out ILexEntry lexEntry1_Entry, out ILexSense lexEntry1_Sense1) { ITsString tssLexEntryForm = TsStringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs); // create a sense with a matching gloss var entryComponents = MorphServices.BuildEntryComponents(Cache, tssLexEntryForm); int hvoSenseMsaPos = m_sandbox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, partOfSpeech); if (hvoSenseMsaPos != 0) { entryComponents.MSA.MainPOS = Cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoSenseMsaPos); } entryComponents.GlossAlternatives.Add(TsStringUtils.MakeTss(senseGloss, Cache.DefaultAnalWs)); ILexEntry newEntry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(entryComponents); lexEntry1_Entry = newEntry; lexEntry1_Sense1 = newEntry.SensesOS[0]; }
private static bool TryCreateParseMorph(FdoCache cache, XElement morphElem, out ParseMorph morph) { XElement formElement = morphElem.Element("MoForm"); Debug.Assert(formElement != null); var formHvo = (string)formElement.Attribute("DbRef"); XElement msiElement = morphElem.Element("MSI"); Debug.Assert(msiElement != null); var msaHvo = (string)msiElement.Attribute("DbRef"); // Normally, the hvo for MoForm is a MoForm and the hvo for MSI is an MSA // There are four exceptions, though, when an irregularly inflected form is involved: // 1. <MoForm DbRef="x"... and x is an hvo for a LexEntryInflType. // This is one of the null allomorphs we create when building the // input for the parser in order to still get the Word Grammar to have something in any // required slots in affix templates. The parser filer can ignore these. // 2. <MSI DbRef="y"... and y is an hvo for a LexEntryInflType. // This is one of the null allomorphs we create when building the // input for the parser in order to still get the Word Grammar to have something in any // required slots in affix templates. The parser filer can ignore these. // 3. <MSI DbRef="y"... and y is an hvo for a LexEntry. // The LexEntry is a variant form for the first set of LexEntryRefs. // 4. <MSI DbRef="y"... and y is an hvo for a LexEntry followed by a period and an index digit. // The LexEntry is a variant form and the (non-zero) index indicates // which set of LexEntryRefs it is for. ICmObject objForm; if (!cache.ServiceLocator.GetInstance <ICmObjectRepository>().TryGetObject(int.Parse(formHvo), out objForm)) { morph = null; return(false); } var form = objForm as IMoForm; if (form == null) { morph = null; return(true); } // Irregulary inflected forms can have a combination MSA hvo: the LexEntry hvo, a period, and an index to the LexEntryRef Tuple <int, int> msaTuple = ProcessMsaHvo(msaHvo); ICmObject objMsa; if (!cache.ServiceLocator.GetInstance <ICmObjectRepository>().TryGetObject(msaTuple.Item1, out objMsa)) { morph = null; return(false); } var msa = objMsa as IMoMorphSynAnalysis; if (msa != null) { morph = new ParseMorph(form, msa); return(true); } var msaAsLexEntry = objMsa as ILexEntry; if (msaAsLexEntry != null) { // is an irregularly inflected form // get the MoStemMsa of its variant if (msaAsLexEntry.EntryRefsOS.Count > 0) { ILexEntryRef lexEntryRef = msaAsLexEntry.EntryRefsOS[msaTuple.Item2]; ILexSense sense = MorphServices.GetMainOrFirstSenseOfVariant(lexEntryRef); var inflType = lexEntryRef.VariantEntryTypesRS[0] as ILexEntryInflType; morph = new ParseMorph(form, sense.MorphoSyntaxAnalysisRA, inflType); return(true); } } // if it is anything else, we ignore it morph = null; return(true); }
public static void WriteMorphInfoElements(this XmlWriter writer, FdoCache cache, string formID, string msaID, string wordType, string props) { ICmObject obj = cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(int.Parse(formID, CultureInfo.InvariantCulture)); var form = obj as IMoForm; if (form == null) { // This is one of the null allomorphs we create when building the // input for the parser in order to still get the Word Grammar to have something in any // required slots in affix templates. var lexEntryInflType = obj as ILexEntryInflType; if (lexEntryInflType != null) { WriteLexEntryInflTypeElement(writer, wordType, lexEntryInflType); return; } } string shortName; string alloform; string gloss; string citationForm; if (form != null) { shortName = form.LongName; int iFirstSpace = shortName.IndexOf(" (", StringComparison.Ordinal); int iLastSpace = shortName.LastIndexOf("):", StringComparison.Ordinal) + 2; alloform = shortName.Substring(0, iFirstSpace); Tuple <int, int> msaTuple = ProcessMsaHvo(msaID); ICmObject msaObj = cache.ServiceLocator.GetObject(msaTuple.Item1); if (msaObj.ClassID == LexEntryTags.kClassId) { var entry = msaObj as ILexEntry; Debug.Assert(entry != null); if (entry.EntryRefsOS.Count > 0) { ILexEntryRef lexEntryRef = entry.EntryRefsOS[msaTuple.Item2]; ITsIncStrBldr sbGlossPrepend; ITsIncStrBldr sbGlossAppend; ILexSense sense = MorphServices.GetMainOrFirstSenseOfVariant(lexEntryRef); IWritingSystem glossWs = cache.ServiceLocator.WritingSystemManager.Get(cache.DefaultAnalWs); MorphServices.JoinGlossAffixesOfInflVariantTypes(lexEntryRef.VariantEntryTypesRS, glossWs, out sbGlossPrepend, out sbGlossAppend); ITsIncStrBldr sbGloss = sbGlossPrepend; sbGloss.Append(sense.Gloss.BestAnalysisAlternative.Text); sbGloss.Append(sbGlossAppend.Text); gloss = sbGloss.Text; } else { gloss = ParserCoreStrings.ksUnknownGloss; } } else { var msa = msaObj as IMoMorphSynAnalysis; gloss = msa != null?msa.GetGlossOfFirstSense() : shortName.Substring(iFirstSpace, iLastSpace - iFirstSpace).Trim(); } citationForm = shortName.Substring(iLastSpace).Trim(); shortName = String.Format(ParserCoreStrings.ksX_Y_Z, alloform, gloss, citationForm); } else { alloform = ParserCoreStrings.ksUnknownMorpheme; // in case the user continues... gloss = ParserCoreStrings.ksUnknownGloss; citationForm = ParserCoreStrings.ksUnknownCitationForm; shortName = String.Format(ParserCoreStrings.ksX_Y_Z, alloform, gloss, citationForm); throw new ApplicationException(shortName); } writer.WriteElementString("shortName", shortName); writer.WriteElementString("alloform", alloform); switch (form.ClassID) { case MoStemAllomorphTags.kClassId: WriteStemNameElement(writer, form, props); break; case MoAffixAllomorphTags.kClassId: WriteAffixAlloFeatsElement(writer, form, props); WriteStemNameAffixElement(writer, cache, props); break; } writer.WriteElementString("gloss", gloss); writer.WriteElementString("citationForm", citationForm); }
/// <summary> /// Reset the list of matching items. /// </summary> /// <param name="searchKey"></param> protected override void ResetMatches(string searchKey) { using (new WaitCursor(this)) { string sAdjusted; var mmt = MorphServices.GetTypeIfMatchesPrefix(m_cache, searchKey, out sAdjusted); if (mmt != null) { searchKey = String.Empty; m_btnInsert.Enabled = false; } else if (searchKey.Length > 0) { // NB: This method strips off reserved characters for searchKey, // which is a good thing. (fixes LT-802?) try { int clsidForm; MorphServices.FindMorphType(m_cache, ref searchKey, out clsidForm); m_btnInsert.Enabled = searchKey.Length > 0; } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show(ex.Message, LexText.Controls.LexTextControls.ksInvalidForm, MessageBoxButtons.OK); m_btnInsert.Enabled = false; return; } } else { m_btnInsert.Enabled = false; } var selectedWs = (IWritingSystem)m_cbWritingSystems.SelectedItem; int wsSelHvo = selectedWs != null ? selectedWs.Handle : 0; string form, gloss; int vernWs, analWs; if (!GetSearchKey(wsSelHvo, searchKey, out form, out vernWs, out gloss, out analWs)) { int ws = TsStringUtils.GetWsAtOffset(m_tbForm.Tss, 0); if (!GetSearchKey(ws, searchKey, out form, out vernWs, out gloss, out analWs)) { return; } wsSelHvo = ws; } if (m_oldSearchKey == searchKey && m_oldSearchWs == wsSelHvo) { return; // Nothing new to do, so skip it. } if (m_oldSearchWs != wsSelHvo) { m_matchingObjectsBrowser.Reset(); // This updates the writing system for the functor. m_searchFieldGetter.SearchWs = wsSelHvo; } // disable Go button until we rebuild our match list. m_btnOK.Enabled = false; m_oldSearchKey = searchKey; m_oldSearchWs = wsSelHvo; var fields = new List <SearchField>(); if (form != null) { ITsString tssForm = m_tsf.MakeString(form, vernWs); fields.Add(new SearchField(LexEntryTags.kflidCitationForm, tssForm)); fields.Add(new SearchField(LexEntryTags.kflidLexemeForm, tssForm)); fields.Add(new SearchField(LexEntryTags.kflidAlternateForms, tssForm)); } if (gloss != null) { ITsString tssGloss = m_tsf.MakeString(gloss, analWs); fields.Add(new SearchField(LexSenseTags.kflidGloss, tssGloss)); } if (!Controls.Contains(m_searchAnimation)) { Controls.Add(m_searchAnimation); m_searchAnimation.BringToFront(); } m_matchingObjectsBrowser.Search(fields, m_startingEntry == null ? null : new[] { m_startingEntry }); if (Controls.Contains(m_searchAnimation)) { Controls.Remove(m_searchAnimation); } } }
/// <summary> /// Reset the list of matching items. /// </summary> /// <param name="searchKey"></param> protected override void ResetMatches(string searchKey) { string sAdjusted; var mmt = MorphServices.GetTypeIfMatchesPrefix(m_cache, searchKey, out sAdjusted); if (mmt != null) { searchKey = String.Empty; m_btnInsert.Enabled = false; } else if (searchKey.Length > 0) { // NB: This method strips off reserved characters for searchKey, // which is a good thing. (fixes LT-802?) try { int clsidForm; MorphServices.FindMorphType(m_cache, ref searchKey, out clsidForm); m_btnInsert.Enabled = searchKey.Length > 0; } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show(ex.Message, LexText.Controls.LexTextControls.ksInvalidForm, MessageBoxButtons.OK); m_btnInsert.Enabled = false; return; } } else { m_btnInsert.Enabled = false; } var selectedWs = (IWritingSystem)m_cbWritingSystems.SelectedItem; int wsSelHvo = selectedWs != null ? selectedWs.Handle : 0; if (!m_vernHvos.Contains(wsSelHvo) && !m_analHvos.Contains(wsSelHvo)) { wsSelHvo = TsStringUtils.GetWsAtOffset(m_tbForm.Tss, 0); if (!m_vernHvos.Contains(wsSelHvo) && !m_analHvos.Contains(wsSelHvo)) { return; } } if (m_oldSearchKey == searchKey && m_oldSearchWs == wsSelHvo) { return; // Nothing new to do, so skip it. } if (m_oldSearchKey != string.Empty || searchKey != string.Empty) { StartSearchAnimation(); } // disable Go button until we rebuild our match list. m_btnOK.Enabled = false; m_oldSearchKey = searchKey; m_oldSearchWs = wsSelHvo; m_matchingObjectsBrowser.SearchAsync(GetFields(searchKey, wsSelHvo)); }
/// <summary> /// /// </summary> /// <param name="argument">The xCore Command object.</param> /// <returns>true</returns> public bool OnAddApprovedAnalysis(object argument) { var mainWnd = (FwXWindow)m_dataEntryForm.FindForm(); using (EditMorphBreaksDlg dlg = new EditMorphBreaksDlg(mainWnd.Mediator.HelpTopicProvider)) { IWfiWordform wf = Wordform; if (wf == null) { return(true); } ITsString tssWord = Wordform.Form.BestVernacularAlternative; string morphs = tssWord.Text; var cache = Cache; dlg.Initialize(tssWord, morphs, cache.MainCacheAccessor.WritingSystemFactory, cache, m_dataEntryForm.Mediator.StringTbl, m_dataEntryForm.StyleSheet); // Making the form active fixes problems like LT-2619. // I'm (RandyR) not sure what adverse impact might show up by doing this. mainWnd.Activate(); if (dlg.ShowDialog(mainWnd) == DialogResult.OK) { morphs = dlg.GetMorphs().Trim(); if (morphs.Length == 0) { return(true); } string[] prefixMarkers = MorphServices.PrefixMarkers(cache); string[] postfixMarkers = MorphServices.PostfixMarkers(cache); List <string> allMarkers = new List <string>(); foreach (string s in prefixMarkers) { allMarkers.Add(s); } foreach (string s in postfixMarkers) { if (!allMarkers.Contains(s)) { allMarkers.Add(s); } } allMarkers.Add(" "); string[] breakMarkers = new string[allMarkers.Count]; for (int i = 0; i < allMarkers.Count; ++i) { breakMarkers[i] = allMarkers[i]; } string fullForm = SandboxBase.MorphemeBreaker.DoBasicFinding(morphs, breakMarkers, prefixMarkers, postfixMarkers); var command = (Command)argument; UndoableUnitOfWorkHelper.Do(command.UndoText, command.RedoText, cache.ActionHandlerAccessor, () => { IWfiAnalysis newAnalysis = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create(); Wordform.AnalysesOC.Add(newAnalysis); newAnalysis.ApprovalStatusIcon = 1; // Make it human approved. int vernWS = TsStringUtils.GetWsAtOffset(tssWord, 0); foreach (string morph in fullForm.Split(Unicode.SpaceChars)) { if (morph != null && morph.Length != 0) { IWfiMorphBundle mb = cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create(); newAnalysis.MorphBundlesOS.Add(mb); mb.Form.set_String(vernWS, Cache.TsStrFactory.MakeString(morph, vernWS)); } } }); } } return(true); }
public void LexEntryInflTypeAnalysisWithNullForSlotFiller() { IWfiWordform brubs = CheckAnalysisSize("brubsTEST", 0, true); ILexDb ldb = Cache.LanguageProject.LexDbOA; ParseResult result = null; UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () => { // Verb brub which is a present tense irregularly inflected form of 'believe' // with automatically generated null Tense slot and an -s Plural Number slot filler // (This is not supposed to be English, in case you're wondering....) ILexEntryInflType presentTenseLexEntryInflType = m_lexEntryInflTypeFactory.Create(); Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(presentTenseLexEntryInflType); ILexEntry believeV = m_entryFactory.Create(); IMoStemAllomorph believeVForm = m_stemAlloFactory.Create(); believeV.AlternateFormsOS.Add(believeVForm); believeVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("believeVTEST", m_vernacularWS.Handle); IMoStemMsa believeVMsa = m_stemMsaFactory.Create(); believeV.MorphoSyntaxAnalysesOC.Add(believeVMsa); ILexSense believeVSense = m_senseFactory.Create(); believeV.SensesOS.Add(believeVSense); believeVSense.MorphoSyntaxAnalysisRA = believeVMsa; ILexEntry brubV = m_entryFactory.Create(); IMoStemAllomorph brubVForm = m_stemAlloFactory.Create(); brubV.AlternateFormsOS.Add(brubVForm); brubVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("brubVTEST", m_vernacularWS.Handle); ILexEntryRef lexEntryref = m_lexEntryRefFactory.Create(); brubV.EntryRefsOS.Add(lexEntryref); lexEntryref.ComponentLexemesRS.Add(believeV); lexEntryref.VariantEntryTypesRS.Add(presentTenseLexEntryInflType); ILexEntry nullPresent = m_entryFactory.Create(); IMoAffixAllomorph nullPresentForm = m_afxAlloFactory.Create(); nullPresent.AlternateFormsOS.Add(nullPresentForm); nullPresentForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("nullPRESENTTEST", m_vernacularWS.Handle); IMoInflAffMsa nullPresentMsa = m_inflAffMsaFactory.Create(); nullPresent.MorphoSyntaxAnalysesOC.Add(nullPresentMsa); ILexEntry sPlural = m_entryFactory.Create(); IMoAffixAllomorph sPluralForm = m_afxAlloFactory.Create(); sPlural.AlternateFormsOS.Add(sPluralForm); sPluralForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("sPLURALTEST", m_vernacularWS.Handle); IMoInflAffMsa sPluralMsa = m_inflAffMsaFactory.Create(); sPlural.MorphoSyntaxAnalysesOC.Add(sPluralMsa); result = new ParseResult(new[] { new ParseAnalysis(new[] { new ParseMorph(brubVForm, MorphServices.GetMainOrFirstSenseOfVariant(brubV.EntryRefsOS[0]).MorphoSyntaxAnalysisRA, (ILexEntryInflType)brubV.EntryRefsOS[0].VariantEntryTypesRS[0]), new ParseMorph(sPluralForm, sPluralMsa) }) }); }); m_filer.ProcessParse(brubs, ParserPriority.Low, result); ExecuteIdleQueue(); CheckAnalysisSize("brubsTEST", 1, false); var analysis = brubs.AnalysesOC.ElementAt(0); Assert.AreEqual(2, analysis.MorphBundlesOS.Count, "Expected only 2 morphs in the analysis"); var morphBundle = analysis.MorphBundlesOS.ElementAt(0); Assert.IsNotNull(morphBundle.Form, "First bundle: form is not null"); Assert.IsNotNull(morphBundle.MsaRA, "First bundle: msa is not null"); Assert.IsNotNull(morphBundle.InflTypeRA, "First bundle: infl type is not null"); }
public void LexEntryInflTypeTwoAnalyses() { IWfiWordform creb = CheckAnalysisSize("crebTEST", 0, true); ILexDb ldb = Cache.LanguageProject.LexDbOA; ParseResult result = null; UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () => { // Verb creb which is a past tense, plural irregularly inflected form of 'believe' and also 'seek' // with automatically generated null Tense slot and an automatically generated null Number slot filler // (This is not supposed to be English, in case you're wondering....) ILexEntryInflType pastTenseLexEntryInflType = m_lexEntryInflTypeFactory.Create(); ILexEntryInflType pluralTenseLexEntryInflType = m_lexEntryInflTypeFactory.Create(); Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pastTenseLexEntryInflType); Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pluralTenseLexEntryInflType); ILexEntry believeV = m_entryFactory.Create(); IMoStemAllomorph believeVForm = m_stemAlloFactory.Create(); believeV.AlternateFormsOS.Add(believeVForm); believeVForm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeString("believeVTEST", m_vernacularWS.Handle); IMoStemMsa believeVMsa = m_stemMsaFactory.Create(); believeV.MorphoSyntaxAnalysesOC.Add(believeVMsa); ILexSense believeVSense = m_senseFactory.Create(); believeV.SensesOS.Add(believeVSense); believeVSense.MorphoSyntaxAnalysisRA = believeVMsa; ILexEntry seekV = m_entryFactory.Create(); IMoStemAllomorph seekVForm = m_stemAlloFactory.Create(); believeV.AlternateFormsOS.Add(seekVForm); seekVForm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeString("seekVTEST", m_vernacularWS.Handle); IMoStemMsa seekVMsa = m_stemMsaFactory.Create(); seekV.MorphoSyntaxAnalysesOC.Add(seekVMsa); ILexSense seekVSense = m_senseFactory.Create(); seekV.SensesOS.Add(seekVSense); seekVSense.MorphoSyntaxAnalysisRA = seekVMsa; ILexEntry crebV = m_entryFactory.Create(); IMoStemAllomorph crebVForm = m_stemAlloFactory.Create(); crebV.AlternateFormsOS.Add(crebVForm); crebVForm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeString("crebVTEST", m_vernacularWS.Handle); ILexEntryRef lexEntryref = m_lexEntryRefFactory.Create(); crebV.EntryRefsOS.Add(lexEntryref); lexEntryref.ComponentLexemesRS.Add(believeV); lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType); lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType); lexEntryref = m_lexEntryRefFactory.Create(); crebV.EntryRefsOS.Add(lexEntryref); lexEntryref.ComponentLexemesRS.Add(seekV); lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType); lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType); ILexEntry nullPast = m_entryFactory.Create(); IMoAffixAllomorph nullPastForm = m_afxAlloFactory.Create(); nullPast.AlternateFormsOS.Add(nullPastForm); nullPastForm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeString("nullPASTTEST", m_vernacularWS.Handle); IMoInflAffMsa nullPastMsa = m_inflAffMsaFactory.Create(); nullPast.MorphoSyntaxAnalysesOC.Add(nullPastMsa); ILexEntry nullPlural = m_entryFactory.Create(); IMoAffixAllomorph nullPluralForm = m_afxAlloFactory.Create(); nullPlural.AlternateFormsOS.Add(nullPluralForm); nullPluralForm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeString("nullPLURALTEST", m_vernacularWS.Handle); IMoInflAffMsa nullPluralMsa = m_inflAffMsaFactory.Create(); nullPlural.MorphoSyntaxAnalysesOC.Add(nullPluralMsa); result = new ParseResult(new[] { new ParseAnalysis(new[] { new ParseMorph(crebVForm, MorphServices.GetMainOrFirstSenseOfVariant(crebV.EntryRefsOS[1]).MorphoSyntaxAnalysisRA, (ILexEntryInflType)crebV.EntryRefsOS[1].VariantEntryTypesRS[0]) }), new ParseAnalysis(new[] { new ParseMorph(crebVForm, MorphServices.GetMainOrFirstSenseOfVariant(crebV.EntryRefsOS[0]).MorphoSyntaxAnalysisRA, (ILexEntryInflType)crebV.EntryRefsOS[0].VariantEntryTypesRS[0]) }) }); }); m_filer.ProcessParse(creb, ParserPriority.Low, result); ExecuteIdleQueue(); CheckAnalysisSize("crebTEST", 2, false); foreach (var analysis in creb.AnalysesOC) { Assert.AreEqual(1, analysis.MorphBundlesOS.Count, "Expected only 1 morph in the analysis"); var morphBundle = analysis.MorphBundlesOS.ElementAt(0); Assert.IsNotNull(morphBundle.Form, "First bundle: form is not null"); Assert.IsNotNull(morphBundle.MsaRA, "First bundle: msa is not null"); Assert.IsNotNull(morphBundle.InflTypeRA, "First bundle: infl type is not null"); } }