示例#1
0
        // Serialization Functions (Binary) ------------

        public void Serialize(BinaryWriter binWrt, bool bSerializeExamples)
        {
            // settings
            Lsett.Serialize(binWrt);

            // examples
            binWrt.Write(bSerializeExamples);
            ElExamples.Serialize(binWrt, bSerializeExamples, false);
            if (!bSerializeExamples)
            {
                ElExamples.GetFrontRearExampleList(false).Serialize(binWrt, bSerializeExamples, false);
                ElExamples.GetFrontRearExampleList(true).Serialize(binWrt, bSerializeExamples, false);
            }

            // root node
            LtrRootNodeSafe.Serialize(binWrt);

            // root node front
            if (Lsett.bBuildFrontLemmatizer)
            {
                LtrRootNodeFrontSafe.Serialize(binWrt);
            }

            // exceptions
            binWrt.Write(this.Exceptions.Count);
            foreach (var exception in Exceptions)
            {
                binWrt.Write(string.Format("{0} {1}", exception.Key, exception.Value));
            }
        }
示例#2
0
        public string Lemmatize(string word)
        {
            if (this.Exceptions.ContainsKey(word.ToLower()))
            {
                return(this.Exceptions[word.ToLower()]);
            }

            if (!Lsett.bBuildFrontLemmatizer)
            {
                return(LtrRootNodeSafe.Lemmatize(word));
            }
            else
            {
                string sWordFront  = LemmaExample.StringReverse(word);
                string sLemmaFront = LtrRootNodeFrontSafe.Lemmatize(sWordFront);
                string sWordRear   = LemmaExample.StringReverse(sLemmaFront);
                return(LtrRootNodeSafe.Lemmatize(sWordRear));
            }
        }