Esempio n. 1
0
        public static Dawg <FormInterpretations> CreateDAWG(MRDFileReader mrdFile)
        {
            DateTime start = DateTime.Now;

            Console.WriteLine("Inserting forms in DAWG... Please wait...");
            DawgSharp.DawgBuilder <FormInterpretations> dawgBuilder = new DawgBuilder <FormInterpretations>();
            UInt64 cntForms = 0;

            foreach (WordForm f in mrdFile.AllForms)
            {
                string word = f.Prefix + f.Flexia.Prefix + f.Lemma.Base + f.Flexia.Flexion;
                FormInterpretations payload = null;
                dawgBuilder.TryGetValue(word, out payload);
                if (payload == null)
                {
                    payload = new FormInterpretations();
                    dawgBuilder.Insert(word, payload);
                }
                payload.Add(f);
                cntForms++;
            }
            Console.WriteLine("All forms count: " + cntForms);
            Console.WriteLine("Building... please wait...");
            Dawg <FormInterpretations> dawg = dawgBuilder.BuildDawg();

            Console.WriteLine("DAWG create time: {0}", DateTime.Now - start);
            return(dawg);
        }
Esempio n. 2
0
        private void _rebuildDAWG(string path)
        {
            MRDFileReader mrdFile = new MRDFileReader(_gramtab);

            mrdFile.LoadMrd(Path.Combine(_workDir, @"Dicts\morphs.mrd"));
            _dawg = CreateDAWG(mrdFile);
            _dawg.SaveTo(File.Create(path), WritePayload);
        }
Esempio n. 3
0
        private static void ParseMRDFile()
        {
            MRDFileReader mrdFile = new MRDFileReader(gramtab);

            mrdFile.LoadMrd(Path.Combine(workDir, @"Dicts\morphs.mrd"));
            mrdFile.PrintStat();
            mrdFile.PrintStat2();

            //mrdFile.PrintLemma("КЛЕ");
            mrdFile.PrintLemma("ГЛАЗ");
            //mrdFile.PrintLemma("ЗАМ");

            mrdFile.WriteAllForms(Path.Combine(workDir, "forms.txt"));
        }