public SearchEngine(SearchEngineConfig config)
        {
            mConfig      = config;
            mQueryParser = new SimpleQueryParser(new QueryParserConfig
            {
                TextSegmenter = config.TextSegmenter,
            });

            mRetriever = new InexactTopKRetriever(new RetrieverConfig
            {
                PostingListStore   = config.PostingListStore,
                UrlFileStore       = config.UrlFileStore,
                InvertedIndexStore = config.InvertedIndexStore,
            }, ResultSize);

            var rankerConfig = new RankerConfig
            {
                PostingListStore   = config.PostingListStore,
                UrlFileStore       = config.UrlFileStore,
                InvertedIndexStore = config.InvertedIndexStore,
            };

            mRanker    = new IntegratedRanker(rankerConfig);
            mProRanker = new QueryTermProximityRanker(rankerConfig);

            mLogger = new RuntimeLogger(Path.Combine(config.LogDirectory, "SearchEngine.Log"), true);
        }
Exemple #2
0
 public int[] ChooseRanking(string uniqueKey, TContext context, IRanker <TContext> defaultRanker)
 {
     return(this.ChooseRankingAsync(uniqueKey, context, defaultRanker)
            .ConfigureAwait(true)
            .GetAwaiter()
            .GetResult());
 }
Exemple #3
0
        /// <summary>
        /// Performs ranking using the specified algorithm
        /// </summary>
        /// <param name="rankingAlgorithm">The algorithm that should be used for ranking</param>
        public void PerformRanking(IRanker rankingAlgorithm)
        {
            RankerBase ranker = rankingAlgorithm as RankerBase;

            // Validate the provided ranker
            if (ranker == null)
            {
                throw new ArgumentNullException("rankingAlgorithm", "No valid ranker provided");
            }

            // Execute the ranking algorithm.  If normalizeResults is true then
            // the returned results are normalized rather than just the raw values.
            ranker.CalculateNormalizedRankAsync(GraphManager.Instance.DefaultGraphComponentsInstance.Scope);
        }
        // Call Rank() on the given IRanker then transform its result into a message which is
        // informative to the end user.
        public static (string strong, string normal) RankAndHumanify(IRanker ranker, string query)
        {
            string rankings;

            try {
                rankings = ranker.Rank(query, TARGET_SITE);
            } catch (ExtractionException ex) {
                return("Error: ", ex.Message);
            }

            if (rankings == "0")
            {
                return("Result: ", $"The site '{TARGET_SITE}' could not be found in the search results.");
            }

            string inflected_index = rankings.Split(' ').Length == 1 ? "index" : "indices";

            return("Result: ",
                   $"The site '{TARGET_SITE}' was found at the following {inflected_index} (where 1 represents the first search result): {rankings}.");
        }
Exemple #5
0
 public Scorer(IRanker ranker)
 {
     _ranker = ranker;
 }
Exemple #6
0
 public async Task <int[]> ChooseRankingAsync(string uniqueKey, TContext context, IRanker <TContext> defaultRanker, bool doNotLog)
 {
     return(await ChooseRankingAsync(uniqueKey, context, (await defaultRanker.MapContextAsync(context)).Value, doNotLog));
 }
Exemple #7
0
 public Task <int[]> ChooseRankingAsync(string uniqueKey, TContext context, IRanker <TContext> defaultRanker)
 {
     return(this.ChooseRankingAsync(uniqueKey, context, defaultRanker, doNotLog: false));
 }
 public HomeController(ILogger <HomeController> log, IRanker ranker)
 {
     this.log    = log;
     this.ranker = ranker;
 }
Exemple #9
0
 public RankerTests(SystemUnderTestFixture <Ranker> fixture)
 {
     _ranker = fixture.SystemUnderTest;
 }
 public SearchService(IUnitOfWork uow, IListingService listingService, IRanker ranker)
 {
     this.uow            = uow;
     this.listingService = listingService;
     this.ranker         = ranker;
 }
Exemple #11
0
 public static void TheHandIsRanked(IRanker ranker, string handNotation, out Hand hand)
 {
     hand = new Hand(handNotation);
     ranker.RankHand(hand);
 }
Exemple #12
0
 public int[] ChooseRanking(string uniqueKey, TContext context, IRanker <TContext> defaultRanker, bool doNotLog)
 {
     return(ChooseRanking(uniqueKey, context, defaultRanker.MapContext(context).Value, doNotLog));
 }
Exemple #13
0
        /// <summary>
        /// Performs ranking using the specified algorithm
        /// </summary>
        /// <param name="rankingAlgorithm">The algorithm that should be used for ranking</param>
        public void PerformRanking(IRanker rankingAlgorithm)
        {
            RankerBase ranker = rankingAlgorithm as RankerBase;

            // Validate the provided ranker
            if (ranker == null)
                throw new ArgumentNullException("rankingAlgorithm", "No valid ranker provided");

            // Execute the ranking algorithm.  If normalizeResults is true then
            // the returned results are normalized rather than just the raw values.
            ranker.CalculateNormalizedRankAsync(GraphManager.Instance.DefaultGraphComponentsInstance.Scope);
        }