Exemple #1
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();

            if (Name != null)
            {
                res.Append(Name);
            }
            foreach (Pullenti.Ner.Slot r in Slots)
            {
                if (r.TypeName == ATTR_ATTR && r.Value != null)
                {
                    res.AppendFormat(", {0}", r.Value.ToString());
                }
            }
            foreach (Pullenti.Ner.Slot r in Slots)
            {
                if (r.TypeName == ATTR_REF && (r.Value is Pullenti.Ner.Referent) && (lev < 10))
                {
                    res.AppendFormat("; {0}", (r.Value as Pullenti.Ner.Referent).ToString(shortVariant, lang, lev + 1));
                }
            }
            PersonPropertyReferent hi = Higher;

            if (hi != null && hi != this && this.CheckCorrectHigher(hi, 0))
            {
                res.AppendFormat("; {0}", hi.ToString(shortVariant, lang, lev + 1));
            }
            return(res.ToString());
        }
Exemple #2
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            if (IsRelative && !shortVariant)
            {
                StringBuilder res = new StringBuilder();
                res.Append(this.ToString(true, lang, lev));
                Pullenti.Ner.Date.Internal.DateRelHelper.AppendToString2(this, res);
                return(res.ToString());
            }
            string fr = (DateFrom == null ? null : DateFrom._ToString(shortVariant, lang, lev, 1));
            string to = (DateTo == null ? null : DateTo._ToString(shortVariant, lang, lev, 2));

            if (fr != null && to != null)
            {
                return(string.Format("{0} {1}", fr, (DateTo.Century > 0 && DateTo.Year == 0 ? to : to.ToLower())));
            }
            if (fr != null)
            {
                return(fr.ToString());
            }
            if (to != null)
            {
                return(to);
            }
            return(string.Format("{0} ? по ?", (lang.IsUa ? 'з' : 'с')));
        }
        internal void Deserialize(Stream stream)
        {
            m_Class = new Pullenti.Morph.MorphClass()
            {
                Value = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream)
            };
            m_Case = new Pullenti.Morph.MorphCase()
            {
                Value = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream)
            };
            m_Gender   = (Pullenti.Morph.MorphGender)Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream);
            m_Number   = (Pullenti.Morph.MorphNumber)Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream);
            m_Voice    = (Pullenti.Morph.MorphVoice)Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream);
            m_Language = new Pullenti.Morph.MorphLang()
            {
                Value = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeShort(stream)
            };
            int cou = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeInt(stream);

            m_Items = new List <Pullenti.Morph.MorphBaseInfo>();
            for (int i = 0; i < cou; i++)
            {
                Pullenti.Morph.MorphBaseInfo it = this.DeserializeItem(stream);
                if (it != null)
                {
                    m_Items.Add(it);
                }
            }
            m_NeedRecalc = false;
        }
