Пример #1
0
        public FullLemmaInfo[] FastFindAllWord(string word)
        {
            word = word.ToUpper();

            List <FullLemmaInfo> result = new List <FullLemmaInfo>();

            if (Lemmas.ContainsKey(word))
            {
                foreach (LemmaInfo li in Lemmas[word].GetItems())
                {
                    FlexiaModel   flexiaModel = this.FlexiaModels[li.FlexiaModelNo];
                    FullLemmaInfo fi          = new FullLemmaInfo(li.FlexiaModelNo,
                                                                  li.AccentModelNo,
                                                                  li.CommonAncode);
                    fi.CommonLemma = word;
                    fi.CommonMF    = flexiaModel.FirstMF;
                    fi.CurrentMF   = flexiaModel.FirstMF;
                    result.Add(fi);
                }
            }

            for (int i = 0; i <= word.Length && i < FastFlexia.Length; i++)
            {
                string end = word.Substring(word.Length - i);

                List <int> nos;
                if (FastFlexia[i].TryGetValue(end, out nos))
                {
                    foreach (int iFlexiaModelNo in nos)
                    {
                        FlexiaModel     flexiaModel = this.FlexiaModels[iFlexiaModelNo];
                        MorphologicForm morphForm   = flexiaModel.FindMorphologicFormByFlex(end);
                        {
                            if (word.StartsWith(morphForm.PrefixStr))
                            {
                                string commonWord = word.Substring(morphForm.PrefixStr.Length, word.Length - morphForm.FlexiaStr.Length - morphForm.PrefixStr.Length) + flexiaModel.FirstFlex;
                                if (Lemmas.ContainsKey(commonWord))
                                {
                                    foreach (LemmaInfo li in Lemmas[commonWord].GetItems())
                                    {
                                        if (li.FlexiaModelNo == iFlexiaModelNo)
                                        {
                                            FullLemmaInfo fi = new FullLemmaInfo(li.FlexiaModelNo,
                                                                                 li.AccentModelNo,
                                                                                 li.CommonAncode);
                                            fi.CommonLemma = commonWord;
                                            fi.CommonMF    = flexiaModel.FirstMF;
                                            fi.CurrentMF   = morphForm;
                                            result.Add(fi);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(result.ToArray());
        }
Пример #2
0
 public FullLemmaInfo(LemmaInfo lemmaInfo,
                      string commonLemma,
                      MorphologicForm commonMF,
                      MorphologicForm currentMF)
     : base(lemmaInfo)
 {
     CommonLemma = commonLemma;
     CommonMF    = commonMF;
     CurrentMF   = currentMF;
 }
Пример #3
0
        public bool ReadFromString(string s)
        {
            Flexia = new Dictionary <string, MorphologicForm>();

            int comm = s.IndexOf(FlexiaModelCommDelim);

            if (comm != -1)
            {
                Comments = s.Substring(comm + FlexiaModelCommDelim.Length).Trim();

                s.Trim();
            }
            else
            {
                Comments = string.Empty;
            }

            string[] forms = s.Split(new char[] { '%' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < forms.Length; i++)
            {
                int ast = forms[i].IndexOf('*');
                if (ast == -1)
                {
                    return(false);
                }
                int             last_ast = forms[i].LastIndexOf('*');
                MorphologicForm mf;
                if (last_ast != ast)
                {
                    string Prefix = forms[i].Substring(last_ast + 1);
                    mf = new MorphologicForm(forms[i].Substring(ast + 1, last_ast - ast - 1), forms[i].Substring(0, ast), Prefix);
                }
                else
                {
                    mf = new MorphologicForm(forms[i].Substring(ast + 1), forms[i].Substring(0, ast), string.Empty);
                }

                if (i == 0)
                {
                    firstMF = mf;
                }

                Flexia[mf.FlexiaStr] = mf;
            }

            return(true);
        }
Пример #4
0
 public bool Equals(MorphologicForm mf)
 {
     // Return true if the fields match:
     return(this == mf);
 }