Beispiel #1
0
 internal void Deserialize(Stream str, bool lazyLoad)
 {
     Pullenti.Morph.Internal.ByteArrayWrapper wr = null;
     using (MemoryStream tmp = new MemoryStream())
     {
         Pullenti.Morph.Internal.MorphDeserializer.DeflateGzip(str, tmp);
         wr = new Pullenti.Morph.Internal.ByteArrayWrapper(tmp.ToArray());
         int pos = 0;
         int cou = wr.DeserializeInt(ref pos);
         for (; cou > 0; cou--)
         {
             int p1 = wr.DeserializeInt(ref pos);
             Pullenti.Semantic.Utils.DerivateGroup ew = new Pullenti.Semantic.Utils.DerivateGroup();
             if (lazyLoad)
             {
                 ew.LazyPos = pos;
                 pos        = p1;
             }
             else
             {
                 ew.Deserialize(wr, ref pos);
             }
             ew.Id = m_AllGroups.Count + 1;
             m_AllGroups.Add(ew);
         }
         m_Root = new ExplanTreeNode();
         m_Root.Deserialize(wr, this, lazyLoad, ref pos);
     }
     m_Buf = wr;
 }
Beispiel #2
0
        internal void Deserialize(Pullenti.Morph.Internal.ByteArrayWrapper str, DerivateDictionary dic, bool lazyLoad, ref int pos)
        {
            int        cou = str.DeserializeShort(ref pos);
            List <int> li  = (cou > 0 ? new List <int>() : null);

            for (; cou > 0; cou--)
            {
                int id = str.DeserializeInt(ref pos);
                if (id > 0 && id <= dic.m_AllGroups.Count)
                {
                    Pullenti.Semantic.Utils.DerivateGroup gr = dic.m_AllGroups[id - 1];
                    if (gr.LazyPos > 0)
                    {
                        int p0 = pos;
                        pos = gr.LazyPos;
                        gr.Deserialize(str, ref pos);
                        gr.LazyPos = 0;
                        pos        = p0;
                    }
                }
                li.Add(id);
            }
            if (li != null)
            {
                Groups = li;
            }
            cou = str.DeserializeShort(ref pos);
            if (cou == 0)
            {
                return;
            }
            for (; cou > 0; cou--)
            {
                int            ke  = str.DeserializeShort(ref pos);
                int            p1  = str.DeserializeInt(ref pos);
                ExplanTreeNode tn1 = new ExplanTreeNode();
                if (Nodes == null)
                {
                    Nodes = new Dictionary <short, ExplanTreeNode>();
                }
                short sh = (short)ke;
                if (lazyLoad)
                {
                    tn1.LazyPos = pos;
                    pos         = p1;
                }
                else
                {
                    tn1.Deserialize(str, dic, false, ref pos);
                }
                if (!Nodes.ContainsKey(sh))
                {
                    Nodes.Add(sh, tn1);
                }
            }
        }
Beispiel #3
0
        internal void Deserialize(Pullenti.Morph.Internal.ByteArrayWrapper str, ref int pos)
        {
            int attr = str.DeserializeShort(ref pos);

            if (((attr & 1)) != 0)
            {
                IsDummy = true;
            }
            if (((attr & 2)) != 0)
            {
                NotGenerate = true;
            }
            Prefix = str.DeserializeString(ref pos);
            Model.Deserialize(str, ref pos);
            Cm.Deserialize(str, ref pos);
            CmRev.Deserialize(str, ref pos);
            int cou = str.DeserializeShort(ref pos);

            for (; cou > 0; cou--)
            {
                DerivateWord w = new DerivateWord();
                w.Spelling = str.DeserializeString(ref pos);
                int sh = str.DeserializeShort(ref pos);
                w.Class       = new Pullenti.Morph.MorphClass();
                w.Class.Value = (short)sh;
                sh            = str.DeserializeShort(ref pos);
                w.Lang        = new Pullenti.Morph.MorphLang();
                w.Lang.Value  = (short)sh;
                sh            = str.DeserializeShort(ref pos);
                w.Attrs.Value = (short)sh;
                byte b = str.DeserializeByte(ref pos);
                w.Aspect = (Pullenti.Morph.MorphAspect)b;
                b        = str.DeserializeByte(ref pos);
                w.Tense  = (Pullenti.Morph.MorphTense)b;
                b        = str.DeserializeByte(ref pos);
                w.Voice  = (Pullenti.Morph.MorphVoice)b;
                b        = str.DeserializeByte(ref pos);
                int cou1 = (int)b;
                for (; cou1 > 0; cou1--)
                {
                    string n = str.DeserializeString(ref pos);
                    if (w.NextWords == null)
                    {
                        w.NextWords = new List <string>();
                    }
                    if (n != null)
                    {
                        w.NextWords.Add(n);
                    }
                }
                Words.Add(w);
            }
        }
