private static void WriteStemNameAffixElement(XmlWriter writer, FdoCache cache, string props) { if (string.IsNullOrEmpty(props)) { return; } string[] propsArray = props.Trim().Split(' '); foreach (string prop in propsArray) { int i = prop.IndexOf("StemNameAffix", StringComparison.Ordinal); if (i > -1) { string id = (prop.Substring(i + 13)).Trim(); IMoStemName sn = cache.ServiceLocator.GetInstance <IMoStemNameRepository>().GetObject(Convert.ToInt32(id)); if (sn != null) { writer.WriteStartElement("stemNameAffix"); writer.WriteAttributeString("id", id); writer.WriteString(sn.Name.BestAnalysisAlternative.Text); writer.WriteEndElement(); } } } }
/// <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> /// Add a MoStemName to the collection. /// </summary> /// <param name="sn">The MoStemName to add.</param> public IMoStemName Add(IMoStemName sn) { Debug.Assert(sn != null); IMoStemName snAdd = (IMoStemName)ValidateObject(sn); List.Add(snAdd); return(snAdd); }
protected void ConvertStemName(XmlDocument doc, XmlNode node, IMoForm form, XmlNode tempNode) { IMoStemAllomorph sallo = form as IMoStemAllomorph; IMoStemName sn = sallo.StemNameRA; if (sn != null) { tempNode = CreateXmlElement(doc, "stemName", node); CreateXmlAttribute(doc, "id", sn.Hvo.ToString(), tempNode); tempNode.InnerXml = CreateEntities(sn.Name.BestAnalysisAlternative.Text); } else { // There's no overt stem name on this allomorph, but there might be overt stem names // on other allomorphs in this lexical entry. This allomorph, then, cannot bear any // of the features of these other stem names. If so, there will be a property named // NotStemNameddd or NotStemNamedddNotStemNamedddd, etc. tempNode = CreateNotStemNameElement(doc, node, tempNode); } }
private static void WriteStemNameElement(XmlWriter writer, IMoForm form, string props) { var sallo = form as IMoStemAllomorph; Debug.Assert(sallo != null); IMoStemName sn = sallo.StemNameRA; if (sn != null) { writer.WriteStartElement("stemName"); writer.WriteAttributeString("id", sn.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteString(sn.Name.BestAnalysisAlternative.Text); writer.WriteEndElement(); //stemName } else { // There's no overt stem name on this allomorph, but there might be overt stem names // on other allomorphs in this lexical entry. This allomorph, then, cannot bear any // of the features of these other stem names. If so, there will be a property named // NotStemNameddd or NotStemNamedddNotStemNamedddd, etc. WriteNotStemNameElement(writer, props); } }
private static XElement ExportStemName(IMoStemName stemName, Icu.UNormalizationMode mode) { return new XElement("MoStemName", new XAttribute("Id", stemName.Hvo), ExportBestAnalysis(stemName.Name, "Name", mode), ExportBestAnalysis(stemName.Description, "Description", mode), ExportBestAnalysis(stemName.Abbreviation, "Abbreviation", mode), new XElement("Regions", from region in stemName.RegionsOC select ExportFeatureStructure(region))); }
/// <summary> /// Add a MoStemName to the collection. /// </summary> /// <param name="sn">The MoStemName to add.</param> public IMoStemName Add(IMoStemName sn) { Debug.Assert(sn != null); IMoStemName snAdd = (IMoStemName)ValidateObject(sn); List.Add(snAdd); return snAdd; }