コード例 #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 bool Equals(FlexiaModel fm)
 {
     // If parameter is null, return false:
     if ((object)fm == null)
     {
         return(false);
     }
     // Return true if the fields match:
     return(this == fm);
 }
コード例 #3
0
 /// <summary>
 /// Adds AnCodes of all Flexia models satisfied to word.
 /// </summary>
 /// <param name="word"></param>
 /// <param name="result"></param>
 protected void FindFlex(SearchInfo searchInfo, string word)
 {
     if (Info != null)
     {
         foreach (LemmaInfo li in Info)
         {
             FlexiaModel fm = searchInfo.OriginalDictionary.FlexiaModels[li.FlexiaModelNo];
             if (fm.HasFlex(word))
             {
                 searchInfo.Add(new FullLemmaInfo(
                                    li,
                                    searchInfo.FullWord.Substring(0, searchInfo.FullWord.Length - word.Length) + fm.FirstFlex,
                                    fm.FirstMF,
                                    fm.FindMorphologicFormByFlex(word)));
             }
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Read list of flexia models from stream.
        /// </summary>
        /// <param name="sr">Stream reader.</param>
        /// <returns>List of flexia models.</returns>
        /// <remarks>
        /// Structure of stream:
        /// FlexiaModelsCount(int)
        /// FlexiaModel[0]
        /// ...
        /// FlexiaModel[FlexiaModelsCount-1]
        /// </remarks>
        private List <FlexiaModel> ReadFlexiaModels(StreamReader sr)
        {
            List <FlexiaModel> tempFlexiaModels = new List <FlexiaModel>();

            int paradigm_count = int.Parse(sr.ReadLine());

            for (int num = 0; num < paradigm_count; num++)
            {
                string      line = sr.ReadLine().Trim();
                FlexiaModel fm   = new FlexiaModel();
                if (!fm.ReadFromString(line))
                {
                    throw new Exception(string.Format("Cannot parse paradigm No %i", num + 1));
                }

                tempFlexiaModels.Add(fm);
            }

            return(tempFlexiaModels);
        }
コード例 #5
0
        public void FastInit()
        {
            FastFlexia = new Dictionary <string, List <int> > [20];
            for (int i = 0; i < 20; i++)
            {
                FastFlexia[i] = new Dictionary <string, List <int> >();
            }

            if (FlexiaModels != null)
            {
                for (int iFlexiaModelNo = 0; iFlexiaModelNo < FlexiaModels.Count; iFlexiaModelNo++)
                {
                    FlexiaModel flexiaModel = this.FlexiaModels[iFlexiaModelNo];
                    if (flexiaModel.Flexia != null && flexiaModel.Flexia.Count != 0)
                    {
                        foreach (MorphologicForm morphForm in flexiaModel.Flexia.Values)
                        {
                            FastAddFlexNo(morphForm.FlexiaStr, iFlexiaModelNo);
                        }
                    }
                }
            }
        }