示例#1
0
        /// <summary>
        /// Поиск по точному или приблизительному совпадению
        /// </summary>
        public static Noun FindSimilar(string sourceForm, Gender gender = Gender.Undefined, Animacy animacy = Animacy.Undefined)
        {
            var searchWord = PrepareWord(sourceForm);

            object tag = null;

            OnBeforeFindSimilar(ref sourceForm, ref gender, ref animacy, ref searchWord, ref tag);

            var res = items.FindSimilar(new NounRaw()
            {
                Word = searchWord
            }, new StringReverseComparer <NounRaw>(), PrepareFilter(gender, animacy));

            Noun result = null;

            if (res.Word != null)
            {
                result = new Noun {
                    Word = sourceForm, Gender = res.Gender, SchemaIndex = res.SchemaIndex, Inexact = res.Word != searchWord
                }
            }
            ;

            OnAfterFindSimilar(result, sourceForm, searchWord, tag);

            return(result);
        }
示例#2
0
 private static void OnAfterFindSimilar(Noun result, string sourceForm, string searchWord, object tag)
 {
     if (AfterFindSimilar != null)
     {
         var args = new AfterFindSimilarNounEventArgs {
             PreparedForm = searchWord, SourceForm = sourceForm, Tag = tag, Result = result
         };
         AfterFindSimilar(null, args);
         result     = args.Result;
         sourceForm = args.SourceForm;
         searchWord = args.PreparedForm;
         tag        = args.Tag;
     }
 }