Пример #1
0
 public void Load(Latino.BinarySerializer binRead)
 {
     lsett      = new LemmatizerSettings(binRead);
     elExamples = new ExampleList(binRead, lsett);
     if (!lsett.bBuildFrontLemmatizer)
     {
         ltnRootNode = new LemmaTreeNode(binRead, lsett, elExamples, null);
     }
     else
     {
         ltnRootNode      = new LemmaTreeNode(binRead, lsett, elExamples.GetFrontRearExampleList(false), null);
         ltnRootNodeFront = new LemmaTreeNode(binRead, lsett, elExamples.GetFrontRearExampleList(true), null);
     }
 }
Пример #2
0
        public void Deserialize(BinaryReader binRead)
        {
            using (binRead)
            {
                // settings
                Lsett = new LemmatizerSettings(binRead);

                // examples
                bool bSerializeExamples = binRead.ReadBoolean();
                ElExamples = new ExampleList(binRead, Lsett);
                ExampleList elExamplesRear;
                ExampleList elExamplesFront;
                if (bSerializeExamples)
                {
                    elExamplesRear  = ElExamples.GetFrontRearExampleList(false);
                    elExamplesFront = ElExamples.GetFrontRearExampleList(true);
                }
                else
                {
                    elExamplesRear  = new ExampleList(binRead, Lsett);
                    elExamplesFront = new ExampleList(binRead, Lsett);
                }

                // root node
                LtnRootNode = new LemmaTreeNode(binRead, Lsett, Lsett.bBuildFrontLemmatizer ? elExamplesRear : ElExamples, null);

                // root node front
                if (Lsett.bBuildFrontLemmatizer)
                {
                    LtnRootNodeFront = new LemmaTreeNode(binRead, Lsett, elExamplesFront, null);
                }

                // exceptions - use try catch for retro compatibility
                // --> this section is missing in the old lemmatizer files
                try
                {
                    var nbOfExceptions = binRead.ReadInt32();
                    for (var i = 0; i < nbOfExceptions; i++)
                    {
                        var exception = binRead.ReadString();
                        var parts     = exception.Split(' ');
                        this.AddException(parts[0], parts[1]);
                    }
                }
                catch (Exception)
                {
                    Trace.WriteLine("Couldn't deserialize exceptions in Lemmatizer file");
                }
            }
        }
Пример #3
0
        // Essential Class Functions (building model & lemmatizing) ----------

        public void BuildModel()
        {
            if (LtnRootNode != null)
            {
                return;
            }

            if (!Lsett.bBuildFrontLemmatizer)
            {
                //TODO remove: elExamples.FinalizeAdditions();
                ElExamples.FinalizeAdditions();
                LtnRootNode = new LemmaTreeNode(Lsett, ElExamples);
            }
            else
            {
                LtnRootNode      = new LemmaTreeNode(Lsett, ElExamples.GetFrontRearExampleList(false));
                LtnRootNodeFront = new LemmaTreeNode(Lsett, ElExamples.GetFrontRearExampleList(true));
            }
        }