Exemplo n.º 1
0
        public void PrintLemma(Lemma l)
        {
            FlexiaModel flexModel   = _flexiaModels[l.FlexModelNo];
            AccentModel accentModel = _accentModels[l.AccentModelNo];
            UserSession session     = _userSessions[l.SessionNo];

            Console.WriteLine("=== {0} {1} {2} {3} ===", l.Base, _gramtab.LookupAncode(l.TypeAncode), flexModel.Forms.Count,
                              accentModel.AccentForms.Count);
            int formNo = 0;

            foreach (Flexia form in flexModel.Forms)
            {
                if (!string.IsNullOrWhiteSpace(form.Prefix))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write(form.Prefix);
                }
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write(l.Base);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(form.Flexion);
                int accent = accentModel.AccentForms[formNo];
                Console.Write(" {0} ", accent);
                string accWord = AccentHelper.SetAccent(form.Prefix + l.Base + form.Flexion, accent);
                Console.Write(" " + accWord + " ");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write("\t" + _gramtab.LookupAncode(form.Ancode));
                Console.ResetColor();
                Console.WriteLine();
                formNo++;
            }
            if (l.PrefixSetNo.HasValue)
            {
                PrefixSet prefixSet = _prefixSets[l.PrefixSetNo.Value];
                Console.WriteLine("PrefixSets:");
                foreach (string pref in prefixSet.Prefixes)
                {
                    Console.WriteLine(pref);
                }
            }
            Console.WriteLine("-------------------");
        }
Exemplo n.º 2
0
        public IEnumerable <WordForm> GetLemmaForms(Lemma l, string prefix)
        {
            FlexiaModel flexModel   = _flexiaModels[l.FlexModelNo];
            AccentModel accentModel = _accentModels[l.AccentModelNo];
            //UserSession session = _userSessions[l.SessionNo];
            int formNo = 0;

            foreach (Flexia form in flexModel.Forms)
            {
                int accent = accentModel.AccentForms[formNo];
                yield return(new WordForm()
                {
                    Lemma = l,
                    Prefix = prefix,
                    Flexia = form,
                    Accent = accent
                });

                formNo++;
            }
        }
Exemplo n.º 3
0
        private void _parseFlexiaModel(string line)
        {
            //%< flexion > *< ancode >
            //	or %< flexion > *< ancode > *< prefix >
            FlexiaModel model = new FlexiaModel();

            foreach (string item in line.Split(new[] { '%' }, StringSplitOptions.RemoveEmptyEntries))
            {
                string[] parts  = item.Split('*');
                var      flexia = new Flexia();
                flexia.Flexion  = parts[0];
                flexia.Ancode   = parts[1].Substring(0, 2);
                flexia.AncodeNo = _gramtab.AncodeToInt(flexia.Ancode);
                _gramtab.CountFrequency(flexia.Ancode);
                if (parts.Length > 2)
                {
                    flexia.Prefix = parts[2];
                }
                model.Forms.Add(flexia);
            }
            _flexiaModels.Add(model);
        }