/// <summary> /// Given a (potentially) owning object, and the flid in which is does/will own /// the feature structure, find the relevant POS. /// </summary> /// <param name="cobj"></param> /// <param name="owningFlid"></param> /// <returns></returns> private IPartOfSpeech GetPosFromCmObjectAndFlid(ICmObject cobj, int owningFlid) { IPartOfSpeech pos = null; switch (cobj.ClassID) { case MoInflAffMsa.kclsidMoInflAffMsa: IMoInflAffMsa infl = cobj as IMoInflAffMsa; if (infl != null) { pos = infl.PartOfSpeechRA; } break; case MoDerivAffMsa.kclsidMoDerivAffMsa: IMoDerivAffMsa deriv = cobj as IMoDerivAffMsa; if (deriv != null) { if (owningFlid == (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromMsFeatures) { pos = deriv.FromPartOfSpeechRA; } else if (owningFlid == (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidToMsFeatures) { pos = deriv.ToPartOfSpeechRA; } } break; case MoStemMsa.kclsidMoStemMsa: IMoStemMsa stem = cobj as IMoStemMsa; if (stem != null) { pos = stem.PartOfSpeechRA; } break; case MoStemName.kclsidMoStemName: IMoStemName sn = cobj as IMoStemName; pos = PartOfSpeech.CreateFromDBObject(sn.Cache, sn.OwnerHVO); break; case MoAffixAllomorph.kclsidMoAffixAllomorph: // get entry of the allomorph and then get the msa of first sense and return its (from) POS ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, cobj.OwnerHVO); if (entry == null) { return(pos); } ILexSense sense = entry.SensesOS.FirstItem; if (sense == null) { return(pos); } IMoMorphSynAnalysis msa = sense.MorphoSyntaxAnalysisRA; pos = GetPosFromCmObjectAndFlid(msa, (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromMsFeatures); break; } return(pos); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } base.Dispose(disposing); if (disposing) { if (components != null) { components.Dispose(); } if (m_vc != null) { m_vc.Dispose(); } } m_vc = null; m_msa = null; }
public static IPartOfSpeech FromMSA(IMoMorphSynAnalysis msa, out IPartOfSpeech secondaryPos) { secondaryPos = null; switch (msa.ClassID) { case MoDerivAffMsaTags.kClassId: // FDO considers the "From" PoS to be the main one, and "To" to be the secondary one secondaryPos = ((IMoDerivAffMsa)msa).ToPartOfSpeechRA; return(((IMoDerivAffMsa)msa).FromPartOfSpeechRA); case MoDerivStepMsaTags.kClassId: return(((IMoDerivStepMsa)msa).PartOfSpeechRA); case MoInflAffMsaTags.kClassId: return(((IMoInflAffMsa)msa).PartOfSpeechRA); case MoStemMsaTags.kClassId: return(((IMoStemMsa)msa).PartOfSpeechRA); case MoUnclassifiedAffixMsaTags.kClassId: return(((IMoUnclassifiedAffixMsa)msa).PartOfSpeechRA); default: return(null); } }
/// <summary> /// Handle launching of the MSA editor. /// </summary> protected override void HandleChooser() { using (MsaCreatorDlg dlg = new MsaCreatorDlg()) { MoMorphSynAnalysis originalMsa = m_obj as MoMorphSynAnalysis; ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, originalMsa.OwnerHVO); dlg.SetDlgInfo(m_cache, m_persistProvider, m_mediator, entry, DummyGenericMSA.Create(originalMsa), originalMsa.Hvo, true, String.Format(LexEdStrings.ksEditX, Slice.Label)); if (dlg.ShowDialog(FindForm()) == DialogResult.OK) { DummyGenericMSA dummyMsa = dlg.DummyMSA; if (!originalMsa.EqualsMsa(dummyMsa)) { m_cache.BeginUndoTask(LexEdStrings.ksUndoEditFunction, LexEdStrings.ksRedoEditFunction); // The UpdateOrReplace call may end up disposing this. So any variables we // need after it must be copied to the stack. FdoCache cache = m_cache; Slice parent = Slice; IMoMorphSynAnalysis newMsa = originalMsa.UpdateOrReplace(dummyMsa); cache.EndUndoTask(); } } } }
public EmptyWwfInfo(IMoForm form, IMoMorphSynAnalysis msa, IPartOfSpeech pos, ILexSense sense) { Form = form; Msa = msa; Pos = pos; Sense = sense; }
/// <summary> /// Handle launching of the MSA editor. /// </summary> protected override void HandleChooser() { using (MsaCreatorDlg dlg = new MsaCreatorDlg()) { IMoMorphSynAnalysis originalMsa = m_obj as IMoMorphSynAnalysis; ILexEntry entry = originalMsa.Owner as ILexEntry; dlg.SetDlgInfo(m_cache, m_persistProvider, m_mediator, m_propertyTable, entry, SandboxGenericMSA.Create(originalMsa), originalMsa.Hvo, true, String.Format(LexEdStrings.ksEditX, Slice.Label)); if (dlg.ShowDialog(FindForm()) == DialogResult.OK) { SandboxGenericMSA sandboxMsa = dlg.SandboxMSA; if (!originalMsa.EqualsMsa(sandboxMsa)) { UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoEditFunction, LexEdStrings.ksRedoEditFunction, entry, () => { originalMsa.UpdateOrReplace(sandboxMsa); }); } } } }
private static FeatureStruct GetFeatureStruct(FeatureSystem featSys, IMoMorphSynAnalysis msa) { IFsFeatStruc fs = null; var stemMsa = msa as IMoStemMsa; if (stemMsa != null) { fs = stemMsa.MsFeaturesOA; } else { var inflMsa = msa as IMoInflAffMsa; if (inflMsa != null) { fs = inflMsa.InflFeatsOA; } else { var dervMsa = msa as IMoDerivAffMsa; if (dervMsa != null) { fs = dervMsa.ToMsFeaturesOA; } } } if (fs != null && !fs.IsEmpty) { return(GetFeatureStruct(featSys, fs)); } return(null); }
/// <summary> /// /// </summary> /// <param name="hvo"></param> /// <param name="tag"></param> /// <param name="ws"></param> /// <param name="cda"></param> public override void Load(int hvo, int tag, int ws, IVwCacheDa cda) { IMoMorphSynAnalysis msa = MoMorphSynAnalysis.CreateFromDBObject(m_cache, hvo); ITsStrFactory tsf = TsStrFactoryClass.Create(); cda.CacheStringProp(hvo, tag, tsf.MakeString(msa.InterlinearName, m_cache.DefaultAnalWs)); }
public void InvalidReduplicationForm(IMoForm form, string reason, IMoMorphSynAnalysis msa) { m_xmlWriter.WriteStartElement("LoadError"); m_xmlWriter.WriteAttributeString("type", "invalid-redup-form"); m_xmlWriter.WriteElementString("Form", form.Form.VernacularDefaultWritingSystem.Text); m_xmlWriter.WriteElementString("Hvo", msa.Hvo.ToString(CultureInfo.InvariantCulture)); m_xmlWriter.WriteElementString("Reason", reason); m_xmlWriter.WriteEndElement(); }
public void InvalidShape(string str, int errorPos, IMoMorphSynAnalysis msa) { m_xmlWriter.WriteStartElement("LoadError"); m_xmlWriter.WriteAttributeString("type", "invalid-shape"); m_xmlWriter.WriteElementString("Form", str); m_xmlWriter.WriteElementString("Position", errorPos.ToString(CultureInfo.InvariantCulture)); m_xmlWriter.WriteElementString("Hvo", msa.Hvo.ToString(CultureInfo.InvariantCulture)); m_xmlWriter.WriteEndElement(); }
internal static XElement CreateAllomorphElement(string name, IMoForm form, IMoMorphSynAnalysis msa, bool circumfix) { var elem = new XElement(name, new XAttribute("id", form.Hvo), new XAttribute("type", GetMorphTypeString(circumfix ? MoMorphTypeTags.kguidMorphCircumfix : form.MorphTypeRA.Guid)), new XElement("Form", circumfix ? form.OwnerOfClass <ILexEntry>().HeadWord.Text : form.GetFormWithMarkers(form.Cache.DefaultVernWs)), new XElement("LongName", form.LongName)); elem.Add(CreateMorphemeElement(msa)); return(elem); }
private ILexSense MakeSense(ILexEntry entry, string gloss, IMoMorphSynAnalysis msa) { // Bare bones of Sense var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.AnalysisDefaultWritingSystem = MakeAnalysisString(gloss); sense.MorphoSyntaxAnalysisRA = msa; return(sense); }
private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, ITsStrFactory tsf, IMoMorphSynAnalysis msa) { // JohnT: as described in LT-4633, a stem can be given an allomorph that // is an affix. So we need some sort of way to handle this. //Debug.Assert(msa is MoStemMsa); ITsString tssLabel = msa.InterlinearNameTSS; if (msa is IMoStemMsa && (msa as IMoStemMsa).PartOfSpeechRAHvo == 0) tssLabel = tsf.MakeString(m_sUnknown, Cache.DefaultUserWs); HvoTreeNode node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); return node; }
/// <summary> /// Make an entry with the specified lexeme form of the specified slot type, a sense with the specified gloss, /// an MSA with the specified part of speech, and generally hook things up as expected. /// Assumes all of the required objects need to be created; in general this might not be true, but it works /// for the test data here. /// </summary> private ILexEntry MakeEntry(string lf, string pos, Guid slotType, out IMoMorphSynAnalysis msa) { // The entry itself. ILexEntry entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); // Lexeme Form and MSA. IMoForm form; msa = GetMsaAndMoForm(entry, slotType, pos, out form); entry.LexemeFormOA = form; form.Form.VernacularDefaultWritingSystem = MakeVernString(lf); form.MorphTypeRA = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(slotType); return(entry); }
// This class used to contain code for parsing the canonical part-of-speech data from GOLDEtic.xml and creating // new IPartOfSpeech objects from the canonical data if they were in Mongo but not in FDO. Most of that code has // been moved to the classes in the CanonicalSources namespace, and the "create new IPartOfSpeech" objects has // been moved to ConvertMongoToFdoOptionList (and made more generic). The only thing left in this class is the // static SetPartOfSpeech function, which deals with the complexities of MSAs. public static void SetPartOfSpeech(IMoMorphSynAnalysis msa, IPartOfSpeech pos, IPartOfSpeech secondaryPos = null, ILogger logger = null) { if (msa == null) { if (logger != null) { logger.Debug("Trying to set part of speech \"{0}\" in MSA, but MSA was null", pos == null ? "(null)" : pos.AbbrAndName); } return; } if (pos == null) { if (logger != null) { logger.Debug("Trying to set a null part of speech in MSA \"{0}\" with GUID {1}", msa.GetGlossOfFirstSense(), msa.Guid); } return; } switch (msa.ClassID) { case MoDerivAffMsaTags.kClassId: ((IMoDerivAffMsa)msa).FromPartOfSpeechRA = pos; // It's OK for secondaryPos to be null here; this represents *removing* the "To" part of speech link from this MSA ((IMoDerivAffMsa)msa).ToPartOfSpeechRA = secondaryPos; break; case MoDerivStepMsaTags.kClassId: ((IMoDerivStepMsa)msa).PartOfSpeechRA = pos; break; case MoInflAffMsaTags.kClassId: ((IMoInflAffMsa)msa).PartOfSpeechRA = pos; break; case MoStemMsaTags.kClassId: ((IMoStemMsa)msa).PartOfSpeechRA = pos; break; case MoUnclassifiedAffixMsaTags.kClassId: ((IMoUnclassifiedAffixMsa)msa).PartOfSpeechRA = pos; break; default: // We'll only reach here if new MSA types are added to FDO and we forget to update the switch statement above if (logger != null) { logger.Debug("Got MSA of unknown type {0}", msa.GetType().Name); } return; } }
public void Init(LcmCache cache, IMoMorphSynAnalysis msa) { Debug.Assert(msa != null); m_msa = msa; m_cache = cache; if (m_rootb == null) { MakeRoot(); } else { m_rootb.SetRootObject(m_msa.Hvo, Vc, (int)VcFrags.kfragFullMSAInterlinearname, m_rootb.Stylesheet); m_rootb.Reconstruct(); } m_cache.DomainDataByFlid.AddNotification(this); }
public override string GetHvoRepresentation(FdoCache cache, int hvo) { var obj = cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo); IMoMorphSynAnalysis msa = obj as IMoMorphSynAnalysis; string sResult; if (msa != null) { sResult = msa.LongName; } else { sResult = ParserUIStrings.ksUnknownMorpheme; // in case the user continues... throw new ApplicationException(sResult); } return(sResult); }
public void Init(Mediator mediator, IMoMorphSynAnalysis msa) { Debug.Assert(msa != null); m_msa = msa; m_fdoCache = (FdoCache)mediator.PropertyTable.GetValue("cache"); if (m_rootb == null) { MakeRoot(); } else { MoMorphSynAnalysisUi msaUi = new MoMorphSynAnalysisUi(m_msa); m_rootb.SetRootObject(m_msa.Hvo, msaUi.Vc, (int)VcFrags.kfragFullMSAInterlinearname, m_rootb.Stylesheet); m_rootb.Reconstruct(); } }
public void Init(Mediator mediator, IMoMorphSynAnalysis msa) { Debug.Assert(msa != null); m_msa = msa; m_fdoCache = (FdoCache)mediator.PropertyTable.GetValue("cache"); if (m_rootb == null) { MakeRoot(); } else { m_rootb.SetRootObject(m_msa.Hvo, Vc, (int)VcFrags.kfragFullMSAInterlinearname, m_rootb.Stylesheet); m_rootb.Reconstruct(); } m_fdoCache.DomainDataByFlid.AddNotification(this); }
public override string GetHvoRepresentation(FdoCache cache, int hvo) { ICmObject obj = CmObject.CreateFromDBObject(cache, hvo); IMoMorphSynAnalysis msa = obj as IMoMorphSynAnalysis; string sResult; if (msa != null) { sResult = msa.LongName; } else { sResult = ParserUIStrings.ksUnknownMorpheme; // in case the user continues... throw new ApplicationException(sResult); } return(sResult); }
private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, IMoMorphSynAnalysis msa) { // JohnT: as described in LT-4633, a stem can be given an allomorph that // is an affix. So we need some sort of way to handle this. //Debug.Assert(msa is MoStemMsa); ITsString tssLabel = msa.InterlinearNameTSS; var stemMsa = msa as IMoStemMsa; if (stemMsa != null && stemMsa.PartOfSpeechRA == null) { tssLabel = TsStringUtils.MakeString( m_sUnknown, Cache.ServiceLocator.WritingSystemManager.UserWs); } var node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); return(node); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { // Must not be run more than once. if (IsDisposed) return; if (disposing) { if (components != null) { components.Dispose(); } if (m_fdoCache != null) m_fdoCache.DomainDataByFlid.RemoveNotification(this); } m_vc = null; m_msa = null; base.Dispose(disposing); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; base.Dispose(disposing); if (disposing) { if (components != null) { components.Dispose(); } if (m_vc != null) m_vc.Dispose(); } m_vc = null; m_msa = null; }
// This class used to contain code for parsing the canonical part-of-speech data from GOLDEtic.xml and creating // new IPartOfSpeech objects from the canonical data if they were in Mongo but not in FDO. Most of that code has // been moved to the classes in the CanonicalSources namespace, and the "create new IPartOfSpeech" objects has // been moved to ConvertMongoToFdoOptionList (and made more generic). The only thing left in this class is the // static SetPartOfSpeech function, which deals with the complexities of MSAs. public static void SetPartOfSpeech(IMoMorphSynAnalysis msa, IPartOfSpeech pos, IPartOfSpeech secondaryPos = null, ILogger logger = null) { if (msa == null) { if (logger != null) logger.Debug("Trying to set part of speech \"{0}\" in MSA, but MSA was null", pos == null ? "(null)" : pos.AbbrAndName); return; } if (pos == null) { if (logger != null) logger.Debug("Trying to set a null part of speech in MSA \"{0}\" with GUID {1}", msa.GetGlossOfFirstSense(), msa.Guid); return; } switch (msa.ClassID) { case MoDerivAffMsaTags.kClassId: ((IMoDerivAffMsa)msa).FromPartOfSpeechRA = pos; // It's OK for secondaryPos to be null here; this represents *removing* the "To" part of speech link from this MSA ((IMoDerivAffMsa)msa).ToPartOfSpeechRA = secondaryPos; break; case MoDerivStepMsaTags.kClassId: ((IMoDerivStepMsa)msa).PartOfSpeechRA = pos; break; case MoInflAffMsaTags.kClassId: ((IMoInflAffMsa)msa).PartOfSpeechRA = pos; break; case MoStemMsaTags.kClassId: ((IMoStemMsa)msa).PartOfSpeechRA = pos; break; case MoUnclassifiedAffixMsaTags.kClassId: ((IMoUnclassifiedAffixMsa)msa).PartOfSpeechRA = pos; break; default: // We'll only reach here if new MSA types are added to FDO and we forget to update the switch statement above if (logger != null) logger.Debug("Got MSA of unknown type {0}", msa.GetType().Name); return; } }
/// <summary> /// Populate the tree with just ONE menu item, the one that we want to select, and select it. /// </summary> /// <param name="popupTree"></param> public TreeNode MakeTargetMenuItem() { CheckDisposed(); PopupTree popupTree = GetPopupTree(); popupTree.Nodes.Clear(); IMoMorphSynAnalysis msa = m_sense.MorphoSyntaxAnalysisRA; if (msa == null) { // CreateEmptyMSA during an Undo can crash out, // or cause the Undo (e.g. merge senses) not to complete. (cf. LT-7776) //CreateEmptyMsa(); //msa = m_sense.MorphoSyntaxAnalysisRA; //if (msa == null) return null; } int hvoTarget = msa.Hvo; ITsStrFactory tsf = TsStrFactoryClass.Create(); TreeNode match = AddTreeNodeForMsa(popupTree, tsf, msa); SelectChosenItem(match, popupTree); return match; }
public static IPartOfSpeech FromMSA(IMoMorphSynAnalysis msa, out IPartOfSpeech secondaryPos) { secondaryPos = null; switch (msa.ClassID) { case MoDerivAffMsaTags.kClassId: // FDO considers the "From" PoS to be the main one, and "To" to be the secondary one secondaryPos = ((IMoDerivAffMsa)msa).ToPartOfSpeechRA; return ((IMoDerivAffMsa)msa).FromPartOfSpeechRA; case MoDerivStepMsaTags.kClassId: return ((IMoDerivStepMsa)msa).PartOfSpeechRA; case MoInflAffMsaTags.kClassId: return ((IMoInflAffMsa)msa).PartOfSpeechRA; case MoStemMsaTags.kClassId: return ((IMoStemMsa)msa).PartOfSpeechRA; case MoUnclassifiedAffixMsaTags.kClassId: return ((IMoUnclassifiedAffixMsa)msa).PartOfSpeechRA; default: // TODO: Make this a log message, not Console.WriteLine Console.WriteLine("Got MSA of unknown type {0}", msa.GetType().Name); return null; } }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (components != null) { components.Dispose(); } if (m_fdoCache != null) { m_fdoCache.DomainDataByFlid.RemoveNotification(this); } } m_vc = null; m_msa = null; base.Dispose(disposing); }
private ILexEntry MakeEntry(string lf, IPartOfSpeech pos, string gloss, FS inflFS = null) { // The entry itself. ILexEntry entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); // Lexeme Form and MSA. Guid slotType = GetSlotType(lf); IMoForm form; IMoMorphSynAnalysis msa = GetMsaAndMoForm(entry, slotType, pos, inflFS, out form); entry.LexemeFormOA = form; string trimmed = lf.Trim('-'); form.Form.VernacularDefaultWritingSystem = MakeVernString(trimmed); form.Form.AnalysisDefaultWritingSystem = MakeAnalysisString(trimmed); form.MorphTypeRA = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(slotType); // Bare bones of Sense var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.AnalysisDefaultWritingSystem = MakeAnalysisString(gloss); sense.MorphoSyntaxAnalysisRA = msa; return(entry); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create an allomorph. /// </summary> /// <param name="entry">The entry.</param> /// <param name="msa">The msa.</param> /// <param name="tssform">The tssform.</param> /// <param name="morphType">Type of the morph.</param> /// <param name="fLexemeForm">set to <c>true</c> to create a lexeme form.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static IMoForm CreateAllomorph(ILexEntry entry, IMoMorphSynAnalysis msa, ITsString tssform, IMoMorphType morphType, bool fLexemeForm) { IMoForm allomorph = null; switch (morphType.Guid.ToString()) { case Ling.MoMorphType.kguidMorphProclitic: // Fall through. case Ling.MoMorphType.kguidMorphClitic: // Fall through. case Ling.MoMorphType.kguidMorphEnclitic: Debug.Assert(msa is IMoStemMsa, "Wrong MSA for a clitic."); IMoStemMsa stemMsa = (IMoStemMsa) msa; goto case Ling.MoMorphType.kguidMorphBoundStem; case Ling.MoMorphType.kguidMorphRoot: // Fall through. case Ling.MoMorphType.kguidMorphBoundRoot: // Fall through. case Ling.MoMorphType.kguidMorphStem: // Fall through. case Ling.MoMorphType.kguidMorphParticle: // Fall through. case Ling.MoMorphType.kguidMorphPhrase: // Fall through. case Ling.MoMorphType.kguidMorphDiscontiguousPhrase: // Fall through. // AndyB_Yahoo: On particles, (and LT-485), these are always to be // roots that never take any affixes // AndyB_Yahoo: Therefore, they need to have StemMsas and Stem // allomorphs case Ling.MoMorphType.kguidMorphBoundStem: allomorph = new MoStemAllomorph(); break; default: // All others, which should get an non-stem MSA and an affix allo. Debug.Assert(!(msa is IMoStemMsa), "Wrong MSA for a affix."); allomorph = new MoAffixAllomorph(); break; } if (fLexemeForm) entry.LexemeFormOA = allomorph; else allomorph = (IMoForm) entry.AlternateFormsOS.Append(allomorph); allomorph.MorphTypeRA = morphType; // Has to be done before the next call. ITsString tssAllomorphForm = null; int maxLength = entry.Cache.MaxFieldLength((int) MoForm.MoFormTags.kflidForm); if (tssform.Length > maxLength) { string sMessage = String.Format(Strings.ksTruncatedXXXToYYYChars, fLexemeForm ? Strings.ksLexemeForm : Strings.ksAllomorph, maxLength); System.Windows.Forms.MessageBox.Show(sMessage, Strings.ksWarning, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); tssAllomorphForm = tssform.GetSubstring(0, maxLength); } else { tssAllomorphForm = tssform; } allomorph.FormMinusReservedMarkers = tssAllomorphForm; if ((morphType.Guid.ToString() == Ling.MoMorphType.kguidMorphInfix) || (morphType.Guid.ToString() == Ling.MoMorphType.kguidMorphInfixingInterfix)) { HandleInfix(entry, allomorph); } return allomorph; }
/// <summary> /// Execute the change requested by the current selection in the combo. /// Basically we want the MoInflClass indicated by m_selectedHvo, (even if 0?? not yet possible), /// to become the InflectionClass of each record that is appropriate to change. /// We do nothing to records where the check box is turned off, /// and nothing to ones that currently have an MSA other than an MoStemMsa, /// and nothing to ones that currently have an MSA with the wrong POS. /// (a) If the owning entry has an MoStemMsa with the right inflection class (and presumably POS), /// set the sense to use it. /// (b) If all senses using the current MoStemMsa are to be changed, just update /// the inflection class of that MoStemMsa. /// We could add this...but very probably unused MSAs would have been taken over /// when setting the POS. /// --(c) If the entry has an MoStemMsa which is not being used at all, change it to /// --the required POS and inflection class and use it. /// (d) Make a new MoStemMsa in the LexEntry with the required POS and inflection class /// and point the sense at it. /// </summary> public void DoIt(Set <int> itemsToChange, ProgressState state) { CheckDisposed(); int hvoPos = GetPOS(); // A Set of eligible parts of speech to use in filtering. Set <int> possiblePOS = GetPossiblePartsOfSpeech(); // Make a Dictionary from HVO of entry to list of modified senses. Dictionary <int, List <ILexSense> > sensesByEntry = new Dictionary <int, List <ILexSense> >(); int tagOwningEntry = m_cache.VwCacheDaAccessor.GetVirtualHandlerName("LexSense", "OwningEntry").Tag; int i = 0; // Report progress 50 times or every 100 items, whichever is more (but no more than once per item!) int interval = Math.Min(100, Math.Max(itemsToChange.Count / 50, 1)); foreach (int hvoSense in itemsToChange) { i++; if (i % interval == 0) { state.PercentDone = i * 20 / itemsToChange.Count; state.Breath(); } if (!IsItemEligible(m_cache.MainCacheAccessor, hvoSense, possiblePOS)) { continue; } ILexSense ls = (ILexSense)CmObject.CreateFromDBObject(m_cache, hvoSense, false); IMoMorphSynAnalysis msa = ls.MorphoSyntaxAnalysisRA; int hvoEntry = m_cache.MainCacheAccessor.get_ObjectProp(ls.Hvo, tagOwningEntry); if (!sensesByEntry.ContainsKey(hvoEntry)) { sensesByEntry[hvoEntry] = new List <ILexSense>(); } sensesByEntry[hvoEntry].Add(ls); } m_cache.BeginUndoTask(FdoUiStrings.ksUndoBEInflClass, FdoUiStrings.ksRedoBEInflClass); BulkEditBar.ForceRefreshOnUndoRedo(m_cache.MainCacheAccessor); i = 0; interval = Math.Min(100, Math.Max(sensesByEntry.Count / 50, 1)); foreach (KeyValuePair <int, List <ILexSense> > kvp in sensesByEntry) { i++; if (i % interval == 0) { state.PercentDone = i * 80 / sensesByEntry.Count + 20; state.Breath(); } ILexEntry entry = (ILexEntry)CmObject.CreateFromDBObject(m_cache, kvp.Key, false); List <ILexSense> sensesToChange = kvp.Value; IMoStemMsa msmTarget = null; foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC) { IMoStemMsa msm = msa as IMoStemMsa; if (msm != null && msm.InflectionClassRAHvo == m_selectedHvo) { // Can reuse this one! msmTarget = msm; break; } } if (msmTarget == null) { // See if we can reuse an existing MoStemMsa by changing it. // This is possible if it is used only by senses in the list, or not used at all. List <ILexSense> otherSenses = new List <ILexSense>(); if (entry.SensesOS.Count != sensesToChange.Count) { foreach (ILexSense ls in entry.SensesOS) { if (!sensesToChange.Contains(ls)) { otherSenses.Add(ls); } } } foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC) { IMoStemMsa msm = msa as IMoStemMsa; if (msm == null) { continue; } bool fOk = true; foreach (ILexSense ls in otherSenses) { if (ls.MorphoSyntaxAnalysisRA == msm) { fOk = false; break; } } if (fOk) { // Can reuse this one! Nothing we don't want to change uses it. // Adjust its POS as well as its inflection class, just to be sure. msmTarget = msm; msmTarget.PartOfSpeechRAHvo = hvoPos; msmTarget.InflectionClassRAHvo = m_selectedHvo; break; } } } if (msmTarget == null) { // Nothing we can reuse...make a new one. msmTarget = new MoStemMsa(); entry.MorphoSyntaxAnalysesOC.Add(msmTarget); msmTarget.PartOfSpeechRAHvo = hvoPos; msmTarget.InflectionClassRAHvo = m_selectedHvo; } // Finally! Make the senses we want to change use it. foreach (ILexSense ls in sensesToChange) { ls.MorphoSyntaxAnalysisRA = msmTarget; } } m_cache.EndUndoTask(); }
/// <summary> /// Make an entry with the specified lexeme form of the specified slot type, a sense with the specified gloss, /// an MSA with the specified part of speech, and generally hook things up as expected. /// Assumes all of the required objects need to be created; in general this might not be true, but it works /// for the test data here. /// </summary> private ILexEntry MakeEntry(string lf, string pos, Guid slotType, out IMoMorphSynAnalysis msa) { // The entry itself. ILexEntry entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create(); // Lexeme Form and MSA. IMoForm form; msa = GetMsaAndMoForm(entry, slotType, pos, out form); entry.LexemeFormOA = form; form.Form.VernacularDefaultWritingSystem = MakeVernString(lf); form.MorphTypeRA = Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(slotType); return entry; }
/// <summary> /// Get the hvo(s) for the Part of Speech for the various subclasses of MSA. /// N.B. If we add new subclasses or rearrange the class hierarchy, this will /// need to change. /// </summary> /// <param name="msa"></param> /// <returns></returns> private static IEnumerable <int> GetHvoOfMsaPartOfSpeech(IMoMorphSynAnalysis msa) { var result = new List <int>(); ICmPossibility pos; var affMsa = msa as IMoInflAffMsa; if (affMsa != null) { pos = affMsa.PartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } } var stemMsa = msa as IMoStemMsa; if (stemMsa != null) { pos = stemMsa.PartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } } var derivAffMsa = msa as IMoDerivAffMsa; if (derivAffMsa != null) { var derivMsa = derivAffMsa; pos = derivMsa.ToPartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } pos = derivMsa.FromPartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } } var stepMsa = msa as IMoDerivStepMsa; if (stepMsa != null) { pos = stepMsa.PartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } } var affixMsa = msa as IMoUnclassifiedAffixMsa; if (affixMsa != null) { pos = affixMsa.PartOfSpeechRA; if (pos != null) { result.Add(pos.Hvo); } } return(result); }
private ILexSense MakeSense(ILexEntry entry, string gloss, IMoMorphSynAnalysis msa) { // Bare bones of Sense var sense = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.AnalysisDefaultWritingSystem = MakeAnalysisString(gloss); sense.MorphoSyntaxAnalysisRA = msa; return sense; }
// TODO RandyR: Add ShortNameTSS and DeletionTextTSS. /// <summary> /// Determines whether the specified Object is equal to the current MoStemMsa. /// </summary> /// <param name="msa">The MoStemMsa to compare with the current MoStemMsa.</param> /// <returns>true if the specified MoStemMsa is equal to the current MoStemMsa; otherwise, false.</returns> public virtual bool EqualsMsa(IMoMorphSynAnalysis msa) { throw new ApplicationException("Subclasses must override this method."); }
/// <summary> /// /// </summary> /// <param name="msa"></param> /// <returns></returns> public static DummyGenericMSA Create(IMoMorphSynAnalysis msa) { switch (msa.ClassID) { case MoStemMsa.kclsidMoStemMsa: return new DummyGenericMSA(msa as IMoStemMsa); case MoInflAffMsa.kclsidMoInflAffMsa: return new DummyGenericMSA(msa as IMoInflAffMsa); case MoDerivAffMsa.kclsidMoDerivAffMsa: return new DummyGenericMSA(msa as IMoDerivAffMsa); case MoUnclassifiedAffixMsa.kclsidMoUnclassifiedAffixMsa: return new DummyGenericMSA(msa as IMoUnclassifiedAffixMsa); /* Not supported yet, so it throws an exception. case MoDerivStepMsa.kclsidMoDerivStepMsa: return new DummyGenericMSA(msa as MoDerivStepMsa); */ } return null; }
/// <summary> /// Switches select inbound references from the sourceMsa to 'this'. /// </summary> /// <param name="sourceMsa"></param> public void SwitchReferences(IMoMorphSynAnalysis sourceMsa) { foreach (LinkedObjectInfo loi in sourceMsa.LinkedObjects) { switch (loi.RelObjClass) { case WfiMorphBundle.kclsidWfiMorphBundle: { IWfiMorphBundle mb = WfiMorphBundle.CreateFromDBObject(m_cache, loi.RelObjId); mb.MsaRAHvo = Hvo; break; } case LexSense.kclsidLexSense: { ILexSense sense = LexSense.CreateFromDBObject(m_cache, loi.RelObjId); sense.MorphoSyntaxAnalysisRAHvo = Hvo; break; } } } }
public void InvalidAffixProcess(IMoAffixProcess affixProcess, bool isInvalidLhs, IMoMorphSynAnalysis msa) { Console.WriteLine("The affix process \"{0}\" is invalid.", affixProcess.Form.BestVernacularAlternative.Text); }
/// <summary> /// Check whether this sense or any of its subsenses uses the given MSA. /// </summary> /// <param name="msaOld"></param> /// <returns></returns> internal bool UsesMsa(IMoMorphSynAnalysis msaOld) { if (msaOld.Equals(MorphoSyntaxAnalysisRA)) // == doesn't work! See LT-7088. return true; foreach (LexSense ls in SensesOS) { if (ls.UsesMsa(msaOld)) return true; } return false; }
internal static XElement CreateMorphemeElement(IMoMorphSynAnalysis msa) { var msaElem = new XElement("Morpheme", new XAttribute("id", msa.Hvo)); switch (msa.ClassID) { case MoStemMsaTags.kClassId: var stemMsa = (IMoStemMsa) msa; msaElem.Add(new XAttribute("type", "stem")); if (stemMsa.PartOfSpeechRA != null) msaElem.Add(new XElement("Category", stemMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); if (stemMsa.FromPartsOfSpeechRC.Count > 0) msaElem.Add(new XElement("FromCategories", stemMsa.FromPartsOfSpeechRC.Select(pos => new XElement("Category", pos.Abbreviation.BestAnalysisAlternative.Text)))); if (stemMsa.InflectionClassRA != null) msaElem.Add(new XElement("InflClass", stemMsa.InflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); break; case MoDerivAffMsaTags.kClassId: var derivMsa = (IMoDerivAffMsa) msa; msaElem.Add(new XAttribute("type", "deriv")); if (derivMsa.FromPartOfSpeechRA != null) msaElem.Add(new XElement("FromCategory", derivMsa.FromPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); if (derivMsa.ToPartOfSpeechRA != null) msaElem.Add(new XElement("ToCategory", derivMsa.ToPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); if (derivMsa.ToInflectionClassRA != null) msaElem.Add(new XElement("ToInflClass", derivMsa.ToInflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); break; case MoUnclassifiedAffixMsaTags.kClassId: var unclassMsa = (IMoUnclassifiedAffixMsa) msa; msaElem.Add(new XAttribute("type", "unclass")); if (unclassMsa.PartOfSpeechRA != null) msaElem.Add(new XElement("Category", unclassMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); break; case MoInflAffMsaTags.kClassId: var inflMsa = (IMoInflAffMsa) msa; msaElem.Add(new XAttribute("type", "infl")); if (inflMsa.PartOfSpeechRA != null) msaElem.Add(new XElement("Category", inflMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); if (inflMsa.SlotsRC.Count > 0) { IMoInflAffixSlot slot = inflMsa.SlotsRC.First(); msaElem.Add(new XElement("Slot", new XAttribute("optional", slot.Optional), slot.Name.BestAnalysisAlternative.Text)); } break; } msaElem.Add(new XElement("HeadWord", msa.OwnerOfClass<ILexEntry>().HeadWord.Text)); msaElem.Add(new XElement("Gloss", msa.GetGlossOfFirstSense())); return msaElem; }
/// <summary> /// Check whether this LexEntry has any senses or subsenses that use the given MSA. /// </summary> /// <param name="msaOld"></param> /// <returns></returns> internal bool UsesMsa(IMoMorphSynAnalysis msaOld) { if (msaOld == null) return false; foreach (LexSense ls in this.SensesOS) { if (ls.UsesMsa(msaOld)) return true; } return false; }
public LMsa(IMoMorphSynAnalysis msa) : base(msa.Hvo) { m_name = msa.InterlinearName; }
/// <summary> /// Determines whether the specified MoDerivAffMsa is equal to the current MoDerivAffMsa. /// </summary> /// <param name="msa">The MoDerivAffMsa to compare with the current MoDerivAffMsa.</param> /// <returns>true if the specified MoDerivAffMsa is equal to the current MoDerivAffMsa; otherwise, false.</returns> public override bool EqualsMsa(IMoMorphSynAnalysis msa) { throw new NotImplementedException("'EqualsMsa' not implemneted on class MoDerivStepMsa."); }
/// <summary> /// Determines whether the specified MoInflAffMsa is equal to the current MoInflAffMsa. /// </summary> /// <param name="msa">The MoInflAffMsa to compare with the current MoInflAffMsa.</param> /// <returns>true if the specified MoInflAffMsa is equal to the current MoInflAffMsa; otherwise, false.</returns> public override bool EqualsMsa(IMoMorphSynAnalysis msa) { // This is the behavior defined by Object.Equals(). if (msa == null) return false; // Make sure that we can cast this object to a MoInflAffMsa. if (!(msa is IMoInflAffMsa)) return false; var inflMsa = (IMoInflAffMsa)msa; return DomainObjectServices.AreEquivalent(InflFeatsOA, inflMsa.InflFeatsOA) && FromProdRestrictRC.IsEquivalent(inflMsa.FromProdRestrictRC) && PartOfSpeechRA == inflMsa.PartOfSpeechRA && HasSameSlots(inflMsa); }
public void InvalidShape(string str, int errorPos, IMoMorphSynAnalysis msa) { Console.WriteLine("The form \"{0}\" contains an undefined phoneme at {1}.", str, errorPos); }
/// <summary> /// Determines whether the specified MoDerivAffMsa is equal to the current MoDerivAffMsa. /// </summary> /// <param name="msa">The MoDerivAffMsa to compare with the current MoDerivAffMsa.</param> /// <returns>true if the specified MoDerivAffMsa is equal to the current MoDerivAffMsa; otherwise, false.</returns> public override bool EqualsMsa(IMoMorphSynAnalysis msa) { // This is the behavior defined by Object.Equals(). if (msa == null) return false; // Make sure that we can cast this object to a MoUnclassifiedAffixMsa. if (!(msa is IMoUnclassifiedAffixMsa)) return false; var uncMsa = (IMoUnclassifiedAffixMsa)msa; return PartOfSpeechRA == uncMsa.PartOfSpeechRA; }
/// <summary> /// See if the owner of the feature structure is an endocentric compound. /// If so, use the stem msa of the head. /// </summary> /// <param name="fs">feature structure we're checking</param> /// <param name="msa">resulting msa, if any</param> private void TryEndocentricCompound(IFsFeatStruc fs, out IMoMorphSynAnalysis msa) { msa = null; // assume it is not IMoEndoCompound endo = CmObject.CreateFromDBObject(m_cache, fs.OwnerHVO) as IMoEndoCompound; if (endo != null) { int msaHvo; if (endo.HeadLast) msaHvo = endo.RightMsaOAHvo; else msaHvo = endo.LeftMsaOAHvo; msa = CmObject.CreateFromDBObject(m_cache, msaHvo) as IMoMorphSynAnalysis; } }
/// <summary> /// Get the hvo(s) for the Part of Speech for the various subclasses of MSA. /// N.B. If we add new subclasses or rearrange the class hierarchy, this will /// need to change. /// </summary> /// <param name="msa"></param> /// <returns></returns> private static List<int> GetHvoOfMsaPartOfSpeech(IMoMorphSynAnalysis msa) { var result = new List<int>(); ICmPossibility pos; if (msa is IMoInflAffMsa) { pos = ((IMoInflAffMsa) msa).PartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); } if (msa is IMoStemMsa) { pos = ((IMoStemMsa) msa).PartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); } if (msa is IMoDerivAffMsa) { var derivMsa = ((IMoDerivAffMsa) msa); pos = derivMsa.ToPartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); pos = derivMsa.FromPartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); } if (msa is IMoDerivStepMsa) { pos = ((IMoDerivStepMsa)msa).PartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); } if (msa is IMoUnclassifiedAffixMsa) { pos = ((IMoUnclassifiedAffixMsa)msa).PartOfSpeechRA; if (pos != null) result.Add(pos.Hvo); } return result; }
/// <summary> /// Determines whether the specified Object is equal to the current MoStemMsa. /// </summary> /// <param name="msa">The MoStemMsa to compare with the current MoStemMsa.</param> /// <returns>true if the specified MoStemMsa is equal to the current MoStemMsa; otherwise, false.</returns> public abstract bool EqualsMsa(IMoMorphSynAnalysis msa);
private int FindOrCreateMatchingStemMsa(IMoMorphSynAnalysis msa) { int hvoPOS = 0; if (msa is IMoInflAffMsa) hvoPOS = (msa as IMoInflAffMsa).PartOfSpeechRAHvo; else if (msa is IMoDerivAffMsa) hvoPOS = (msa as IMoDerivAffMsa).ToPartOfSpeechRAHvo; else if (msa is IMoDerivStepMsa) hvoPOS = (msa as IMoDerivStepMsa).PartOfSpeechRAHvo; else if (msa is IMoUnclassifiedAffixMsa) hvoPOS = (msa as IMoUnclassifiedAffixMsa).PartOfSpeechRAHvo; foreach (IMoMorphSynAnalysis msaT in this.MorphoSyntaxAnalysesOC) { IMoStemMsa msaStem = msaT as IMoStemMsa; if (msaStem != null && msaStem.PartOfSpeechRAHvo == hvoPOS && msaStem.FromPartsOfSpeechRC.Count == 0 && msaStem.InflectionClassRAHvo == 0 && msaStem.ProdRestrictRC.Count == 0 && msaStem.StratumRAHvo == 0 && msaStem.MsFeaturesOAHvo == 0) { return msaStem.Hvo; } } IMoStemMsa msaNew = new MoStemMsa(); this.MorphoSyntaxAnalysesOC.Add(msaNew); msaNew.PartOfSpeechRAHvo = hvoPOS; return msaNew.Hvo; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create an allomorph. /// </summary> /// <param name="entry">The entry.</param> /// <param name="msa">The msa.</param> /// <param name="tssform">The tssform.</param> /// <param name="morphType">Type of the morph.</param> /// <param name="fLexemeForm">set to <c>true</c> to create a lexeme form.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ internal static IMoForm CreateAllomorph(ILexEntry entry, IMoMorphSynAnalysis msa, ITsString tssform, IMoMorphType morphType, bool fLexemeForm) { MoForm allomorph = null; switch (morphType.Guid.ToString()) { case MoMorphTypeTags.kMorphProclitic: // Fall through. case MoMorphTypeTags.kMorphClitic: // Fall through. case MoMorphTypeTags.kMorphEnclitic: Debug.Assert(msa is MoStemMsa, "Wrong MSA for a clitic."); #pragma warning disable 168 var stemMsa = (IMoStemMsa)msa; #pragma warning restore 168 goto case MoMorphTypeTags.kMorphBoundStem; case MoMorphTypeTags.kMorphRoot: // Fall through. case MoMorphTypeTags.kMorphBoundRoot: // Fall through. case MoMorphTypeTags.kMorphStem: // Fall through. case MoMorphTypeTags.kMorphParticle: // Fall through. case MoMorphTypeTags.kMorphPhrase: // Fall through. case MoMorphTypeTags.kMorphDiscontiguousPhrase: // Fall through. // AndyB_Yahoo: On particles, (and LT-485), these are always to be // roots that never take any affixes // AndyB_Yahoo: Therefore, they need to have StemMsas and Stem // allomorphs case MoMorphTypeTags.kMorphBoundStem: allomorph = new MoStemAllomorph(); break; default: // All others, which should get an non-stem MSA and an affix allo. Debug.Assert(!(msa is IMoStemMsa), "Wrong MSA for a affix."); allomorph = new MoAffixAllomorph(); break; } if (fLexemeForm) entry.LexemeFormOA = allomorph; else entry.AlternateFormsOS.Add(allomorph); allomorph.MorphTypeRA = morphType; // Has to be done before the next call. ITsString tssAllomorphForm = tssform; allomorph.FormMinusReservedMarkers = tssAllomorphForm; if ((morphType.Guid == MoMorphTypeTags.kguidMorphInfix) || (morphType.Guid == MoMorphTypeTags.kguidMorphInfixingInterfix)) { HandleInfix(entry, allomorph); } return allomorph; }
private ILexSense AddLexSense(ILexEntry le, string defn, ICmSemanticDomain domain, IMoMorphSynAnalysis msa) { var servLoc = Cache.ServiceLocator; var ws = Cache.DefaultAnalWs; var ls = servLoc.GetInstance<ILexSenseFactory>().Create(); le.SensesOS.Add(ls); ls.Definition.set_String(ws, Cache.TsStrFactory.MakeString(defn, ws)); if (domain != null) ls.SemanticDomainsRC.Add(domain); var msaToAdd = msa ?? servLoc.GetInstance<IMoStemMsaFactory>().Create(); le.MorphoSyntaxAnalysesOC.Add(msaToAdd); ls.MorphoSyntaxAnalysisRA = msaToAdd; return ls; }
partial void FirstMorphemeRASideEffects(IMoMorphSynAnalysis oldObjValue, IMoMorphSynAnalysis newObjValue) { if (oldObjValue == newObjValue || (oldObjValue == null || !oldObjValue.CanDelete)) return; // Nothing to do. // Wipe out the old MSA. ((ILexEntry)oldObjValue.Owner).MorphoSyntaxAnalysesOC.Remove(oldObjValue); }
/// <summary> /// Switches select inbound references from the sourceMsa to 'this'. /// </summary> public void SwitchReferences(IMoMorphSynAnalysis sourceMsa) { foreach (var obj in sourceMsa.ReferringObjects) { if (obj is IWfiMorphBundle) { IWfiMorphBundle wmb = obj as IWfiMorphBundle; Debug.Assert(wmb.MsaRA == sourceMsa); wmb.MsaRA = this; } else if (obj is ILexSense) { ILexSense sense = obj as ILexSense; Debug.Assert(sense.MorphoSyntaxAnalysisRA == sourceMsa); sense.MorphoSyntaxAnalysisRA = this; } else { // Alert programmers to need for more code. Debug.Assert(obj is IWfiMorphBundle || obj is ILexSense); } } }
/// <summary> /// Handle launching of the MSA editor. /// </summary> protected override void HandleChooser() { VectorReferenceLauncher vrl = null; using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg()) { IFsFeatStruc originalFs = m_obj as IFsFeatStruc; Slice parentSlice = Slice; if (originalFs == null) { int owningFlid; int parentSliceClass = (int)parentSlice.Object.ClassID; switch (parentSliceClass) { case MoAffixAllomorphTags.kClassId: IMoAffixAllomorph allo = parentSlice.Object as IMoAffixAllomorph; owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid; dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, allo, owningFlid); break; /*case LexEntryInflTypeTags.kClassId: * ILexEntryInflType leit = parentSlice.Object as ILexEntryInflType; * owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid; * dlg.SetDlgInfo(m_cache, m_mediator, leit, owningFlid); * break;*/ default: IMoMorphSynAnalysis msa = parentSlice.Object as IMoMorphSynAnalysis; owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid; dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, msa, owningFlid); break; } } else { dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, originalFs, (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid); } const string ksPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='FeatureChooser']/"; dlg.Text = StringTable.Table.GetStringWithXPath("InflectionFeatureTitle", ksPath); dlg.Prompt = StringTable.Table.GetStringWithXPath("InflectionFeaturePrompt", ksPath); dlg.LinkText = StringTable.Table.GetStringWithXPath("InflectionFeatureLink", ksPath); DialogResult result = dlg.ShowDialog(parentSlice.FindForm()); if (result == DialogResult.OK) { // Note that this may set m_obj to null. dlg.FS will be null if all inflection features have been // removed. That is a valid state for this slice; m_obj deleted is not. m_obj = dlg.FS; m_msaInflectionFeatureListDlgLauncherView.Init(m_cache, dlg.FS); } else if (result == DialogResult.Yes) { // Get the VectorReferenceLauncher for the Inflection Features slice. // Since we're not changing tools, we want to change the chooser dialog. // See LT-5913 for motivation. Control ctl = this.Parent; while (ctl != null && !(ctl is Slice)) { ctl = ctl.Parent; } Slice slice = ctl as Slice; if (slice != null) { DataTree dt = slice.ContainingDataTree; for (int i = 0; i < dt.Slices.Count; ++i) { Slice sliceT = dt.FieldOrDummyAt(i); vrl = sliceT.Control as VectorReferenceLauncher; if (vrl != null) { if (vrl.Flid == PartOfSpeechTags.kflidInflectableFeats) { break; } vrl = null; } } } if (vrl == null) { // We do, too, need to change tools! Sometimes this slice shows up in a different context, // such as the main data entry view. See LT-7167. // go to m_highestPOS in editor // TODO: this should be reviewed by someone who knows how these links should be done // I'm just guessing. // Also, is there some way to know the application name and tool name without hard coding them? var linkJump = new FwLinkArgs("posEdit", dlg.HighestPOS.Guid); m_mediator.PostMessage("FollowLink", linkJump); } else { vrl.HandleExternalChooser(); } } } }
/// <summary> /// Determines whether the specified MoDerivAffMsa is equal to the current MoDerivAffMsa. /// </summary> /// <param name="msa">The MoDerivAffMsa to compare with the current MoDerivAffMsa.</param> /// <returns>true if the specified MoDerivAffMsa is equal to the current MoDerivAffMsa; otherwise, false.</returns> public override bool EqualsMsa(IMoMorphSynAnalysis msa) { // This is the behavior defined by Object.Equals(). if (msa == null) return false; // Make sure that we can cast this object to a MoDerivAffMsa. if (!(msa is IMoDerivAffMsa)) return false; var derivMsa = (IMoDerivAffMsa)msa; return (DomainObjectServices.AreEquivalent(FromMsFeaturesOA, derivMsa.FromMsFeaturesOA) && DomainObjectServices.AreEquivalent(ToMsFeaturesOA, derivMsa.ToMsFeaturesOA) && FromPartOfSpeechRA == derivMsa.FromPartOfSpeechRA && ToPartOfSpeechRA == derivMsa.ToPartOfSpeechRA && FromInflectionClassRA == derivMsa.FromInflectionClassRA && FromStemNameRA == derivMsa.FromStemNameRA && ToInflectionClassRA == derivMsa.ToInflectionClassRA && FromProdRestrictRC.IsEquivalent(derivMsa.FromProdRestrictRC) && ToProdRestrictRC.IsEquivalent(derivMsa.ToProdRestrictRC)); }
private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, ITsStrFactory tsf, IMoMorphSynAnalysis msa) { // JohnT: as described in LT-4633, a stem can be given an allomorph that // is an affix. So we need some sort of way to handle this. //Debug.Assert(msa is MoStemMsa); ITsString tssLabel = msa.InterlinearNameTSS; if (msa is IMoStemMsa && (msa as IMoStemMsa).PartOfSpeechRA == null) tssLabel = tsf.MakeString( m_sUnknown, Cache.ServiceLocator.WritingSystemManager.UserWs); var node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); return node; }
/// <summary> /// Determines whether the specified Object is equal to the current MoStemMsa. /// </summary> /// <param name="msa">The MoStemMsa to compare with the current MoStemMsa.</param> /// <returns>true if the specified MoStemMsa is equal to the current MoStemMsa; otherwise, false.</returns> public override bool EqualsMsa(IMoMorphSynAnalysis msa) { // This is the behavior defined by Object.Equals(). if (msa == null) return false; // Make sure that we can cast this object to a MoStemMsa. if (!(msa is IMoStemMsa)) return false; var stemMsa = (IMoStemMsa)msa; // TODO: Add checks for other properties, when we support using them. if (stemMsa.PartOfSpeechRA != PartOfSpeechRA) return false; if (stemMsa.InflectionClassRA != InflectionClassRA) return false; if (!DomainObjectServices.AreEquivalent(MsFeaturesOA, stemMsa.MsFeaturesOA)) return false; if (!FromPartsOfSpeechRC.IsEquivalent(stemMsa.FromPartsOfSpeechRC)) return false; return ProdRestrictRC.IsEquivalent(stemMsa.ProdRestrictRC); }