Exemple #4
0
 /// <summary>
 /// Инициализация SDK.
 /// Вызывать в самом начале работы. Инициализируется морфология (MorphologyService),
 /// служба процессоров (ProcessorService), все доступные анализаторы сущностей и
 /// семантический анализ (SemanticService). Так что больше ничего инициализировать не нужно.
 /// </summary>
 /// <param name="lang">по умолчанию, русский и английский</param>
 public static void Initialize(Pullenti.Morph.MorphLang lang = null)
 {
     // сначала инициализация всего сервиса
     Pullenti.Ner.ProcessorService.Initialize(lang);
     // а затем конкретные анализаторы (какие нужно, в данном случае - все)
     Pullenti.Ner.Money.MoneyAnalyzer.Initialize();
     Pullenti.Ner.Uri.UriAnalyzer.Initialize();
     Pullenti.Ner.Phone.PhoneAnalyzer.Initialize();
     Pullenti.Ner.Date.DateAnalyzer.Initialize();
     Pullenti.Ner.Keyword.KeywordAnalyzer.Initialize();
     Pullenti.Ner.Definition.DefinitionAnalyzer.Initialize();
     Pullenti.Ner.Denomination.DenominationAnalyzer.Initialize();
     Pullenti.Ner.Measure.MeasureAnalyzer.Initialize();
     Pullenti.Ner.Bank.BankAnalyzer.Initialize();
     Pullenti.Ner.Geo.GeoAnalyzer.Initialize();
     Pullenti.Ner.Address.AddressAnalyzer.Initialize();
     Pullenti.Ner.Org.OrganizationAnalyzer.Initialize();
     Pullenti.Ner.Person.PersonAnalyzer.Initialize();
     Pullenti.Ner.Mail.MailAnalyzer.Initialize();
     Pullenti.Ner.Transport.TransportAnalyzer.Initialize();
     Pullenti.Ner.Decree.DecreeAnalyzer.Initialize();
     Pullenti.Ner.Instrument.InstrumentAnalyzer.Initialize();
     Pullenti.Ner.Titlepage.TitlePageAnalyzer.Initialize();
     Pullenti.Ner.Booklink.BookLinkAnalyzer.Initialize();
     Pullenti.Ner.Goods.GoodsAnalyzer.Initialize();
     Pullenti.Ner.Named.NamedEntityAnalyzer.Initialize();
     Pullenti.Ner.Weapon.WeaponAnalyzer.Initialize();
     // ещё инициализируем семантическую обработки (в принципе, она не используется для задачи NER)
     Pullenti.Semantic.SemanticService.Initialize();
 }
Exemple #5
0
        /// <summary>
        /// Преобразовать внутреннее значение в строку указанного языка
        /// </summary>
        /// <param name="lang">язык</param>
        /// <return>значение</return>
        public string ConvertValueToString(Pullenti.Morph.MorphLang lang)
        {
            if (Value == null)
            {
                return(null);
            }
            Pullenti.Ner.Metadata.Feature attr = DefiningFeature;
            if (attr == null)
            {
                return(Value.ToString());
            }
            object v = (object)attr.ConvertInnerValueToOuterValue(Value.ToString(), lang);

            if (v == null)
            {
                return(null);
            }
            if (v is string)
            {
                return(v as string);
            }
            else
            {
                return(v.ToString());
            }
        }
Exemple #6
0
        public string ConvertInnerValueToOuterValue(string innerValue, Pullenti.Morph.MorphLang lang = null)
        {
            if (innerValue == null)
            {
                return(null);
            }
            string val = innerValue.ToString();

            for (int i = 0; i < InnerValues.Count; i++)
            {
                if (string.Compare(InnerValues[i], val, true) == 0 && (i < OuterValues.Count))
                {
                    if (lang != null)
                    {
                        if (lang.IsUa && (i < OuterValuesUA.Count) && OuterValuesUA[i] != null)
                        {
                            return(OuterValuesUA[i]);
                        }
                        if (lang.IsEn && (i < OuterValuesEN.Count) && OuterValuesEN[i] != null)
                        {
                            return(OuterValuesEN[i]);
                        }
                    }
                    return(OuterValues[i]);
                }
            }
            return(innerValue);
        }
Exemple #7
0
        /// <summary>
        /// Найти для слова его толковую информацию (среди дериватных групп)
        /// </summary>
        /// <param name="word">слово в верхнем регистре и нормальной форме</param>
        /// <param name="lang">возможный язык</param>
        /// <return>список слов DerivateWord</return>
        public static List <DerivateWord> FindWords(string word, Pullenti.Morph.MorphLang lang = null)
        {
            List <DerivateGroup> grs = m_DerRu.Find(word, false, lang);

            if (grs == null)
            {
                return(null);
            }
            List <DerivateWord> res = null;

            foreach (DerivateGroup g in grs)
            {
                foreach (DerivateWord w in g.Words)
                {
                    if (w.Spelling == word)
                    {
                        if (res == null)
                        {
                            res = new List <DerivateWord>();
                        }
                        res.Add(w);
                    }
                }
            }
            return(res);
        }
