Example #1
0
        private MatchedChar ScopeMatch(bool[,] source, bool[,] target, int start)
        {
            int    targetWidth  = target.GetLength(0);
            int    targetHeight = target.GetLength(1);
            int    sourceWidth  = source.GetLength(0);
            int    sourceHeight = source.GetLength(1);
            double max          = 0;
            var    matched      = new MatchedChar();

            for (int i = -2; i < 6; i++)
            {
                for (int j = -3; j < sourceHeight - targetHeight + 5; j++)
                {
                    double rate = FixedMatch(source, target, i + start, j);
                    if (rate > max)
                    {
                        max          = rate;
                        matched.X    = i + start;
                        matched.Y    = j;
                        matched.Rate = rate;
                    }
                }
            }
            return(matched);
        }
Example #2
0
        private MatchedChar Match(bool[,] source, int start)
        {
            MatchedChar best = null;

            foreach (var info in words_)
            {
                var matched = ScopeMatch(source, info.Table, start);
                matched.Char = info.Char;
                if (best == null || best.Rate < matched.Rate)
                {
                    best = matched;
                }
            }
            return(best);
        }
Example #3
0
 private MatchedChar ScopeMatch(bool[,] source, bool[,] target, int start)
 {
     int targetWidth = target.GetLength(0);
     int targetHeight = target.GetLength(1);
     int sourceWidth = source.GetLength(0);
     int sourceHeight = source.GetLength(1);
        double max = 0;
     var matched = new MatchedChar();
     for (int i = -2; i < 6; i++)
         for (int j = -3; j < sourceHeight - targetHeight + 5; j++)
         {
             double rate = FixedMatch(source, target, i + start, j);
             if (rate > max)
             {
                 max = rate;
                 matched.X = i + start;
                 matched.Y = j;
                 matched.Rate = rate;
             }
         }
     return matched;
 }