예제 #1
0
        public LemmaExample AddExample(string sWord, string sLemma, double dWeight, string sMsd)
        {
            string sNewMsd = lsett.eMsdConsider != LemmatizerSettings.MsdConsideration.Ignore ? sMsd : null;
            var    leNew   = new LemmaExample(sWord, sLemma, dWeight, sNewMsd, rlRules, lsett);

            return(Add(leNew));
        }
예제 #2
0
        private LemmaExample Add(LemmaExample leNew)
        {
            LemmaExample leReturn = null;

            if (!dictExamples.TryGetValue(leNew.Signature, out leReturn))
            {
                leReturn = leNew;
                dictExamples.Add(leReturn.Signature, leReturn);
            }
            else
            {
                leReturn.Join(leNew);
            }

            lstExamples = null;

            return(leReturn);
        }
예제 #3
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));
            }
        }
예제 #4
0
        public void Deserialize(BinaryReader binRead, LemmatizerSettings lsett)
        {
            //load metadata
            bool bThisTopObject = binRead.ReadBoolean();

            //load refernce types if needed -------------------------
            if (bThisTopObject)
            {
                this.lsett = new LemmatizerSettings(binRead);
            }
            else
            {
                this.lsett = lsett;
            }

            // deserialize rules
            rlRules = new RuleList(binRead, this.lsett);

            // deserialize examples
            bool bCreateLstExamples = binRead.ReadBoolean();

            lstExamples  = bCreateLstExamples ? new List <LemmaExample>() : null;
            dictExamples = new Dictionary <string, LemmaExample>();

            //load dictionary items
            int iCount = binRead.ReadInt32();

            for (int iId = 0; iId < iCount; iId++)
            {
                LemmaRule lrRule = rlRules[binRead.ReadString()];
                var       le     = new LemmaExample(binRead, this.lsett, lrRule);

                dictExamples.Add(le.Signature, le);
                if (bCreateLstExamples)
                {
                    lstExamples.Add(le);
                }
            }
        }
예제 #5
0
        // Essential Class Functions --------------

        public LemmaRule AddRule(LemmaExample le)
        {
            return(AddRule(new LemmaRule(le.Word, le.Lemma, this.Count, lsett)));
        }