Exemple #8
0
        public bool Init(Pullenti.Morph.MorphLang lang, bool lazy)
        {
            if (m_Inited)
            {
                return(true);
            }
            Assembly assembly = Assembly.GetExecutingAssembly();
            string   rsname   = string.Format("d_{0}.dat", lang.ToString());

            string[] names = assembly.GetManifestResourceNames();
            foreach (string n in names)
            {
                if (n.EndsWith(rsname, StringComparison.OrdinalIgnoreCase))
                {
                    object inf = assembly.GetManifestResourceInfo(n);
                    if (inf == null)
                    {
                        continue;
                    }
                    using (Stream stream = assembly.GetManifestResourceStream(n))
                    {
                        stream.Position = 0;
                        m_AllGroups.Clear();
                        this.Deserialize(stream, lazy);
                        Lang = lang;
                    }
                    m_Inited = true;
                    return(true);
                }
            }
            return(false);
        }
Exemple #9
0
 public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
 {
     if (shortVariant)
     {
         return(this.toShortString(lang));
     }
     else
     {
         string res = this.toFullString(ShowLastnameOnFirstPosition, lang);
         if (this.FindSlot(ATTR_NICKNAME, null, true) == null)
         {
             return(res);
         }
         List <string> niks = this.GetStringValues(ATTR_NICKNAME);
         if (niks.Count == 1)
         {
             return(string.Format("{0} ({1})", res, Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(niks[0])));
         }
         StringBuilder tmp = new StringBuilder();
         tmp.Append(res);
         tmp.Append(" (");
         foreach (string s in niks)
         {
             if (s != niks[0])
             {
                 tmp.Append(", ");
             }
             tmp.Append(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(s));
         }
         tmp.Append(")");
         return(tmp.ToString());
     }
 }
Exemple #10
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();

            foreach (Pullenti.Ner.Slot s in Slots)
            {
                if (s.Value is Pullenti.Ner.Uri.UriReferent)
                {
                    if ((s.Value as Pullenti.Ner.Uri.UriReferent).Scheme == "Р/С")
                    {
                        res.Append(s.Value.ToString());
                        break;
                    }
                }
            }
            if (res.Length == 0)
            {
                res.Append(this.GetStringValue(ATTR_ITEM) ?? "?");
            }
            if (ParentReferent != null && !shortVariant && (lev < 20))
            {
                res.AppendFormat(", {0}", ParentReferent.ToString(true, lang, lev + 1));
            }
            return(res.ToString());
        }
Exemple #11
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();

            res.Append(Typ ?? "?");
            if (Number != null)
            {
                res.AppendFormat(" №{0}", Number);
            }
            if (State != null)
            {
                res.AppendFormat(", {0}", State.ToString(true, lang, lev + 1));
            }
            if (!shortVariant)
            {
                string dat = this.GetStringValue(ATTR_DATE);
                string org = this.GetStringValue(ATTR_ORG);
                if (dat != null || org != null)
                {
                    res.Append(", выдан");
                    if (dat != null)
                    {
                        res.AppendFormat(" {0}", dat);
                    }
                    if (org != null)
                    {
                        res.AppendFormat(" {0}", org);
                    }
                }
            }
            return(res.ToString());
        }
Exemple #12
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            string        v   = this.GetStringValue(ATTR_VALUE);
            int           r   = Rest;

            if (v != null || r > 0)
            {
                res.Append(v ?? "0");
                int cou = 0;
                for (int i = res.Length - 1; i > 0; i--)
                {
                    if ((++cou) == 3)
                    {
                        res.Insert(i, '.');
                        cou = 0;
                    }
                }
            }
            else
            {
                res.Append("?");
            }
            if (r > 0)
            {
                res.AppendFormat(",{0}", r.ToString("D02"));
            }
            res.AppendFormat(" {0}", Currency);
            return(res.ToString());
        }
