Пример #1
0
        public MatchResult GetSavedMatchLevel3(
            string level3,
            string level1,
            string level2)
        {
            IEnumerable <Level3Match> matches =
                matchProvider.GetMatches(level3, level1, level2).ToList();
            int count = matches.Count();

            if (count > 1)
            {
                // there must only be a max of one saved match for any given input.
                var msg = string.Format(
                    "[{0}] matched names found for the input [{1}] [{2}],[{3}]",
                    count,
                    level1,
                    level2,
                    level3);
                throw new InvalidOperationException(msg);
            }

            Level3Match match = matches.FirstOrDefault();

            return(match != null
                ? new MatchResult(match.Level3, DefaultProbability)
                : null);
        }
        public void AddLevel3(string[] match, string[] actual)
        {
            var matched = Level3Matches(actual[0], actual[1], match[2]).FirstOrDefault();

            if (matched != null)
            {
                level3Matches.Remove(matched);
            }
            Level3Match level3Match = new Level3Match();

            level3Match.Level1    = actual[0];
            level3Match.Level2    = actual[1];
            level3Match.Level3    = actual[2];
            level3Match.AltLevel3 = match[2];
            level3Matches.Add(level3Match);
        }
Пример #3
0
        private Level3Match SavedLevel3Match(CodedLocation location)
        {
            IEnumerable <Level3Match> matches =
                matchProvider.GetMatches(
                    location.Name3,
                    location.GeoCode1.Name,
                    location.GeoCode2.Name).ToList();
            int count = matches.Count();

            if (count > 1)
            {
                // there must only be a max of one saved match for any given input.
                var msg = string.Format(
                    "[{0}] matched names found for the input [{1}] [{2}],[{3}]",
                    count,
                    location.GeoCode1.Name,
                    location.GeoCode2.Name,
                    location.Name3);
                throw new InvalidOperationException(msg);
            }
            Level3Match match = matches.FirstOrDefault();

            return(match);
        }