public OrgItemTypeTermin(string s, Pullenti.Morph.MorphLang lang = null, Pullenti.Ner.Org.OrgProfile p1 = Pullenti.Ner.Org.OrgProfile.Undefined, Pullenti.Ner.Org.OrgProfile p2 = Pullenti.Ner.Org.OrgProfile.Undefined) : base(s, lang, false) { if (p1 != Pullenti.Ner.Org.OrgProfile.Undefined) { Profiles.Add(p1); } if (p2 != Pullenti.Ner.Org.OrgProfile.Undefined) { Profiles.Add(p2); } }
public override string GetImageId(Pullenti.Ner.Referent obj = null) { if (obj is Pullenti.Ner.Org.OrganizationReferent) { List <Pullenti.Ner.Org.OrgProfile> prs = (obj as Pullenti.Ner.Org.OrganizationReferent).Profiles; if (prs != null && prs.Count > 0) { Pullenti.Ner.Org.OrgProfile pr = prs[prs.Count - 1]; return(pr.ToString()); } } return(OrgImageId); }
public static List <OrgItemTypeTermin> DeserializeSrc(XmlNode xml, OrgItemTypeTermin set) { List <OrgItemTypeTermin> res = new List <OrgItemTypeTermin>(); bool isSet = xml.LocalName == "set"; if (isSet) { res.Add((set = new OrgItemTypeTermin(null))); } if (xml.Attributes == null) { return(res); } foreach (XmlAttribute a in xml.Attributes) { string nam = a.LocalName; if (!nam.StartsWith("name")) { continue; } Pullenti.Morph.MorphLang lang = Pullenti.Morph.MorphLang.RU; if (nam == "nameUa") { lang = Pullenti.Morph.MorphLang.UA; } else if (nam == "nameEn") { lang = Pullenti.Morph.MorphLang.EN; } OrgItemTypeTermin it = null; foreach (string s in a.Value.Split(';')) { if (!string.IsNullOrEmpty(s)) { if (it == null) { res.Add((it = new OrgItemTypeTermin(s, lang))); if (set != null) { it.CopyFrom(set); } } else { it.AddVariant(s, false); } } } } foreach (XmlAttribute a in xml.Attributes) { string nam = a.LocalName; if (nam.StartsWith("name")) { continue; } if (nam.StartsWith("abbr")) { Pullenti.Morph.MorphLang lang = Pullenti.Morph.MorphLang.RU; if (nam == "abbrUa") { lang = Pullenti.Morph.MorphLang.UA; } else if (nam == "abbrEn") { lang = Pullenti.Morph.MorphLang.EN; } foreach (OrgItemTypeTermin r in res) { if (r.Lang == lang) { r.Acronym = a.Value; } } continue; } if (nam == "profile") { List <Pullenti.Ner.Org.OrgProfile> li = new List <Pullenti.Ner.Org.OrgProfile>(); foreach (string s in a.Value.Split(';')) { try { Pullenti.Ner.Org.OrgProfile p = (Pullenti.Ner.Org.OrgProfile)Enum.Parse(typeof(Pullenti.Ner.Org.OrgProfile), s, true); if (p != Pullenti.Ner.Org.OrgProfile.Undefined) { li.Add(p); } } catch (Exception ex) { } } foreach (OrgItemTypeTermin r in res) { r.Profiles = li; } continue; } if (nam == "coef") { float v = float.Parse(a.Value); foreach (OrgItemTypeTermin r in res) { r.Coeff = v; } continue; } if (nam == "partofname") { foreach (OrgItemTypeTermin r in res) { r.MustBePartofName = a.Value == "true"; } continue; } if (nam == "top") { foreach (OrgItemTypeTermin r in res) { r.IsTop = a.Value == "true"; } continue; } if (nam == "geo") { foreach (OrgItemTypeTermin r in res) { r.CanBeSingleGeo = a.Value == "true"; } continue; } if (nam == "purepref") { foreach (OrgItemTypeTermin r in res) { r.IsPurePrefix = a.Value == "true"; } continue; } if (nam == "number") { foreach (OrgItemTypeTermin r in res) { r.CanHasNumber = a.Value == "true"; } continue; } throw new Exception("Unknown Org Type Tag: " + a.Name); } return(res); }