Exemple #13
0
 public string CorrectWordByMorph(string word, Pullenti.Morph.MorphLang lang)
 {
     if (Pullenti.Morph.LanguageHelper.IsCyrillicChar(word[0]))
     {
         if (lang != null)
         {
             if (m_EngineRu.Language.IsRu && lang.IsRu)
             {
                 return(m_EngineRu.CorrectWordByMorph(word));
             }
             if (m_EngineUa.Language.IsUa && lang.IsUa)
             {
                 return(m_EngineUa.CorrectWordByMorph(word));
             }
             if (m_EngineBy.Language.IsBy && lang.IsBy)
             {
                 return(m_EngineBy.CorrectWordByMorph(word));
             }
             if (m_EngineKz.Language.IsKz && lang.IsKz)
             {
                 return(m_EngineKz.CorrectWordByMorph(word));
             }
         }
         return(m_EngineRu.CorrectWordByMorph(word));
     }
     else
     {
         return(m_EngineEn.CorrectWordByMorph(word));
     }
 }
Exemple #14
0
 public List <Pullenti.Morph.MorphWordForm> GetAllWordforms(string word, Pullenti.Morph.MorphLang lang)
 {
     if (Pullenti.Morph.LanguageHelper.IsCyrillicChar(word[0]))
     {
         if (lang != null)
         {
             if (m_EngineRu.Language.IsRu && lang.IsRu)
             {
                 return(m_EngineRu.GetAllWordforms(word));
             }
             if (m_EngineUa.Language.IsUa && lang.IsUa)
             {
                 return(m_EngineUa.GetAllWordforms(word));
             }
             if (m_EngineBy.Language.IsBy && lang.IsBy)
             {
                 return(m_EngineBy.GetAllWordforms(word));
             }
             if (m_EngineKz.Language.IsKz && lang.IsKz)
             {
                 return(m_EngineKz.GetAllWordforms(word));
             }
         }
         return(m_EngineRu.GetAllWordforms(word));
     }
     else
     {
         return(m_EngineEn.GetAllWordforms(word));
     }
 }
Exemple #15
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            string        typ = this.GetStringValue(ATTR_TYPE);

            if (typ != null)
            {
                res.Append(typ);
            }
            string name = this.GetStringValue(ATTR_NAME);

            if (name != null)
            {
                if (res.Length > 0)
                {
                    res.Append(' ');
                }
                res.Append(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(name));
            }
            Pullenti.Ner.Referent re = this.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent;
            if (re != null)
            {
                if (res.Length > 0)
                {
                    res.Append("; ");
                }
                res.Append(re.ToString(shortVariant, lang, lev + 1));
            }
            return(res.ToString());
        }
Exemple #16
0
        /// <summary>
        /// Вывести только единицы измерения
        /// </summary>
        /// <param name="lang">язык</param>
        /// <return>строка с результатом</return>
        public string OutUnits(Pullenti.Morph.MorphLang lang = null)
        {
            List <UnitReferent> uu = Units;

            if (uu.Count == 0)
            {
                return("");
            }
            StringBuilder res = new StringBuilder();

            res.Append(uu[0].ToString(true, lang, 0));
            for (int i = 1; i < uu.Count; i++)
            {
                string pow = uu[i].GetStringValue(UnitReferent.ATTR_POW);
                if (!string.IsNullOrEmpty(pow) && pow[0] == '-')
                {
                    res.AppendFormat("/{0}", uu[i].ToString(true, lang, 1));
                    if (pow != "-1")
                    {
                        res.AppendFormat("<{0}>", pow.Substring(1));
                    }
                }
                else
                {
                    res.AppendFormat("*{0}", uu[i].ToString(true, lang, 0));
                }
            }
            return(res.ToString());
        }