Beispiel #4
0
        internal void Deserialize(Pullenti.Morph.Internal.ByteArrayWrapper str, ref int pos)
        {
            byte b = str.DeserializeByte(ref pos);

            Transitive = b != 0;
            int sh = str.DeserializeShort(ref pos);

            Questions = (Pullenti.Semantic.Utils.QuestionType)sh;
            sh        = str.DeserializeShort(ref pos);
            if (sh != 0)
            {
                string pr = str.DeserializeString(ref pos);
                Pullenti.Morph.MorphCase cas = new Pullenti.Morph.MorphCase();
                cas.Value = (short)sh;
                Agent     = new NextModelItem(pr, cas);
            }
            sh = str.DeserializeShort(ref pos);
            if (sh != 0)
            {
                string pr = str.DeserializeString(ref pos);
                Pullenti.Morph.MorphCase cas = new Pullenti.Morph.MorphCase();
                cas.Value = (short)sh;
                Pacient   = new NextModelItem(pr, cas);
            }
            sh = str.DeserializeShort(ref pos);
            if (sh != 0)
            {
                string pr = str.DeserializeString(ref pos);
                Pullenti.Morph.MorphCase cas = new Pullenti.Morph.MorphCase();
                cas.Value  = (short)sh;
                Instrument = new NextModelItem(pr, cas);
            }
            int cou = str.DeserializeShort(ref pos);

            for (; cou > 0; cou--)
            {
                string pref = str.DeserializeString(ref pos);
                if (pref == null)
                {
                    pref = "";
                }
                Pullenti.Morph.MorphCase cas = new Pullenti.Morph.MorphCase();
                sh        = str.DeserializeShort(ref pos);
                cas.Value = (short)sh;
                if (Nexts == null)
                {
                    Nexts = new Dictionary <string, Pullenti.Morph.MorphCase>();
                }
                Nexts.Add(pref, cas);
            }
        }
Beispiel #5
0
        internal void Deserialize(Pullenti.Morph.Internal.ByteArrayWrapper str, ref int pos)
        {
            int sh = str.DeserializeShort(ref pos);

            Value = (short)sh;
            while (true)
            {
                string s = str.DeserializeString(ref pos);
                if (string.IsNullOrEmpty(s))
                {
                    break;
                }
                if (!m_Attrs.Contains(s))
                {
                    m_Attrs.Add(s);
                }
            }
        }
Beispiel #6
0
        internal void Deserialize(Pullenti.Morph.Internal.ByteArrayWrapper str, ref int pos)
        {
            int cou = str.DeserializeShort(ref pos);

            for (; cou > 0; cou--)
            {
                ControlModelItem it = new ControlModelItem();
                byte             b  = str.DeserializeByte(ref pos);
                if (((b & 0x80)) != 0)
                {
                    it.NominativeCanBeAgentAndPacient = true;
                }
                it.Typ = (ControlModelItemType)((b & 0x7F));
                if (it.Typ == ControlModelItemType.Word)
                {
                    it.Word = str.DeserializeString(ref pos);
                }
                int licou = str.DeserializeShort(ref pos);
                for (; licou > 0; licou--)
                {
                    byte bi = str.DeserializeByte(ref pos);
                    int  i  = (int)bi;
                    b = str.DeserializeByte(ref pos);
                    if (i >= 0 && (i < ControlModelQuestion.Items.Count))
                    {
                        it.Links.Add(ControlModelQuestion.Items[i], (Pullenti.Semantic.Core.SemanticRole)b);
                    }
                }
                Items.Add(it);
            }
            cou = str.DeserializeShort(ref pos);
            for (; cou > 0; cou--)
            {
                string p = str.DeserializeString(ref pos);
                if (p != null)
                {
                    Pacients.Add(p);
                }
            }
        }