Beispiel #1
0
        //zTODO: 如果匹配一致?包括完美一致?
        //使用词语近似性算法:LevenshteinDistance
        public MemberCompareResult_t Compare(CSharpMember_t src)
        {
            if (Members.Count == 0)
            {
                return(null);
            }

            MemberCompareResult_t mcr = new MemberCompareResult_t(src);

            Int32  Distance;
            Double Similarity;

            for (int i = 0; i < Members.Count; ++i)
            {
                if (UseSign[i] == true)
                {
                    continue;
                }

                if (Members[i].Name == src.Name)
                {
                    this.UseSign[i] = true;

                    mcr.Distance   = 0;
                    mcr.Similarity = 1;
                    mcr.dst        = Members[i];
                    return(mcr);
                }

                //忽略太短的词语
                if (CONFIG_Member_LevenshteinDistance)
                {
                    if (src.Name.Length > 4)
                    {
                        Distance = CCLevenshtein.LevenshteinDistance(Members[i].Name, src.Name, out Similarity, false);
                        if (Similarity > mcr.Similarity)
                        {
                            mcr.Distance   = Distance;
                            mcr.Similarity = Similarity;
                            mcr.dst        = Members[i];
                        }
                    }
                }
            }
            return(mcr);
        }
Beispiel #2
0
 public MemberCompareResult_t(CSharpMember_t _src)
 {
     src = _src;
 }