Exemple #17
0
 internal void LoadLanguages(Pullenti.Morph.MorphLang langs, bool lazyLoad)
 {
     if (langs.IsRu && !m_EngineRu.Language.IsRu)
     {
         lock (m_Lock)
         {
             if (!m_EngineRu.Language.IsRu)
             {
                 if (!m_EngineRu.Initialize(Pullenti.Morph.MorphLang.RU, lazyLoad))
                 {
                     throw new Exception("Not found resource file m_ru.dat in Morphology");
                 }
             }
         }
     }
     if (langs.IsEn && !m_EngineEn.Language.IsEn)
     {
         lock (m_Lock)
         {
             if (!m_EngineEn.Language.IsEn)
             {
                 if (!m_EngineEn.Initialize(Pullenti.Morph.MorphLang.EN, lazyLoad))
                 {
                     throw new Exception("Not found resource file m_en.dat in Morphology");
                 }
             }
         }
     }
     if (langs.IsUa && !m_EngineUa.Language.IsUa)
     {
         lock (m_Lock)
         {
             if (!m_EngineUa.Language.IsUa)
             {
                 m_EngineUa.Initialize(Pullenti.Morph.MorphLang.UA, lazyLoad);
             }
         }
     }
     if (langs.IsBy && !m_EngineBy.Language.IsBy)
     {
         lock (m_Lock)
         {
             if (!m_EngineBy.Language.IsBy)
             {
                 m_EngineBy.Initialize(Pullenti.Morph.MorphLang.BY, lazyLoad);
             }
         }
     }
     if (langs.IsKz && !m_EngineKz.Language.IsKz)
     {
         lock (m_Lock)
         {
             if (!m_EngineKz.Language.IsKz)
             {
                 m_EngineKz.Initialize(Pullenti.Morph.MorphLang.KZ, lazyLoad);
             }
         }
     }
 }
Exemple #18
0
 CharNode _getRoot(Pullenti.Morph.MorphLang lang, bool isLat)
 {
     if (lang != null && lang.IsUa && !lang.IsRu)
     {
         return(m_RootUa);
     }
     return(m_Root);
 }
Exemple #19
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            string misc = this.GetStringValue(ATTR_TERMIN_ADD);

            if (misc == null)
            {
                misc = this.GetStringValue(ATTR_MISC);
            }
            return(string.Format("[{0}] {1}{2} = {3}", Kind.ToString(), Termin ?? "?", (misc == null ? "" : string.Format(" ({0})", misc)), Value ?? "?"));
        }
Exemple #20
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();

            foreach (GoodAttributeReferent a in Attrs)
            {
                res.AppendFormat("{0} ", a.ToString(true, lang, lev));
            }
            return(res.ToString().Trim());
        }
Exemple #21
0
 /// <summary>
 /// Инициализация внутренних словарей.
 /// Можно не вызывать, но тогда будет автоматически вызвано при первом обращении,
 /// и соответственно первое обращение отработает на несколько секунд дольше.
 /// Если инициализация идёт через Sdk.Initialize или ProcessorService.Initialize, то эту функцию вызывать не надо.
 /// </summary>
 /// <param name="langs">по умолчанию, русский с украинским</param>
 public static void Initialize(Pullenti.Morph.MorphLang langs = null)
 {
     if (langs == null || langs.IsUndefined)
     {
         langs = Pullenti.Morph.MorphLang.RU;
     }
     Pullenti.Semantic.Internal.NextModelHelper.Initialize();
     ControlModelQuestion.Initialize();
     LoadLanguages(langs);
 }
Exemple #22
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            object        a   = this.GetSlotValue(ATTR_AUTHOR);

            if (a != null)
            {
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_AUTHOR)
                    {
                        if (a != s.Value)
                        {
                            res.Append(", ");
                        }
                        if (s.Value is Pullenti.Ner.Referent)
                        {
                            res.Append((s.Value as Pullenti.Ner.Referent).ToString(true, lang, lev + 1));
                        }
                        else if (s.Value is string)
                        {
                            res.Append(s.Value as string);
                        }
                    }
                }
                if (AuthorsAndOther)
                {
                    res.Append(" и др.");
                }
            }
            string nam = Name;

            if (nam != null)
            {
                if (res.Length > 0)
                {
                    res.Append(' ');
                }
                if (nam.Length > 200)
                {
                    nam = nam.Substring(0, 200) + "...";
                }
                res.AppendFormat("\"{0}\"", nam);
            }
            Pullenti.Ner.Uri.UriReferent uri = this.GetSlotValue(ATTR_URL) as Pullenti.Ner.Uri.UriReferent;
            if (uri != null)
            {
                res.AppendFormat(" [{0}]", uri.ToString());
            }
            if (Year > 0)
            {
                res.AppendFormat(", {0}", Year);
            }
            return(res.ToString());
        }
