Ejemplo n.º 1
0
        public static double Score(string subject, string query, StringScorerOptions options = null)
        {
            if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(query))
            {
                return(0);
            }

            options = options ?? new StringScorerOptions();
            options.Init(query);

            return(options.ScorerEngine.Score(subject, query, options));
        }
Ejemplo n.º 2
0
        public static int[] Match(string subject, string query, StringScorerOptions options = null)
        {
            if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(query))
            {
                return new int[] {}
            }
            ;

            options = options ?? new StringScorerOptions();
            options.Init(query);

            return(WordMatcher.Match(subject, query, options));
        }
Ejemplo n.º 3
0
        public static IResultSubject[] Filter(IList <ISubject> candidates, string query,
                                              StringScorerOptions options = null)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(new IResultSubject[0]);
            }
            if (candidates == null || !candidates.Any())
            {
                return(new IResultSubject[0]);
            }

            options = options ?? new StringScorerOptions();
            options.Init(query);

            var result = Sieve.FilterCandidates(candidates.ToList().ConvertAll(Convert).ToArray(), query, options)
                         .ToList();

            return(result.ConvertAll(Convert).ToArray());
        }