private FlexEntry MakeFwEntryFromWeSayEntry(WeSay.LexicalModel.LexEntry weSayEntry) { //MoStemMsa msa = new MoStemMsa(); //// I wouldn't even *pretend* to understand this weirdness. Is 'dummy' a technical term? //DummyGenericMSA dmsa = DummyGenericMSA.Create(msa); //MoMorphType mmt = _flexMorphTypes.Item(MoMorphType.kmtStem); //LexEntry entry = LexEntry.CreateEntry(_cache, EntryType.ketMajorEntry, mmt, weSayEntry.LexicalForm, null, weSayEntry.Gloss, dmsa); FlexEntry entry = new FlexEntry(); _cache.LangProject.LexDbOA.EntriesOC.Add(entry); //(_cache, EntryType.ketMajorEntry, mmt, weSayEntry.LexicalForm, null, weSayEntry.Gloss, dmsa); entry.Guid = weSayEntry.Guid; entry.LexemeFormOA = new MoStemAllomorph(); // entry.LexemeFormOA.Form.VernacularDefaultWritingSystem // = weSayEntry.LexicalForm; //LexSense.CreateSense(entry, dmsa, weSayEntry.Gloss); MakeSense(weSayEntry, entry); // if (Merged != null) // { // Merged.Invoke(this, "Added"); // } return(entry); }
public override void FixtureSetup() { string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FwSourceDirectory, @"common\controls\detailcontrols\detailcontrolstests"); Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>(); keyAttrs["layout"] = new string[] {"class", "type", "name" }; keyAttrs["group"] = new string[] {"label"}; keyAttrs["part"] = new string[] {"ref"}; string configurationDir = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory, @"Language Explorer\Configuration"); m_stringTable = new SIL.Utils.StringTable(configurationDir); m_layouts = new Inventory(new string[] {partDirectory}, "*Layouts.xml", "/LayoutInventory/*", keyAttrs); keyAttrs = new Dictionary<string, string[]>(); keyAttrs["part"] = new string[] {"id"}; m_parts = new Inventory(new string[] {partDirectory}, "*Parts.xml", "/PartInventory/bin/*", keyAttrs); m_cache = FdoCache.Create("TestLangProj"); m_entry = new LexEntry(); m_cache.LangProject.LexDbOA.EntriesOC.Add(m_entry); m_entry.CitationForm.VernacularDefaultWritingSystem = "rubbish"; // We set both alternatives because currently the default part for Bibliography uses vernacular, // but I think this will probably get fixed. Anyway, this way the test is robust. m_entry.Bibliography.SetAnalysisDefaultWritingSystem("My rubbishy bibliography"); m_entry.Bibliography.SetVernacularDefaultWritingSystem("My rubbishy bibliography"); }
private static void MakeSense(WeSay.LexicalModel.LexEntry weSayEntry, FlexEntry flexEntry) { FlexSense sense = new FlexSense(); flexEntry.SensesOS.Append(sense); // sense.Gloss.AnalysisDefaultWritingSystem = weSayEntry.Senses[0]; // if (weSayEntry.Example != null && weSayEntry.Example.Length >0) // { // LexExampleSentence example = new LexExampleSentence(); // sense.ExamplesOS.Append(example); // example.Example.VernacularDefaultWritingSystem.Text = weSayEntry.Example; // } }
/* * /// <summary> * /// Import a single entry selected out of a Lift file. For test use. * /// </summary> * /// <param name="path"></param> * /// <param name="xpath"></param> * /// <returns>either the entry which was created were merged into</returns> * public LexEntry ImportOneWeSayEntry(string path, string xpath) * { * XmlDocument doc = new XmlDocument(); * doc.Load(path); * return ImportOneEntry(doc.SelectSingleNode(xpath)); * } */ internal ILexEntry MergeInOneEntry(LexEntry wsEntry) { ILexEntry flexEntry = null; Guid guid = wsEntry.Guid; int hvo = _cache.GetIdFromGuid(guid); if (hvo > 0) { flexEntry = FlexEntry.CreateFromDBObject(_cache, hvo); // if (((LexSense)flexEntry.SensesOS[0]).Gloss.AnalysisDefaultWritingSystem != weSayEntry.Gloss) // MergeAnalysisString((flexEntry.SensesOS[0]).Gloss,weSayEntry.Gloss); // MergeVernacularString(flexEntry.LexemeFormOA.Form,weSayEntry.LexicalForm); // MergeVernacularString(((ILexExampleSentence)((LexSense)flexEntry.SensesOS[0]).ExamplesOS[0]).Example,weSayEntry.Example); } else { flexEntry = MakeFwEntryFromWeSayEntry(wsEntry); } return(flexEntry); }
public void HomographCollectionWorks() { CheckDisposed(); LexEntry lme = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme); string sLexForm = "unitTestLexemeForm"; lme.LexemeFormOA = new MoStemAllomorph(); lme.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; // Make sure it has 2 other homographs. LexEntry lme2 = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme2); lme2.LexemeFormOA = new MoStemAllomorph(); lme2.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; LexEntry lme3 = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme3); lme3.LexemeFormOA = new MoStemAllomorph(); lme3.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; string homographForm = lme.HomographForm; Assert.AreEqual(sLexForm, homographForm, "Lexeme form and homograph form are not the same."); // These two tests check lexeme forms of the two/three entries. // This version of the CollectHomographs method will not include the lme entry. List<ILexEntry> rgHomographs = lme.CollectHomographs(homographForm, lme.Hvo); Assert.AreEqual(rgHomographs.Count, 2, "Wrong homograph count."); // This version of the CollectHomographs method will not include the lme entry. rgHomographs = lme.CollectHomographs(); Assert.AreEqual(rgHomographs.Count, 2, "Wrong homograph count."); // This version of the CollectHomographs method will include the lme entry. rgHomographs = lme.CollectHomographs(homographForm, 0); Assert.AreEqual(rgHomographs.Count, 3, "Wrong homograph count."); // Now set the citation form to something different than sLexForm. string sCitationForm = "unitTestCitationForm"; lme.CitationForm.VernacularDefaultWritingSystem = sCitationForm; homographForm = lme.HomographForm; Assert.AreEqual(sCitationForm, homographForm, "Citation form and homograph form are not the same."); // This version of the CollectHomographs method will include the lme entry. rgHomographs = lme.CollectHomographs(homographForm, 0); Assert.AreEqual(rgHomographs.Count, 1, "Wrong homograph count."); // This version of the CollectHomographs method will include the lme entry. rgHomographs = lme2.CollectHomographs(sLexForm, 0); Assert.AreEqual(rgHomographs.Count, 2, "Wrong homograph count."); }
public void LexemeFormStemAllomorphIsRelevant() { LexEntry stemEntry = new LexEntry (); Cache.LangProject.LexDbOA.EntriesOC.Add(stemEntry); MoStemAllomorph stemAllomorph = new MoStemAllomorph(); stemEntry.LexemeFormOA = stemAllomorph; Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant when there is no morph type."); foreach (IMoMorphType mmt in Cache.LangProject.LexDbOA.MorphTypesOA.PossibilitiesOS) { stemAllomorph.MorphTypeRA = mmt; switch (mmt.Guid.ToString()) { case MoMorphType.kguidMorphRoot: Assert.IsTrue(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should be relevant for a root morph type."); break; case MoMorphType.kguidMorphBoundRoot: Assert.IsTrue(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should be relevant for a bound root morph type."); break; case MoMorphType.kguidMorphStem: Assert.IsTrue(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should be relevant for a stem morph type."); break; case MoMorphType.kguidMorphBoundStem: Assert.IsTrue(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should be relevant for a bound stem morph type."); break; case MoMorphType.kguidMorphCircumfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a circumfix morph type."); break; case MoMorphType.kguidMorphDiscontiguousPhrase: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a discontiguous phrasemorph type."); break; case MoMorphType.kguidMorphClitic: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a clitic morph type."); break; case MoMorphType.kguidMorphEnclitic: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for an enclitic morph type."); break; case MoMorphType.kguidMorphInfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for an infix morph type."); break; case MoMorphType.kguidMorphInfixingInterfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for an infixing interfix morph type."); break; case MoMorphType.kguidMorphParticle: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a particle morph type."); break; case MoMorphType.kguidMorphPhrase: Assert.IsTrue(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should be relevant for a phrase morph type."); break; case MoMorphType.kguidMorphPrefix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a prefix morph type."); break; case MoMorphType.kguidMorphPrefixingInterfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a prefixing interfix morph type."); break; case MoMorphType.kguidMorphProclitic: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a proclitic morph type."); break; case MoMorphType.kguidMorphSimulfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a simulfix morph type."); break; case MoMorphType.kguidMorphSuffix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a suffix morph type."); break; case MoMorphType.kguidMorphSuffixingInterfix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a suffixing interfix morph type."); break; case MoMorphType.kguidMorphSuprafix: Assert.IsFalse(stemAllomorph.IsFieldRelevant((int)MoStemAllomorph.MoStemAllomorphTags.kflidStemName), "Stem allomorph stem name should not be relevant for a suprafix morph type."); break; } } }
private void DoTestLexemeFormAffixAllomorphIsRelevant() { LexEntry affixEntry = new LexEntry (); Cache.LangProject.LexDbOA.EntriesOC.Add(affixEntry); MoAffixAllomorph affixAllomorph = new MoAffixAllomorph(); affixEntry.LexemeFormOA = affixAllomorph; Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPosition), "Affix allomorph position should not be relevant in an underlying form."); Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPhoneEnv), "Affix allomorph environment should not be relevant in an underlying form."); MoInflAffMsa iamsa = new MoInflAffMsa(); affixEntry.MorphoSyntaxAnalysesOC.Add(iamsa); Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixFormTags.kflidInflectionClasses), "Affix inflection class(es) should not be relevant in an underlying form."); }
private void AddMorphItemsToComboList() { ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); ITsString tssHead = null; MorphItem miPrev = new MorphItem(); m_morphItems.Sort(); foreach (MorphItem mi in m_morphItems) { ITsString tssToDisplay = null; int hvoPrimary = 0; // the key hvo associated with the combo item. tisb.Clear(); int hvoLexEntry = m_caches.MainCache.GetOwnerOfObject(mi.m_hvoMorph); ILexEntry le = new LexEntry(m_caches.MainCache, hvoLexEntry); tssHead = tisb.GetString(); if (mi.m_hvoSense > 0) { int hvoSense = mi.m_hvoSense; tisb = tssHead.GetIncBldr(); tisb.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsAnal); tisb.Append(" "); ITsString tssSense = StringUtils.MakeTss(mi.m_nameSense, m_caches.MainCache.DefaultAnalWs); tisb.AppendTsString(tssSense); tisb.Append(", "); string sPos = mi.m_nameMsa; if (sPos == null) sPos = ITextStrings.ksQuestions; // was "??", not "???" tisb.Append(sPos); tisb.Append(", "); // append lex entry form info tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsVern); tisb.AppendTsString(mi.m_name); tssToDisplay = tisb.GetString(); hvoPrimary = mi.m_hvoSense; tisb.Clear(); } else { hvoPrimary = mi.m_hvoMorph; // mi.m_hvoSense == 0 // Make a comboList item for adding a new sense to the LexEntry if (miPrev.m_hvoMorph != 0 && mi.m_hvoMorph == miPrev.m_hvoMorph && miPrev.m_hvoSense > 0) { // "Add New Sense..." // the comboList has already added selections for senses and lexEntry form // thus establishing the LexEntry the user may wish to "Add New Sense..." to. tisb.Clear(); tisb.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsUser); tisb.Append(ITextStrings.ksAddNewSense_); tssToDisplay = tisb.GetString(); } else { // "Add New Sense for {0}" // (EricP) This path means the current form matches an entry that (strangely enough) // doesn't have any senses so we need to add the LexEntry form into the string, // so the user knows what Entry they'll be adding the new sense to. Debug.Assert(le.SensesOS.Count == 0, "Expected LexEntry to have no senses."); string sFmt = ITextStrings.ksAddNewSenseForX_; tisb.Clear(); tisb.SetIntPropValues( (int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsUser); tisb.Append(sFmt); ITsString tss = tisb.GetString(); int ich = sFmt.IndexOf("{0}"); if (ich >= 0) { ITsStrBldr tsbT = tss.GetBldr(); tsbT.ReplaceTsString(ich, ich + "{0}".Length, mi.m_name); tss = tsbT.GetString(); } tssToDisplay = tss; } } // keep track of the previous MorphItem to track context. m_comboList.Items.Add(new MorphComboItem(mi, tssToDisplay, new EventHandler(HandleSelectMorphComboItem), hvoPrimary)); miPrev = mi; } SyncItemsToMorphItems(); }
public void FromPartsOfSpeechIsRelevant() { CheckDisposed(); LexEntry entry = new LexEntry(); Cache.LangProject.LexDbOA.EntriesOC.Add(entry); MoStemAllomorph allomorph = new MoStemAllomorph(); entry.AlternateFormsOS.Append(allomorph); MoStemMsa msa = new MoStemMsa(); entry.MorphoSyntaxAnalysesOC.Add(msa); SetMorphType(allomorph, MoMorphType.kguidMorphStem); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphProclitic); Assert.IsTrue(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should now be relevant since the entry has a proclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphEnclitic); Assert.IsTrue(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should now be relevant since the entry has an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphClitic); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphBoundRoot); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphBoundStem); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphCircumfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphDiscontiguousPhrase); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphInfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphInfixingInterfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphParticle); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphPhrase); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphPrefix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphPrefixingInterfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphRoot); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphSimulfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphSuffix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphSuffixingInterfix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); SetMorphType(allomorph, MoMorphType.kguidMorphSuprafix); Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech), "FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic."); }
/// <summary> /// creates a variant entry from this (main) entry using its lexemeForm information, /// and links the variant to the given componentLexeme entry via /// EntryRefs.ComponentLexemes /// </summary> /// <param name="variantType">the type of the new variant</param> /// <param name="componentLexeme">the entry or sense of which the new variant entry is a variant</param> /// <param name="tssVariantLexemeForm">the lexeme form of the new variant</param> /// <returns>the new variant entry reference</returns> internal ILexEntryRef CreateVariantEntryAndBackRef(IVariantComponentLexeme componentLexeme, ILexEntryType variantType, ITsString tssVariantLexemeForm) { using (new UndoRedoTaskHelper(Cache, Strings.ksUndoCreateVariantEntry, Strings.ksRedoCreateVariantEntry)) { ILexEntry variantEntry = new LexEntry(); Cache.LangProject.LexDbOA.EntriesOC.Add(variantEntry); if (this.LexemeFormOA is IMoAffixAllomorph) variantEntry.LexemeFormOA = new MoAffixAllomorph(); else variantEntry.LexemeFormOA = new MoStemAllomorph(); if (this.LexemeFormOA != null) variantEntry.LexemeFormOA.MorphTypeRAHvo = this.LexemeFormOA.MorphTypeRAHvo; if (tssVariantLexemeForm != null) variantEntry.LexemeFormOA.FormMinusReservedMarkers = tssVariantLexemeForm; (variantEntry as LexEntry).UpdateHomographNumbersAccountingForNewEntry(); return (variantEntry as LexEntry).MakeVariantOf(componentLexeme, variantType); } }
public void HomographValidationWorks() { CheckDisposed(); LexEntry lme = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme); string sLexForm = "unitTestLexemeForm"; lme.LexemeFormOA = new MoStemAllomorph(); lme.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; // Make sure it has 2 homographs. LexEntry lme2 = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme2); lme2.LexemeFormOA = new MoStemAllomorph(); lme2.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; LexEntry lme3 = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(lme3); lme3.LexemeFormOA = new MoStemAllomorph(); lme3.LexemeFormOA.Form.VernacularDefaultWritingSystem = sLexForm; string homographForm = lme.HomographForm; Assert.AreEqual(sLexForm, homographForm, "lexeme form and homograph form are not the same."); // This version of the CollectHomographs will not include the lme entry. List<ILexEntry> rgHomographs = lme.CollectHomographs(); Assert.AreEqual(rgHomographs.Count, 2, "Wrong homograph count."); // Reset all the homograph numbers to zero. foreach (ILexEntry le in rgHomographs) { le.HomographNumber = 0; } // Restore valid homograph numbers by calling ValidateHomographNumbers. bool fOk = LexEntry.ValidateExistingHomographs(rgHomographs); Assert.IsFalse(fOk, "Validation had to renumber homographs"); int n = 1; foreach (ILexEntry le in rgHomographs) { Assert.AreEqual(n++, le.HomographNumber, "Wrong homograph number found."); } // If we get here without asserting, the renumbering worked okay. fOk = LexEntry.ValidateExistingHomographs(rgHomographs); Assert.IsTrue(fOk, "Validation should not have to renumber this time."); // Reset all the homograph numbers by multiplying each by 2. foreach (ILexEntry le in rgHomographs) { le.HomographNumber *= 2; } // Restore valid homograph numbers by calling ValidateHomographNumbers. fOk = LexEntry.ValidateExistingHomographs(rgHomographs); Assert.IsFalse(fOk, "Validation had to renumber homographs"); n = 1; foreach (ILexEntry le in rgHomographs) { Assert.AreEqual(n++, le.HomographNumber, "Wrong homograph number found."); } }
public void InflectionClassIsRelevant() { CheckDisposed(); LexEntry entry = new LexEntry (); Cache.LangProject.LexDbOA.EntriesOC.Add(entry); MoAffixAllomorph allomorph = new MoAffixAllomorph(); entry.AlternateFormsOS.Append(allomorph); Assert.IsFalse(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses), "InflectionClass should not be relevant until an inflectional affix MSA with a category has been added."); MoInflAffMsa orange = new MoInflAffMsa(); entry.MorphoSyntaxAnalysesOC.Add(orange); Assert.IsFalse(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses), "InflectionClass should not be relevant until an inflectional affix MSA with a category has been added."); PartOfSpeech pos = new PartOfSpeech(); Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Append(pos); orange.PartOfSpeechRA = pos; Assert.IsTrue(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses), "InflectionClass should now be relevant since an inflectional affix MSA with a category has been added."); }
[Test] public void ChangedEntryFound() { Guid g = Guid.NewGuid(); IdentifyingInfo idInfo = CreateFullIdInfo(g); LexEntry e = new LexEntry(); this.Cache.LangProject.LexDbOA.EntriesOC.Add(e); e.Guid = g; e.DateCreated = idInfo.creationTime; e.DateModified = new DateTime(e.DateCreated.Ticks + 100); ILexEntry found = _merger.GetOrMakeEntry(idInfo); Assert.AreEqual(idInfo.creationTime, found.DateCreated); }
public void UnchangedEntryPruned() { LexEntry e = new LexEntry(); this.Cache.LangProject.LexDbOA.EntriesOC.Add(e); IdentifyingInfo idInfo; idInfo.id = e.Guid.ToString(); idInfo.creationTime = e.DateCreated; idInfo.modificationTime = e.DateModified; ILexEntry m= _merger.GetOrMakeEntry(idInfo); Assert.IsNull(m);//pruned //Assert.AreEqual("", _log); }
/// <summary></summary> public void Setup(object o, IRecordListUpdater rlu) { CheckDisposed(); Debug.Assert(o != null && o is LexEntry); m_le = o as LexEntry; Debug.Assert(m_le != null); m_originalHomographForm = m_le.HomographForm; m_originalMorphType = m_le.MorphType; if (rlu != null) { m_rlu = rlu; m_rlu.RecordChangeHandler = this; } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { if (Disposed != null) Disposed(this, new EventArgs()); // Dispose managed resources here. if (m_rlu != null) m_rlu.RecordChangeHandler = null; } // Dispose unmanaged resources here, whether disposing is true or false. m_le = null; m_originalHomographForm = null; m_rlu = null; m_isDisposed = true; }
[Test] public void EntryWithIncomingUnspecifiedModTimeNotPruned() { LexEntry e = new LexEntry(); this.Cache.LangProject.LexDbOA.EntriesOC.Add(e); IdentifyingInfo idInfo; idInfo.id = e.Guid.ToString(); idInfo.creationTime = e.DateCreated; idInfo.modificationTime = DateTime.Parse(e.DateModified.ToString(LiftIO.IdentifyingInfo.LiftDateOnlyFormat)); ILexEntry m = _merger.GetOrMakeEntry(idInfo); Assert.IsNotNull(m);//not pruned }
public void CitationFormWithAffixType() { CheckDisposed(); LexEntry entry = new LexEntry (); Cache.LangProject.LexDbOA.EntriesOC.Add(entry); string sULForm = "abc"; entry.CitationForm.VernacularDefaultWritingSystem = sULForm; MoAffixAllomorph allomorph = new MoAffixAllomorph(); entry.LexemeFormOA = allomorph; Set<ICmPossibility> morphTypes = Cache.LangProject.LexDbOA.MorphTypesOA.ReallyReallyAllPossibilities; foreach (IMoMorphType mmt in morphTypes) { allomorph.MorphTypeRAHvo = mmt.Hvo; switch (MoMorphType.FindMorphTypeIndex(Cache, mmt)) { case MoMorphType.kmtBoundRoot: Assert.AreEqual("*" + sULForm, entry.CitationFormWithAffixType, "Expected * prefix for bound root with CF"); break; case MoMorphType.kmtBoundStem: Assert.AreEqual("*" + sULForm, entry.CitationFormWithAffixType, "Expected * prefix for bound stem with CF"); break; case MoMorphType.kmtCircumfix: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for circumfix"); break; case MoMorphType.kmtClitic: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for clitic"); break; case MoMorphType.kmtEnclitic: Assert.AreEqual("=" + sULForm, entry.CitationFormWithAffixType, "Expected = prefix for enclitic"); break; case MoMorphType.kmtInfix: Assert.AreEqual("-" + sULForm + "-", entry.CitationFormWithAffixType, "Expected - prefix and - postfix for infix"); break; case MoMorphType.kmtInfixingInterfix: Assert.AreEqual("-" + sULForm + "-", entry.CitationFormWithAffixType, "Expected - prefix and - postfix for infixing interfix"); break; case MoMorphType.kmtMixed: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for Mixed"); break; case MoMorphType.kmtParticle: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for particle"); break; case MoMorphType.kmtPrefix: Assert.AreEqual(sULForm + "-", entry.CitationFormWithAffixType, "Expected - postfix for prefix"); break; case MoMorphType.kmtPrefixingInterfix: Assert.AreEqual(sULForm + "-", entry.CitationFormWithAffixType, "Expected - postfix for prefixing interfix"); break; case MoMorphType.kmtProclitic: Assert.AreEqual(sULForm + "=", entry.CitationFormWithAffixType, "Expected = postfix for proclitic"); break; case MoMorphType.kmtRoot: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for root"); break; case MoMorphType.kmtSimulfix: Assert.AreEqual("=" + sULForm + "=", entry.CitationFormWithAffixType, "Expected = prefix and = postfix for simulfix"); break; case MoMorphType.kmtStem: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for stem"); break; case MoMorphType.kmtSuffix: Assert.AreEqual("-" + sULForm, entry.CitationFormWithAffixType, "Expected - prefix for suffix"); break; case MoMorphType.kmtSuffixingInterfix: Assert.AreEqual("-" + sULForm, entry.CitationFormWithAffixType, "Expected - prefix for suffixing interfix"); break; case MoMorphType.kmtSuprafix: Assert.AreEqual("~" + sULForm + "~", entry.CitationFormWithAffixType, "Expected ~ prefix and ~ postfix for suprafix"); break; case MoMorphType.kmtPhrase: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for phrase"); break; case MoMorphType.kmtDiscontiguousPhrase: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for discontiguous phrase"); break; case MoMorphType.kmtUnknown: Assert.AreEqual(sULForm, entry.CitationFormWithAffixType, "Expected no prefix or postfix for Unknown"); break; } } }
public void ParserDataChanges() { XmlNode node; #if !ShowDumpResult m_fxtResult.Save(Path.Combine(System.IO.Path.GetTempPath(), "TestFxtUpdateBefore.xml")); #endif // ------------- // Make data changes // ------------- // Make a change to stem allomorph ILangProject lp = Cache.LangProject; ILexDb lexdb = lp.LexDbOA; int[] aiLexEntries = lexdb.EntriesOC.HvoArray; int hvoLexEntry = aiLexEntries[0]; ILexEntry lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry; Assert.IsNotNull(lexEntry); IMoStemAllomorph stemAllomorph = lexEntry.LexemeFormOA as IMoStemAllomorph; Assert.IsNotNull(stemAllomorph); stemAllomorph.Form.SetAlternative("bili-changed", Cache.DefaultVernWs); int hvoStemAllomorph = stemAllomorph.Hvo; stemAllomorph.IsAbstract = true; // Delete an affix allomorph hvoLexEntry = aiLexEntries[3]; lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry; Assert.IsNotNull(lexEntry); IMoAffixAllomorph affixAllomorph = lexEntry.AlternateFormsOS[1] as IMoAffixAllomorph; Assert.IsNotNull(affixAllomorph); int hvoAffixAllomorph = affixAllomorph.Hvo; lexEntry.AlternateFormsOS.RemoveAt(1); Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, 1, 0, 1); // Add a new affix allomorph IMoAffixAllomorph newAffixAllomorph = new MoAffixAllomorph(); lexEntry.AlternateFormsOS.Append(newAffixAllomorph); newAffixAllomorph.Form.SetAlternative("him-new", Cache.DefaultVernWs); int hvoNewAffixAllomorph = newAffixAllomorph.Hvo; Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, lexEntry.AlternateFormsOS.Count - 1, 1, 0); // add a compound rule IMoMorphData morphData = lp.MorphologicalDataOA; IMoEndoCompound compRuleNew = new MoEndoCompound(); morphData.CompoundRulesOS.Append(compRuleNew); string sCompRuleName = "new compound rule"; compRuleNew.Name.AnalysisDefaultWritingSystem = sCompRuleName; compRuleNew.HeadLast = true; int hvoPOS = lp.PartsOfSpeechOA.PossibilitiesOS.FirstItem.Hvo; compRuleNew.LeftMsaOA.PartOfSpeechRAHvo = hvoPOS; compRuleNew.RightMsaOA.PartOfSpeechRAHvo = hvoPOS; compRuleNew.OverridingMsaOA.PartOfSpeechRAHvo = hvoPOS; // Change compound rule description const string ksCompRuleDescription = "new description"; compRuleNew.Description.AnalysisDefaultWritingSystem.Text = ksCompRuleDescription; Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidCompoundRules, morphData.CompoundRulesOS.Count - 1, 1, 0); // delete a compound rule IMoExoCompound compRuleDeleted = morphData.CompoundRulesOS.FirstItem as IMoExoCompound; int hvoCompRuleDeletedLeftMsa = compRuleDeleted.LeftMsaOAHvo; int hvoCompRuleDeletedRightMsa = compRuleDeleted.RightMsaOAHvo; int hvoCompRuleDeletedToMsa = compRuleDeleted.ToMsaOAHvo; morphData.CompoundRulesOS.RemoveAt(0); // add an ad hoc co-prohibition IMoAlloAdhocProhib alloAdHoc = new MoAlloAdhocProhib(); morphData.AdhocCoProhibitionsOC.Add(alloAdHoc); alloAdHoc.Adjacency = 2; alloAdHoc.FirstAllomorphRAHvo = hvoNewAffixAllomorph; alloAdHoc.RestOfAllosRS.Append(hvoNewAffixAllomorph); // change a "rest of allos" in extant ad hoc co-prohibition int[] hvosAdHocProhibs = morphData.AdhocCoProhibitionsOC.HvoArray; IMoAlloAdhocProhib alloAdHocOld = CmObject.CreateFromDBObject(Cache, hvosAdHocProhibs[9]) as IMoAlloAdhocProhib; IMoAffixAllomorph alloAdHicOldFirstRestOfAllos = alloAdHocOld.RestOfAllosRS.FirstItem as IMoAffixAllomorph; IMoAffixAllomorph affixAllomorph2 = lexEntry.AlternateFormsOS[0] as IMoAffixAllomorph; alloAdHocOld.RestOfAllosRS.Append(affixAllomorph2); alloAdHocOld.RestOfAllosRS.RemoveAt(0); alloAdHocOld.Adjacency = 2; //Add a new productivity restriction ICmPossibilityList prodRestricts = morphData.ProdRestrictOA; ICmPossibility prodRestriction = new CmPossibility(); prodRestricts.PossibilitiesOS.Append(prodRestriction); string sNewProdRestrictName = "new exception feature"; prodRestriction.Name.AnalysisDefaultWritingSystem = sNewProdRestrictName; Cache.PropChanged(null, PropChangeType.kpctNotifyAll, prodRestricts.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, prodRestricts.PossibilitiesOS.Count - 1, 1, 0); // Change a phonological enviroment string representation IPhPhonData phonData = lp.PhonologicalDataOA; IPhEnvironment env = phonData.EnvironmentsOS.FirstItem; const string ksEnvStringRep = "/ _ [C] [V] a e i o u"; env.StringRepresentation.Text = ksEnvStringRep; // Add a new phonological enviroment string representation IPhEnvironment envNew = new PhEnvironment(); phonData.EnvironmentsOS.Append(envNew); envNew.StringRepresentation.Text = "/ _ m"; int hvoPhonData = phonData.Hvo; Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoPhonData, (int)PhPhonData.PhPhonDataTags.kflidEnvironments, phonData.EnvironmentsOS.Count - 1, 1, 0); // Change parser parameters (to test Unicode string field type) string sParserParameters = morphData.ParserParameters.Trim(); int i = sParserParameters.IndexOf("</ParserParameters>"); string sNewParserParameters = sParserParameters.Substring(0, i) + "<HermitCrab><stuff>1</stuff></HermitCrab>" + "</ParserParameters>"; morphData.ParserParameters = sNewParserParameters; // Delete a lex entry int[] hvosEntries = lexdb.EntriesOC.HvoArray; int hvoEntryDeleted = hvosEntries[hvosEntries.Length - 4]; ILexEntry entryDeleted = CmObject.CreateFromDBObject(Cache, hvoEntryDeleted) as ILexEntry; int hvoEntryDeletedLexemeForm = entryDeleted.LexemeFormOAHvo; int[] hvosEntryDeletedAlternateForms = entryDeleted.AlternateFormsOS.HvoArray; int[] hvosEntryDeletedMSAs = entryDeleted.MorphoSyntaxAnalysesOC.HvoArray; int[] hvosEntryDeletedSenses = entryDeleted.SensesOS.HvoArray; //entryDeleted.LexemeFormOA.DeleteUnderlyingObject(); lexdb.EntriesOC.Remove(hvosEntries[hvosEntries.Length - 4]); //Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidParserParameters, 0, 0, 0); // Create a new lex entry ILexEntry entryNew = new LexEntry(); lexdb.EntriesOC.Add(entryNew); IMoAffixAllomorph alloNew = new MoAffixAllomorph(); entryNew.LexemeFormOA = alloNew; string sNewAlloForm = "dem"; alloNew.Form.VernacularDefaultWritingSystem = sNewAlloForm; alloNew.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix)); IMoAffixAllomorph alloNew2 = new MoAffixAllomorph(); entryNew.AlternateFormsOS.Append(alloNew2); string sNewAlloForm2 = "den"; alloNew2.Form.VernacularDefaultWritingSystem = sNewAlloForm2; alloNew2.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix)); Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms, entryNew.AlternateFormsOS.Count - 1, 1, 0); ILexSense sense = new LexSense(); entryNew.SensesOS.Append(sense); string sGloss = "MeToo"; sense.Gloss.AnalysisDefaultWritingSystem = sGloss; IMoInflAffMsa inflAffixMsa = new MoInflAffMsa(); entryNew.MorphoSyntaxAnalysesOC.Add(inflAffixMsa); sense.MorphoSyntaxAnalysisRA = inflAffixMsa; int[] hvosPOSes = lp.PartsOfSpeechOA.PossibilitiesOS.HvoArray; int hvoVerb = hvosPOSes[12]; inflAffixMsa.PartOfSpeechRAHvo = hvoVerb; IPartOfSpeech pos = CmObject.CreateFromDBObject(Cache, hvoVerb) as IPartOfSpeech; int hvoSlot = pos.AffixSlotsOC.HvoArray[2]; inflAffixMsa.SlotsRC.Add(hvoSlot); Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidSenses, entryNew.SensesOS.Count - 1, 1, 0); // Add an inflectional template int[] hvoVerbSubCats = pos.SubPossibilitiesOS.HvoArray; int hvoIntransVerb = hvoVerbSubCats[2]; IPartOfSpeech posVI = CmObject.CreateFromDBObject(Cache, hvoIntransVerb) as IPartOfSpeech; IMoInflAffixTemplate affixTemplate = new MoInflAffixTemplate(); posVI.AffixTemplatesOS.Append(affixTemplate); affixTemplate.Name.AnalysisDefaultWritingSystem = "derived verb"; affixTemplate.Final = false; affixTemplate.SuffixSlotsRS.Append(hvoSlot); Cache.PropChanged(null, PropChangeType.kpctNotifyAll, posVI.Hvo, (int)PartOfSpeech.PartOfSpeechTags.kflidAffixTemplates, posVI.AffixTemplatesOS.Count - 1, 1, 0); // add a phonological feature IFsClosedFeature consFeat = new FsClosedFeature(); Cache.LangProject.PhFeatureSystemOA.FeaturesOC.Add(consFeat); consFeat.Name.AnalysisDefaultWritingSystem = "consonantal"; consFeat.Abbreviation.AnalysisDefaultWritingSystem = "cons"; IFsSymFeatVal consPlus = new FsSymFeatVal(); consFeat.ValuesOC.Add(consPlus); consPlus.SimpleInit("+", "positive"); IFsSymFeatVal consMinus = new FsSymFeatVal(); consFeat.ValuesOC.Add(consMinus); consMinus.SimpleInit("-", "negative"); IFsFeatStrucType fsType = null; if (Cache.LangProject.PhFeatureSystemOA.TypesOC.Count == 0) { fsType = new FsFeatStrucType(); Cache.LangProject.PhFeatureSystemOA.TypesOC.Add(fsType); fsType.Abbreviation.AnalysisDefaultWritingSystem = "Phon"; } else { foreach (IFsFeatStrucType type in Cache.LangProject.PhFeatureSystemOA.TypesOC) { fsType = type; break; } } fsType.FeaturesRS.Append(consFeat); // add a feature-based NC IPhNCFeatures featNC = new PhNCFeatures(); Cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Append(featNC); featNC.Name.AnalysisDefaultWritingSystem = "Consonants (Features)"; featNC.Abbreviation.AnalysisDefaultWritingSystem = "CF"; IFsFeatStruc fs = new FsFeatStruc(); featNC.FeaturesOA = fs; IFsClosedValue val = fs.FindOrCreateClosedValue(consFeat.Hvo); val.FeatureRA = consFeat; val.ValueRA = consPlus; featNC.NotifyNew(); // add phonological rule IPhRegularRule regRule = new PhRegularRule(); Cache.LangProject.PhonologicalDataOA.PhonRulesOS.Append(regRule); regRule.NotifyNew(); regRule.Name.AnalysisDefaultWritingSystem = "regular rule"; IPhSimpleContextSeg segCtxt = new PhSimpleContextSeg(); regRule.RightHandSidesOS[0].StrucChangeOS.Append(segCtxt); IPhPhoneme phoneme = null; foreach (IPhPhoneme phon in Cache.LangProject.PhonologicalDataOA.PhonemeSetsOS[0].PhonemesOC) { phoneme = phon; break; } segCtxt.FeatureStructureRA = phoneme; segCtxt.NotifyNew(); IPhSimpleContextNC ncCtxt = new PhSimpleContextNC(); regRule.RightHandSidesOS[0].LeftContextOA = ncCtxt; ncCtxt.FeatureStructureRA = featNC; ncCtxt.NotifyNew(); // add a morphological rule IMoAffixProcess affRule = new MoAffixProcess(); entryNew.AlternateFormsOS.Append(affRule); affRule.NotifyNew(); ncCtxt = new PhSimpleContextNC(); affRule.InputOS.Append(ncCtxt); ncCtxt.FeatureStructureRA = featNC; ncCtxt.NotifyNew(); IMoCopyFromInput copy = new MoCopyFromInput(); affRule.OutputOS.Append(copy); copy.ContentRA = ncCtxt; copy.NotifyNew(); // ----------- // Update the FXT result // ----------- XmlDocument updatedFxtResult = UpdateFXT(); // ----------- // Test the updated results // ----------- // Test changed stem allomorph: checks on MultiUnicode and boolean node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoStemAllomorph + "']"); Assert.IsNotNull(node); Assert.AreEqual(stemAllomorph.Form.VernacularDefaultWritingSystem, node.InnerText, "stem allomorph form change failed"); XmlNode contentNode = node.SelectSingleNode("@IsAbstract"); Assert.AreEqual("1", contentNode.InnerText, "stem allomorph is abstract should be true (=1)"); // Test deleted affix allomorph: checks on owning sequence node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoAffixAllomorph + "']"); Assert.IsNull(node, "Deleted affix allomorph should be null"); node = updatedFxtResult.SelectSingleNode("//LexEntry[@id='" + hvoLexEntry + "']/AlternateForms[@dst='" + hvoAffixAllomorph + "']"); Assert.IsNull(node, "LexEntry should no longer have deleted alternate form"); // Test added new affix allomorph: checks on owning sequence owned by an item with an @Id; also checks on addition of MoAffixAllomorph via AllAllomorphs string sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']/AlternateForms[@dst='" + hvoNewAffixAllomorph + "']"; node = updatedFxtResult.SelectSingleNode(sXPath); Assert.IsNotNull(node, "LexEntry should have added alternate form"); node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoNewAffixAllomorph + "']"); Assert.IsNotNull(node, "Added affix allomorph should be present"); sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']"; node = updatedFxtResult.SelectSingleNode(sXPath); XmlNodeList nodes = node.SelectNodes("AlternateForms"); Assert.AreEqual(3, nodes.Count, "Expected three Alternate forms in lex entry."); //Test newly added compound rule: checks on owning sequence owned by an Id-less element; also on multistring node = updatedFxtResult.SelectSingleNode("//MoEndoCompound[@Id='" + compRuleNew.Hvo + "']"); Assert.IsNotNull(node, "did not find newly added compound rule"); contentNode = node.SelectSingleNode("@HeadLast"); Assert.IsNotNull(contentNode, "missing headlast attribute for coompound rule"); Assert.AreEqual("1", contentNode.InnerText, "compound rule headlast value differs"); contentNode = node.SelectSingleNode("Name"); Assert.IsNotNull(contentNode, "missing Name for compound rule"); Assert.AreEqual(sCompRuleName, contentNode.InnerText, "compound rule name differs"); // check on MultiString contentNode = node.SelectSingleNode("Description"); Assert.AreEqual(ksCompRuleDescription, contentNode.InnerText, "compound rule description differs"); // check on count node = updatedFxtResult.SelectSingleNode("//CompoundRules"); nodes = node.SelectNodes("MoExoCompound | MoEndoCompound"); Assert.AreEqual(6, nodes.Count, "Expected seven compound rules."); // check on owningAtom node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.LeftMsaOAHvo + "']"); Assert.IsNotNull(node, "missing real MoStemMsa for LeftMsa of newly added compound rule"); node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.RightMsaOAHvo + "']"); Assert.IsNotNull(node, "missing real MoStemMsa for RightMsa of newly added compound rule"); node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.OverridingMsaOAHvo + "']"); Assert.IsNotNull(node, "missing real MoStemMsa for OverridingMsa of newly added compound rule"); // Test deleted compound rule node = updatedFxtResult.SelectSingleNode("//MoExoCompound[@Id='" + compRuleDeleted.Hvo + "']"); Assert.IsNull(node, "compound rule should be deleted"); node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedLeftMsa + "']"); Assert.IsNull(node, "compound rule left MSA should be deleted"); node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedRightMsa + "']"); Assert.IsNull(node, "compound rule right MSA should be deleted"); node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedToMsa + "']"); Assert.IsNull(node, "compound rule to MSA should be deleted"); //Test newly added allomorph ad hoc rule: checks on owning collection node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHoc.Hvo + "']"); Assert.IsNotNull(node, "did not find newly added allo ad hoc rule"); contentNode = node.SelectSingleNode("@Adjacency"); Assert.IsNotNull(contentNode, "missing adjacency attribute for allo ad hoc rule"); Assert.AreEqual("2",contentNode.InnerText, "allo ad hoc rule adjacency value differs"); contentNode = node.SelectSingleNode("FirstAllomorph"); Assert.IsNotNull(contentNode, "missing FirstAllomorph for allo ad hoc rule"); contentNode = contentNode.SelectSingleNode("@dst"); Assert.IsNotNull(contentNode, "missing dst attribute of FirstAllomorph for allo ad hoc rule"); Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "FirstAllomorph of allo ad hoc rule differs"); contentNode = node.SelectSingleNode("RestOfAllos"); Assert.IsNotNull(contentNode, "missing RestOfAllos for allo ad hoc rule"); contentNode = contentNode.SelectSingleNode("@dst"); Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for allo ad hoc rule"); Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "RestOfAllos of allo ad hoc rule differs"); // test change of a "rest of allos" in extant ad hoc co-prohibition: check on reference sequence node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHocOld.Hvo + "']"); Assert.IsNotNull(node, "did not find old allo ad hoc rule"); contentNode = node.SelectSingleNode("RestOfAllos"); Assert.IsNotNull(contentNode, "missing RestOfAllos for old allo ad hoc rule"); contentNode = contentNode.SelectSingleNode("@dst"); Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for old allo ad hoc rule"); Assert.AreEqual(affixAllomorph2.Hvo.ToString(), contentNode.InnerText, "RestOfAllos of old allo ad hoc rule differs"); nodes = node.SelectNodes("RestOfAllos"); Assert.AreEqual(1, nodes.Count, "count of RestOfAllos of old allo ad hoc rule differs"); // check on integer change contentNode = node.SelectSingleNode("@Adjacency"); Assert.AreEqual("2", contentNode.InnerText, "Adjacency differs"); node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloAdHicOldFirstRestOfAllos.Hvo + "']"); Assert.IsNotNull(node, "Original RestOfAllos allomorph should still be present"); nodes = updatedFxtResult.SelectNodes("//MoAffixAllomorph[@Id='" + affixAllomorph2.Hvo + "']"); Assert.AreEqual(1, nodes.Count, "Should only be one instance of new allomorph in RestOfAllos"); // Test added productivity restriction: check on CmPossibilityList node = updatedFxtResult.SelectSingleNode("//ProdRestrict/CmPossibility"); Assert.IsNotNull(node, "Did not find newly added productivity restriction"); node = node.SelectSingleNode("Name"); Assert.IsNotNull(node, "Expected Name node in productivity restrictioni"); Assert.AreEqual(sNewProdRestrictName, node.InnerText, "name of productivity restriction differs"); // Test phonological environment string representation: check on string node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + env.Hvo + "']/@StringRepresentation"); Assert.AreEqual(ksEnvStringRep, node.InnerText, "phonological environment string differs"); // Test adding a phonological environment string representation: // check on case where parent of owner has Id and is class name; // also check on case where there is a comment/text node within the result nodes node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + envNew.Hvo + "']"); Assert.IsNotNull(node, "missing newly added phonological environment"); nodes = updatedFxtResult.SelectNodes("//PhEnvironment"); Assert.AreEqual(11, nodes.Count, "number of PhEnvironments differs"); // Test Parser Parameters: check on unicode string node = updatedFxtResult.SelectSingleNode("//ParserParameters"); string sResultParseParameters = node.OuterXml.Trim(); Assert.AreEqual(sNewParserParameters, sResultParseParameters, "Parser Parameters content differs"); // Test deletion of a lex entry: check on finding LexDb when there is no class LexDb in FXT file nodes = updatedFxtResult.SelectNodes("//LexEntry"); Assert.AreEqual(61, nodes.Count, "number of LexEntries differs"); node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + hvoEntryDeleted + "']"); Assert.IsNull(node, "Deleted lex entry should be missing"); foreach (int hvo in hvosEntryDeletedAlternateForms) { node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvo + "'] | //MoAffixAllomorph[@Id='" + hvo + "']"); Assert.IsNull(node, "deleted entry's alternate form should also be gone"); } foreach (int hvo in hvosEntryDeletedMSAs) { node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvo + "']"); Assert.IsNull(node, "deleted entry's msa should also be gone"); } foreach (int hvo in hvosEntryDeletedSenses) { node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + hvo + "']"); Assert.IsNull(node, "deleted entry's lexsense should also be gone"); } node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoEntryDeletedLexemeForm + "']"); Assert.IsNull(node, "deleted entry's lexeme form should also be gone"); // Test adding new entry node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']"); Assert.IsNotNull(node, "new lex entry is missing"); contentNode = node.SelectSingleNode("LexemeForm[@dst='" + alloNew.Hvo + "']"); Assert.IsNotNull(contentNode, "missing lexeme form for new entry"); contentNode = node.SelectSingleNode("AlternateForms[@dst='" + alloNew2.Hvo + "']"); Assert.IsNotNull(contentNode, "missing alternate form in new lex entry"); contentNode = node.SelectSingleNode("Sense[@dst='" + sense.Hvo + "']"); Assert.IsNotNull(contentNode, "missing sense in new lex entry"); contentNode = node.SelectSingleNode("MorphoSyntaxAnalysis[@dst='" + inflAffixMsa.Hvo + "']"); Assert.IsNotNull(contentNode, "missing msa in new lex entry"); contentNode = node.SelectSingleNode("AlternateForms[@dst='" + affRule.Hvo + "']"); Assert.IsNotNull(contentNode, "missing affix process rule in new lex entry"); node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew.Hvo + "']"); Assert.IsNotNull(node, "new lexeme form affix allomorph for new lex entry is missing"); contentNode = node.SelectSingleNode("@MorphType"); Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in lexeme form of new lex entry"); IMoMorphType typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText)); string sGuidNew = typeNew.Guid.ToString(); Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry"); contentNode = node.SelectSingleNode("Form"); Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in lexeme form new lex entry"); Assert.AreEqual(sNewAlloForm, contentNode.InnerText, "form wrong for new MoAffixAllomorph in lexeme form of new lex entry"); node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew2.Hvo + "']"); Assert.IsNotNull(node, "new alternate form affix allomorph for new lex entry is missing"); contentNode = node.SelectSingleNode("@MorphType"); Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in alternate form of new lex entry"); typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText)); sGuidNew = typeNew.Guid.ToString(); Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry"); contentNode = node.SelectSingleNode("Form"); Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in alternate form new lex entry"); Assert.AreEqual(sNewAlloForm2, contentNode.InnerText, "form wrong for new MoAffixAllomorph in alternate form of new lex entry"); node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + sense.Hvo + "']"); Assert.IsNotNull(node, "new sense for new lex entry is missing"); contentNode = node.SelectSingleNode("Gloss"); Assert.IsNotNull(contentNode, "Gloss missing for new LexSense in new lex entry"); Assert.AreEqual(sGloss, contentNode.InnerText, "Gloss wrong for new LexSense in new lex entry"); node = updatedFxtResult.SelectSingleNode("//MoInflAffMsa[@Id='" + inflAffixMsa.Hvo + "']"); Assert.IsNotNull(node, "new infl affix msa for new lex entry is missing"); contentNode = node.SelectSingleNode("@PartOfSpeech"); Assert.IsNotNull(contentNode, "@PartOfSpeech missing for new MoInflAffMsa in new lex entry"); Assert.AreEqual(hvoVerb.ToString(), contentNode.InnerText, "part of speech wrong for new MoInflAffMsa in new lex entry"); contentNode = node.SelectSingleNode("Slots/@dst"); Assert.IsNotNull(contentNode, "Slots missing for new MoInflAffMsa in new lex entry"); Assert.AreEqual(hvoSlot.ToString(), contentNode.InnerText, "slot wrong for new MoInflAffMsa in new lex entry"); // Test adding new template node = updatedFxtResult.SelectSingleNode("//MoInflAffixTemplate[@Id='" + affixTemplate.Hvo + "']"); Assert.IsNotNull(node, "new affix template missing"); node = updatedFxtResult.SelectSingleNode("//PartOfSpeech[@Id='" + hvoIntransVerb + "']/AffixTemplates/MoInflAffixTemplate[@Id='" + affixTemplate.Hvo + "']"); Assert.IsNotNull(node, "new affix template is in intransitive verb"); // Test adding new phonological feature node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Features/FsClosedFeature[@Id='" + consFeat.Hvo + "']"); Assert.IsNotNull(node, "new phonological feature is missing"); contentNode = node.SelectSingleNode("Abbreviation"); Assert.IsNotNull(contentNode, "Abbreviation missing from new phonological feature"); Assert.AreEqual(contentNode.InnerText, consFeat.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new phonological feature"); nodes = node.SelectNodes("Values/FsSymFeatVal"); Assert.IsNotNull(nodes, "values missing from new phonological feature"); Assert.AreEqual(nodes.Count, 2, "incorrect number of values in new phonological feature"); node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Types/FsFeatStrucType/Features/Feature[@dst='" + consFeat.Hvo + "']"); Assert.IsNotNull(node, "reference to new phonological feature is missing from phonological feature system"); // Test adding new feature-based NC node = updatedFxtResult.SelectSingleNode("//PhNCFeatures[@Id='" + featNC.Hvo + "']"); Assert.IsNotNull(node, "new feature-based NC is missing"); contentNode = node.SelectSingleNode("Abbreviation"); Assert.IsNotNull(contentNode, "Abbreviation missing from new feature-based NC"); Assert.AreEqual(contentNode.InnerText, featNC.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new feature-based NC"); contentNode = node.SelectSingleNode("FsFeatStruc/FsClosedValue[@Id='" + val.Hvo + "']"); Assert.IsNotNull(contentNode, "value missing from new feature-based NC"); Assert.AreEqual((contentNode as XmlElement).GetAttribute("Feature"), consFeat.Hvo.ToString(), "closed value feature is wrong in new feature-based NC"); Assert.AreEqual((contentNode as XmlElement).GetAttribute("Value"), consPlus.Hvo.ToString(), "closed value is wrong in new feature-based NC"); // Test adding new phonological rule node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']"); Assert.IsNotNull(node, "new phonological rule is missing"); nodes = node.SelectNodes("StrucDesc/*"); Assert.AreEqual(nodes.Count, 0); contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']"); Assert.IsNotNull(contentNode, "phoneme simple context missing in new phonological rule"); contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSimpleContextNC[@dst='" + featNC.Hvo + "']"); Assert.IsNotNull(contentNode, "NC simple context missing in new phonological rule"); // Test adding new morphological rule node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']"); Assert.IsNotNull(node, "new morphological rule is missing"); contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']"); Assert.IsNotNull(contentNode, "NC simple context missing in new morphological rule"); contentNode = node.SelectSingleNode("Output/MoCopyFromInput/Content[@dst='" + ncCtxt.Hvo + "']"); Assert.IsNotNull(contentNode, "copy from input missing in new morphological rule"); // Modify a phonological rule segCtxt = new PhSimpleContextSeg(); regRule.StrucDescOS.Append(segCtxt); segCtxt.FeatureStructureRA = phoneme; segCtxt.NotifyNew(); regRule.RightHandSidesOS[0].StrucChangeOS[0].DeleteUnderlyingObject(); IPhPhonContext oldCtxt = regRule.RightHandSidesOS[0].LeftContextOA; Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(oldCtxt); IPhSequenceContext seqCtxt = new PhSequenceContext(); regRule.RightHandSidesOS[0].LeftContextOA = seqCtxt; seqCtxt.MembersRS.Append(oldCtxt); seqCtxt.NotifyNew(); IPhSimpleContextBdry bdryCtxt = new PhSimpleContextBdry(); Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(bdryCtxt); bdryCtxt.FeatureStructureRAHvo = Cache.GetIdFromGuid(LangProject.kguidPhRuleWordBdry); bdryCtxt.NotifyNew(); seqCtxt.MembersRS.Append(bdryCtxt); // Modify a morphological rule entryNew.LexemeFormOA = affRule; IMoInsertPhones insertPhones = new MoInsertPhones(); affRule.OutputOS.InsertAt(insertPhones, 0); insertPhones.ContentRS.Append(phoneme); insertPhones.NotifyNew(); affRule.InputOS[1].DeleteUnderlyingObject(); // change order of a sequence vector lexEntry.AlternateFormsOS.InsertAt(newAffixAllomorph, 0); updatedFxtResult = UpdateFXT(); // Test modifying a phonological rule node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']"); contentNode = node.SelectSingleNode("StrucDesc/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']"); Assert.IsNotNull(contentNode, "phoneme simple context missing from StrucDesc in modified phonological rule"); contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']"); Assert.IsNull(contentNode, "phoneme simple context is not missing from StrucChange in modified phonological rule"); contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSequenceContext[@Id='" + seqCtxt.Hvo + "']"); Assert.IsNotNull(contentNode, "sequence context missing from modified phonological rule"); contentNode = contentNode.SelectSingleNode("Members[@dst='" + bdryCtxt.Hvo + "']"); Assert.IsNotNull(contentNode, "boundary context missing from sequence context in modified phonological rule"); node = updatedFxtResult.SelectSingleNode("//PhPhonData/Contexts/PhSimpleContextBdry[@Id='" + bdryCtxt.Hvo + "']"); Assert.IsNotNull(node, "boundary context missing from contexts in phonological data"); // Test modifying a morphological rule node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']"); contentNode = node.SelectSingleNode("LexemeForm[@dst='" + affRule.Hvo + "']"); Assert.IsNotNull(contentNode, "affix process rule is not the lexeme form for the lex entry"); node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']"); contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']"); Assert.IsNull(contentNode, "NC simple context was not removed from morphological rule"); nodes = node.SelectNodes("Output/*"); Assert.AreEqual(nodes.Count, 2, "incorrect number of mappings in morphological rule"); contentNode = node.SelectSingleNode("Output/*[position() = 1 and @Id='" + insertPhones.Hvo + "']"); Assert.IsNotNull(contentNode, "insert phones missing from morphological rule"); // Test changing order of a sequence vector node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + lexEntry.Hvo + "']"); contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[0].Hvo + "']/@ord"); Assert.AreEqual("0", contentNode.InnerText); contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[1].Hvo + "']/@ord"); Assert.AreEqual("1", contentNode.InnerText); contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[2].Hvo + "']/@ord"); Assert.AreEqual("2", contentNode.InnerText); }
public void CliticVsStemMsaWithoutCategory() { CheckDisposed(); LexEntry entry = new LexEntry(); Cache.LangProject.LexDbOA.EntriesOC.Add(entry); MoStemAllomorph allomorph = new MoStemAllomorph(); entry.LexemeFormOA = allomorph; MoStemMsa msa = new MoStemMsa(); entry.MorphoSyntaxAnalysesOC.Add(msa); SetMorphType(allomorph, MoMorphType.kguidMorphClitic); Assert.AreEqual("Clitic of unknown category", msa.LongNameTs.Text); MoStemAllomorph allo2 = new MoStemAllomorph(); entry.AlternateFormsOS.Append(allo2); SetMorphType(allomorph, MoMorphType.kguidMorphStem); Assert.AreEqual("Stem/root of unknown category; takes any affix", msa.LongNameTs.Text); }
/// <summary> /// Get set of inflectional affix slots appropriate for the entry /// </summary> /// <param name="cache"></param> /// <param name="lex">lex entry</param> /// <param name="pos">part of speech</param> /// <returns></returns> public static Set<int> GetSetOfSlots(FdoCache cache, LexEntry lex, IPartOfSpeech pos) { Set<int> set; bool fIsPrefixal = false; bool fIsSuffixal = false; List<IMoMorphType> morphTypes = lex.MorphTypes; foreach (IMoMorphType morphType in morphTypes) { if (MoMorphType.IsPrefixishType(cache, morphType.Hvo)) fIsPrefixal = true; if (MoMorphType.IsSuffixishType(cache, morphType.Hvo)) fIsSuffixal = true; } if (fIsPrefixal && fIsSuffixal) set = new Set<int>(pos.AllAffixSlotIDs); else set = MoInflAffixTemplate.GetSomeSlots(cache, new Set<int>(pos.AllAffixSlotIDs), fIsPrefixal); return set; }
//TODO: (JDH) fix this so that only an exception *on the last line* will produce a PASS // Validity checking in DEBUG mode has been turned off. It complicates performance testing too much. // [ExpectedException(typeof(ArgumentException))] //#if !DEBUG // [Ignore("This test doesn't get an exception in release mode due to CmObject c'tor")] //#endif //TODO (Steve Miller): The above test fails if the followeng lines are remarked // out in CmObject.cs, like below. I have frequently remarked out lines there // like this, because they foul up SQL performance tests: // // (InitExisting method) // //#if DEBUG // // if (!fcCache.IsDummyObject(hvo)) // // fCheckValidity = true; // //#endif // // (CreateFromDBObject method) // //#if DEBUG // // true/*validity check*/, // //#else // false, // //#endif public void DeleteUnderlyingObject() { CheckDisposed(); LexEntry se = new LexEntry(); m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(se); LexSense ls = new LexSense(); se.SensesOS.Append(ls); int khvoLexSense = ls.Hvo; ls.DeleteUnderlyingObject(); Assert.IsTrue(m_fdoCache.VwOleDbDaAccessor.get_ObjOwner(khvoLexSense) <= 0); // khvoLexSense not removed from cache. // See if FDO object is valid. It should not be. Assert.IsFalse(ls.IsValidObject()); // Test to see if it is really gone from DB. // An exception should be thrown by CmObject.InitExisting, // since khvoLexSense isn't in DB now. ls = new LexSense(m_fdoCache, khvoLexSense, true, true); Assert.IsFalse(ls.IsValidObject()); }
private FlexEntry MakeFwEntryFromWeSayEntry(WeSay.LexicalModel.LexEntry weSayEntry) { //MoStemMsa msa = new MoStemMsa(); //// I wouldn't even *pretend* to understand this weirdness. Is 'dummy' a technical term? //DummyGenericMSA dmsa = DummyGenericMSA.Create(msa); //MoMorphType mmt = _flexMorphTypes.Item(MoMorphType.kmtStem); //LexEntry entry = LexEntry.CreateEntry(_cache, EntryType.ketMajorEntry, mmt, weSayEntry.LexicalForm, null, weSayEntry.Gloss, dmsa); FlexEntry entry = new FlexEntry(); _cache.LangProject.LexDbOA.EntriesOC.Add(entry); //(_cache, EntryType.ketMajorEntry, mmt, weSayEntry.LexicalForm, null, weSayEntry.Gloss, dmsa); entry.Guid = weSayEntry.Guid; entry.LexemeFormOA = new MoStemAllomorph(); // entry.LexemeFormOA.Form.VernacularDefaultWritingSystem // = weSayEntry.LexicalForm; //LexSense.CreateSense(entry, dmsa, weSayEntry.Gloss); MakeSense(weSayEntry, entry); // if (Merged != null) // { // Merged.Invoke(this, "Added"); // } return entry; }
/// ------------------------------------------------------------------------------------ /// <summary>Returns a TsString with the entry headword and a sense number if there /// are more than one senses. /// </summary> /// <param name="wsVern"></param> /// ------------------------------------------------------------------------------------ public ITsString OwnerOutlineNameForWs(int wsVern) { if (wsVern <= 0) wsVern = m_cache.DefaultVernWs; int hvoEntry = EntryID; if (hvoEntry == 0) { ITsStrFactory tsf = TsStrFactoryClass.Create(); return tsf.MakeString("<missing entry!!>", wsVern); } LexEntry le = new LexEntry(m_cache, EntryID, false, false); ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); tisb.AppendTsString(le.HeadWordForWs(wsVern)); if (le.HasMoreThanOneSense) { // These int props may not be needed, but they're safe. tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_cache.DefaultAnalWs); tisb.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.Append(" "); tisb.Append(this.SenseNumber); } return tisb.GetString(); }
private SimpleListChooser MakeChooserWithExtantMsas(IMoInflAffixSlot slot, XCore.Command cmd) { // Want the list of all lex entries which have an infl affix Msa // Do not want to list the infl affix Msas that are already assigned to the slot. Set<int> candidates = new Set<int>(); bool fIsPrefixSlot = m_template.PrefixSlotsRS.Contains(slot.Hvo); foreach (int hvoLexEntry in slot.OtherInflectionalAffixLexEntries) { ILexEntry lex = new LexEntry(Cache, hvoLexEntry); bool fInclude = EntryHasAffixThatMightBeInSlot(lex, fIsPrefixSlot); if (fInclude) { foreach (IMoMorphSynAnalysis msa in lex.MorphoSyntaxAnalysesOC) { if (msa.ClassID == MoInflAffMsa.kclsidMoInflAffMsa) { candidates.Add(msa.Hvo); break; } } } } ObjectLabelCollection labels = new ObjectLabelCollection(Cache, candidates, null); XCore.PersistenceProvider persistProvider = new PersistenceProvider(m_mediator.PropertyTable); int[] aiForceMultipleChoices = new int[1]; SimpleListChooser chooser = new SimpleListChooser(persistProvider, labels, m_ChooseInflectionalAffixHelpTopic, Cache, aiForceMultipleChoices); chooser.SetFontForDialog(new int[] { Cache.DefaultVernWs, Cache.DefaultAnalWs }, StyleSheet, WritingSystemFactory); chooser.Cache = Cache; // We don't want the ()'s indicating optionality since the text spells it out. chooser.TextParam = slot.Name.AnalysisDefaultWritingSystem; chooser.Title = m_sInflAffixChooserTitle; if (slot.Optional) chooser.InstructionalText = m_sInflAffixChooserInstructionalTextOpt; else chooser.InstructionalText = m_sInflAffixChooserInstructionalTextReq; chooser.AddLink(m_sInflAffix, SimpleListChooser.LinkType.kDialogLink, new MakeInflAffixEntryChooserCommand(Cache, true, m_sInflAffix, fIsPrefixSlot, slot, m_mediator)); chooser.SetObjectAndFlid(slot.Hvo, slot.OwningFlid); string sGuiControl = XmlUtils.GetOptionalAttributeValue(cmd.ConfigurationNode, "guicontrol"); if (!String.IsNullOrEmpty(sGuiControl)) { chooser.ReplaceTreeView(m_mediator, sGuiControl); } return chooser; }