Exemple #23
0
        List <Termin> _FindInTree(string key, Pullenti.Morph.MorphLang lang)
        {
            if (key == null)
            {
                return(null);
            }
            CharNode nod = this._getRoot(lang, ((lang == null || lang.IsUndefined)) && Pullenti.Morph.LanguageHelper.IsLatin(key));

            for (int i = 0; i < key.Length; i++)
            {
                short    ch = (short)key[i];
                CharNode nn = null;
                if (nod.Children != null)
                {
                    nod.Children.TryGetValue(ch, out nn);
                }
                if (nn == null)
                {
                    if (ch == 32)
                    {
                        if (nod.Termins != null)
                        {
                            string[]      pp  = key.Split(' ');
                            List <Termin> res = null;
                            foreach (Termin t in nod.Termins)
                            {
                                if (t.Terms.Count == pp.Length)
                                {
                                    int k;
                                    for (k = 1; k < pp.Length; k++)
                                    {
                                        if (!t.Terms[k].Variants.Contains(pp[k]))
                                        {
                                            break;
                                        }
                                    }
                                    if (k >= pp.Length)
                                    {
                                        if (res == null)
                                        {
                                            res = new List <Termin>();
                                        }
                                        res.Add(t);
                                    }
                                }
                            }
                            return(res);
                        }
                    }
                    return(null);
                }
                nod = nn;
            }
            return(nod.Termins);
        }
Exemple #24
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            GoodAttrType  typ = Typ;
            string        nam = this.GetStringValue(ATTR_NAME);

            if (!shortVariant)
            {
                if (typ != GoodAttrType.Undefined)
                {
                    res.AppendFormat("{0}{1}: ", Pullenti.Ner.Goods.Internal.AttrMeta.GlobalMeta.TypAttr.ConvertInnerValueToOuterValue(typ.ToString(), lang), (nam == null ? "" : string.Format(" ({0})", nam.ToLower())));
                }
            }
            string s = this.GetStringValue(ATTR_VALUE);

            if (s != null)
            {
                if (typ == GoodAttrType.Keyword || typ == GoodAttrType.Character)
                {
                    res.Append(s.ToLower());
                }
                else if (typ == GoodAttrType.Numeric)
                {
                    List <string> vals  = Values;
                    List <string> units = Units;
                    for (int i = 0; i < vals.Count; i++)
                    {
                        if (i > 0)
                        {
                            res.Append(" x ");
                        }
                        res.Append(vals[i]);
                        if (vals.Count == units.Count)
                        {
                            res.Append(units[i].ToLower());
                        }
                        else if (units.Count > 0)
                        {
                            res.Append(units[0].ToLower());
                        }
                    }
                }
                else
                {
                    res.Append(s);
                }
            }
            Pullenti.Ner.Referent re = Ref;
            if (re != null)
            {
                res.Append(re.ToString(shortVariant, lang, 0));
            }
            return(res.ToString());
        }
Exemple #25
0
 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);
     }
 }
Exemple #26
0
 public static void UnloadLanguages(Pullenti.Morph.MorphLang langs)
 {
     if (langs.IsRu || langs.IsUa)
     {
         if (langs.IsRu && langs.IsUa)
         {
             m_DerRu.Unload();
         }
     }
     GC.Collect();
 }
