Esempio n. 1
0
        // Добавляем ссылку на организацию, также добавляем имена
        internal void AddOrgReferent(Pullenti.Ner.Referent org)
        {
            if (org == null)
            {
                return;
            }
            bool nam = false;

            this.AddSlot(ATTR_REF, org, false, 0);
            GeoReferent geo     = null;
            string      specTyp = null;
            string      num     = org.GetStringValue("NUMBER");

            foreach (Pullenti.Ner.Slot s in org.Slots)
            {
                if (s.TypeName == "NAME")
                {
                    if (num == null)
                    {
                        this.AddName(s.Value as string);
                    }
                    else
                    {
                        this.AddName(string.Format("{0}-{1}", s.Value, num));
                    }
                    nam = true;
                }
                else if (s.TypeName == "TYPE")
                {
                    string v = s.Value as string;
                    if (v == "СЕЛЬСКИЙ СОВЕТ")
                    {
                        this.AddTyp("сельский округ");
                    }
                    else if (v == "ГОРОДСКОЙ СОВЕТ")
                    {
                        this.AddTyp("городской округ");
                    }
                    else if (v == "ПОСЕЛКОВЫЙ СОВЕТ")
                    {
                        this.AddTyp("поселковый округ");
                    }
                    else if (v == "аэропорт")
                    {
                        specTyp = v.ToUpper();
                    }
                }
                else if (s.TypeName == "GEO" && (s.Value is GeoReferent))
                {
                    geo = s.Value as GeoReferent;
                }
            }
            if (!nam)
            {
                foreach (Pullenti.Ner.Slot s in org.Slots)
                {
                    if (s.TypeName == "EPONYM")
                    {
                        if (num == null)
                        {
                            this.AddName((s.Value as string).ToUpper());
                        }
                        else
                        {
                            this.AddName(string.Format("{0}-{1}", (s.Value as string).ToUpper(), num));
                        }
                        nam = true;
                    }
                }
            }
            if (!nam && num != null)
            {
                foreach (Pullenti.Ner.Slot s in org.Slots)
                {
                    if (s.TypeName == "TYPE")
                    {
                        this.AddName(string.Format("{0}-{1}", (s.Value as string).ToUpper(), num));
                        nam = true;
                    }
                }
            }
            if (geo != null && !nam)
            {
                foreach (string n in geo.GetStringValues(ATTR_NAME))
                {
                    this.AddName(n);
                    if (specTyp != null)
                    {
                        this.AddName(string.Format("{0} {1}", n, specTyp));
                        this.AddName(string.Format("{0} {1}", specTyp, n));
                    }
                    nam = true;
                }
            }
            if (!nam)
            {
                this.AddName(org.ToString(true, Pullenti.Morph.MorphLang.Unknown, 0).ToUpper());
            }
        }