public ExampleList(LemmatizerSettings lsett) : base()
        {
            this.lsett = lsett;

            this.dictExamples = new Dictionary <string, LemmaExample>();
            this.lstExamples  = null;
            this.rlRules      = new RuleList(lsett);
        }
        public ExampleList(SerializationInfo info, StreamingContext context)
        {
            lsett = (LemmatizerSettings)info.GetValue("lsett", typeof(LemmatizerSettings));

            this.dictExamples = new Dictionary <string, LemmaExample>();
            this.lstExamples  = null;
            this.rlRules      = new RuleList(lsett);

            string[] aWords   = (string[])info.GetValue("aWords", typeof(string[]));
            string[] aLemmas  = (string[])info.GetValue("aLemmas", typeof(string[]));
            double[] aWeights = (double[])info.GetValue("aWeights", typeof(double[]));
            string[] aMsds    = (string[])info.GetValue("aMsds", typeof(string[]));

            for (int iExm = 0; iExm < aWords.Length; iExm++)
            {
                AddExample(aWords[iExm], aLemmas[iExm], aWeights[iExm], aMsds[iExm]);
            }
        }
Example #3
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);
                }
            }
        }
Example #4
0
        public LemmaExample(string sWord, string sLemma, double dWeight, string sMsd, RuleList rlRules,
                            LemmatizerSettings lsett)
        {
            this.lsett = lsett;

            this.sWord   = sWord;
            this.sLemma  = sLemma;
            this.sMsd    = sMsd;
            this.dWeight = dWeight;
            lrRule       = rlRules.AddRule(this);

            switch (lsett.eMsdConsider)
            {
            case LemmatizerSettings.MsdConsideration.Ignore:
            case LemmatizerSettings.MsdConsideration.JoinAll:
            case LemmatizerSettings.MsdConsideration.JoinDistinct:
            case LemmatizerSettings.MsdConsideration.JoinSameSubstring:
                sSignature = "[" + sWord + "]==>[" + sLemma + "]";
                break;

            case LemmatizerSettings.MsdConsideration.Distinct:
            default:
                sSignature = "[" + sWord + "]==>[" + sLemma + "](" + (sMsd != null ? sMsd : "") + ")";
                break;
            }

            sWordRearCache   = null;
            sWordFrontCache  = null;
            sLemmaFrontCache = null;
        }