Exemple #27
0
        /// <summary>
        /// Добавить строку в качестве записи словаря (термина).
        /// </summary>
        /// <param name="termins">строка, которая подвергается морфологическому анализу, и в термин добавляются все варианты разбора</param>
        /// <param name="tag">это просто значения Tag для термина</param>
        /// <param name="lang">язык (можно null, если язык анализируемого текста)</param>
        /// <param name="isNormalText">если true, то исходный текст не нужно морфологически разбирать - он уже в нормальной форме и верхнем регистре</param>
        /// <return>добавленный термин</return>
        public Termin AddString(string termins, object tag = null, Pullenti.Morph.MorphLang lang = null, bool isNormalText = false)
        {
            Termin t = new Termin(termins, lang, isNormalText || AllAddStrsNormalized);

            t.Tag = tag;
            if (tag != null && t.Terms.Count == 1)
            {
            }
            this.Add(t);
            return(t);
        }
Exemple #28
0
 public static void LoadLanguages(Pullenti.Morph.MorphLang langs)
 {
     if (langs.IsRu || langs.IsUa)
     {
         if (!m_DerRu.Init(Pullenti.Morph.MorphLang.RU, true))
         {
             throw new Exception("Not found resource file e_ru.dat in Enplanatory");
         }
     }
     if (langs.IsUa)
     {
     }
 }
Exemple #29
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            string        str = null;

            foreach (Pullenti.Ner.Slot s in Slots)
            {
                if (s.TypeName == ATTR_TYPE)
                {
                    string n = (string)s.Value;
                    if (str == null || (n.Length < str.Length))
                    {
                        str = n;
                    }
                }
            }
            if (str != null)
            {
                res.Append(str.ToLower());
            }
            if ((((str = this.GetStringValue(ATTR_BRAND)))) != null)
            {
                res.AppendFormat(" {0}", Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(str));
            }
            if ((((str = this.GetStringValue(ATTR_MODEL)))) != null)
            {
                res.AppendFormat(" {0}", str);
            }
            if ((((str = this.GetStringValue(ATTR_NAME)))) != null)
            {
                res.AppendFormat(" \"{0}\"", Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(str));
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_NAME && str != ((string)s.Value))
                    {
                        if (Pullenti.Morph.LanguageHelper.IsCyrillicChar(str[0]) != Pullenti.Morph.LanguageHelper.IsCyrillicChar(((string)s.Value)[0]))
                        {
                            res.AppendFormat(" ({0})", Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower((string)s.Value));
                            break;
                        }
                    }
                }
            }
            if ((((str = this.GetStringValue(ATTR_NUMBER)))) != null)
            {
                res.AppendFormat(", номер {0}", str);
            }
            return(res.ToString());
        }
Exemple #30
0
        string toShortString(Pullenti.Morph.MorphLang lang)
        {
            string id = null;

            foreach (Pullenti.Ner.Slot a in Slots)
            {
                if (a.TypeName == ATTR_IDENTITY)
                {
                    string s = a.Value.ToString();
                    if (id == null || (s.Length < id.Length))
                    {
                        id = s;
                    }
                }
            }
            if (id != null)
            {
                return(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(id));
            }
            string n = this.GetStringValue(ATTR_LASTNAME);

            if (n != null)
            {
                StringBuilder res = new StringBuilder();
                res.Append(n);
                string s = this._findForSurname(ATTR_FIRSTNAME, n, true);
                if (s != null)
                {
                    res.AppendFormat(" {0}.", s[0]);
                    s = this._findForSurname(ATTR_MIDDLENAME, n, false);
                    if (s != null)
                    {
                        res.AppendFormat("{0}.", s[0]);
                    }
                }
                return(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(res.ToString()));
            }
            string tit = this._findShortestKingTitul(true);

            if (tit != null)
            {
                string nam = this.GetStringValue(ATTR_FIRSTNAME);
                if (nam != null)
                {
                    return(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(string.Format("{0} {1}", tit, nam)));
                }
            }
            return(this.toFullString(false, lang));
        }