// Constructor(s) & Destructor(s) -------------------- 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); var aWords = (string[])info.GetValue("aWords", typeof(string[])); var aLemmas = (string[])info.GetValue("aLemmas", typeof(string[])); var aWeights = (double[])info.GetValue("aWeights", typeof(double[])); var aMsds = (string[])info.GetValue("aMsds", typeof(string[])); for (int iExm = 0; iExm < aWords.Length; iExm++) { AddExample(aWords[iExm], aLemmas[iExm], aWeights[iExm], aMsds[iExm]); } }
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); } } }
// Constructor(s) & Destructor(s) --------- 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; this.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 ?? "") + ")"; break; } this.sWordRearCache = null; this.sWordFrontCache = null; this.sLemmaFrontCache = null; }