Example #1
0
 public ReferentToken(Referent entity, Token begin, Token end, Pullenti.Ner.Core.AnalysisKit kit = null) : base(begin, end, kit)
 {
     Referent = entity;
     if (Morph == null)
     {
         Morph = new MorphCollection();
     }
 }
Example #2
0
 internal virtual void Serialize(Stream stream)
 {
     Pullenti.Ner.Core.Internal.SerializerHelper.SerializeInt(stream, BeginChar);
     Pullenti.Ner.Core.Internal.SerializerHelper.SerializeInt(stream, EndChar);
     Pullenti.Ner.Core.Internal.SerializerHelper.SerializeInt(stream, m_Attrs);
     Pullenti.Ner.Core.Internal.SerializerHelper.SerializeInt(stream, Chars.Value);
     if (m_Morph == null)
     {
         m_Morph = new MorphCollection();
     }
     m_Morph.Serialize(stream);
 }
Example #3
0
 internal virtual void Deserialize(Stream stream, Pullenti.Ner.Core.AnalysisKit kit, int vers)
 {
     Kit         = kit;
     m_BeginChar = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeInt(stream);
     m_EndChar   = Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeInt(stream);
     m_Attrs     = (short)Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeInt(stream);
     Chars       = new Pullenti.Morph.CharsInfo()
     {
         Value = (short)Pullenti.Ner.Core.Internal.SerializerHelper.DeserializeInt(stream)
     };
     m_Morph = new MorphCollection();
     m_Morph.Deserialize(stream);
 }
 public MorphCollection(MorphCollection source = null)
 {
     if (source == null)
     {
         return;
     }
     foreach (Pullenti.Morph.MorphBaseInfo it in source.Items)
     {
         Pullenti.Morph.MorphBaseInfo mi = null;
         if (it is Pullenti.Morph.MorphWordForm)
         {
             Pullenti.Morph.MorphWordForm wf = new Pullenti.Morph.MorphWordForm();
             wf.CopyFromWordForm(it as Pullenti.Morph.MorphWordForm);
             mi = wf;
         }
         else
         {
             mi = new Pullenti.Morph.MorphBaseInfo();
             mi.CopyFrom(it);
         }
         if (m_Items == null)
         {
             m_Items = new List <Pullenti.Morph.MorphBaseInfo>();
         }
         m_Items.Add(mi);
     }
     m_Class = new Pullenti.Morph.MorphClass()
     {
         Value = source.m_Class.Value
     };
     m_Gender = source.m_Gender;
     m_Case   = new Pullenti.Morph.MorphCase()
     {
         Value = source.m_Case.Value
     };
     m_Number   = source.m_Number;
     m_Language = new Pullenti.Morph.MorphLang()
     {
         Value = source.m_Language.Value
     };
     m_Voice      = source.m_Voice;
     m_NeedRecalc = false;
 }
        /// <summary>
        /// Создать копию
        /// </summary>
        public MorphCollection Clone()
        {
            MorphCollection res = new MorphCollection();

            if (m_Items != null)
            {
                res.m_Items = new List <Pullenti.Morph.MorphBaseInfo>();
                try
                {
                    res.m_Items.AddRange(m_Items);
                }
                catch (Exception ex)
                {
                }
            }
            if (!m_NeedRecalc)
            {
                res.m_Class = new Pullenti.Morph.MorphClass()
                {
                    Value = m_Class.Value
                };
                res.m_Gender = m_Gender;
                res.m_Case   = new Pullenti.Morph.MorphCase()
                {
                    Value = m_Case.Value
                };
                res.m_Number   = m_Number;
                res.m_Language = new Pullenti.Morph.MorphLang()
                {
                    Value = m_Language.Value
                };
                res.m_NeedRecalc = false;
                res.m_Voice      = m_Voice;
            }
            return(res);
        }
 /// <summary>
 /// Удалить элементы, не соответствующие другой морфологической коллекции
 /// </summary>
 public void RemoveItemsEx(MorphCollection col, Pullenti.Morph.MorphClass cla)
 {
     this.RemoveItemsListCla(col.Items, cla);
 }
Example #7
0
 public TextToken(Pullenti.Morph.MorphToken source, Pullenti.Ner.Core.AnalysisKit kit, int bchar = -1, int echar = -1) : base(kit, (bchar >= 0 ? bchar : (source == null ? 0 : source.BeginChar)), (echar >= 0 ? echar : (source == null ? 0 : source.EndChar)))
 {
     if (source == null)
     {
         return;
     }
     Chars = source.CharInfo;
     Term  = source.Term;
     Lemma = source.GetLemma() ?? Term;
     MaxLengthOfMorphVars = (short)Term.Length;
     Morph = new MorphCollection();
     if (source.WordForms != null)
     {
         foreach (Pullenti.Morph.MorphWordForm wf in source.WordForms)
         {
             Morph.AddItem(wf);
             if (wf.NormalCase != null && (MaxLengthOfMorphVars < wf.NormalCase.Length))
             {
                 MaxLengthOfMorphVars = (short)wf.NormalCase.Length;
             }
             if (wf.NormalFull != null && (MaxLengthOfMorphVars < wf.NormalFull.Length))
             {
                 MaxLengthOfMorphVars = (short)wf.NormalFull.Length;
             }
         }
     }
     for (int i = 0; i < Term.Length; i++)
     {
         char ch = Term[i];
         int  j;
         for (j = 0; j < Morph.ItemsCount; j++)
         {
             Pullenti.Morph.MorphWordForm wf = Morph[j] as Pullenti.Morph.MorphWordForm;
             if (wf.NormalCase != null)
             {
                 if (i >= wf.NormalCase.Length)
                 {
                     break;
                 }
                 if (wf.NormalCase[i] != ch)
                 {
                     break;
                 }
             }
             if (wf.NormalFull != null)
             {
                 if (i >= wf.NormalFull.Length)
                 {
                     break;
                 }
                 if (wf.NormalFull[i] != ch)
                 {
                     break;
                 }
             }
         }
         if (j < Morph.ItemsCount)
         {
             break;
         }
         InvariantPrefixLengthOfMorphVars = (short)((i + 1));
     }
     if (Morph.Language.IsUndefined && !source.Language.IsUndefined)
     {
         Morph.Language = source.Language;
     }
 }