예제 #1
0
        private void handle(RetrieveDocumentResultMessage message)
        {
            var foodNameQuery = message.Request.FoodNameQuery;
            var foodNameTerms = new FoodNameTerms(foodNameQuery);

            Self.Tell(new ScoreDocumentRequestMessage(message.SearchResultDoc, foodNameTerms, foodNameTerms));

            foreach (var foodName in _foodNames.Where(n => !n.Equals(foodNameQuery)))
            {
                Self.Tell(new ScoreDocumentRequestMessage(message.SearchResultDoc, new FoodNameTerms(foodName), foodNameTerms));
            }
        }
예제 #2
0
        public DocumentScore(SearchResultDocument document, FoodNameTerms terms, FoodNameScoreVector foodNameScoreVector)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }
            if (terms == null)
            {
                throw new ArgumentNullException(nameof(terms));
            }
            if (foodNameScoreVector == null)
            {
                throw new ArgumentNullException(nameof(foodNameScoreVector));
            }

            Document      = document;
            FoodNameTerms = terms;
            ScoreVector   = foodNameScoreVector;
        }
예제 #3
0
        public ScoreDocumentRequestMessage(SearchResultDocument document, FoodNameTerms foodNameTerms, FoodNameTerms sourceFoodTerms)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (foodNameTerms == null)
            {
                throw new ArgumentNullException(nameof(foodNameTerms));
            }

            if (sourceFoodTerms == null)
            {
                throw new ArgumentNullException(nameof(sourceFoodTerms));
            }

            Document        = document;
            FoodNameTerms   = foodNameTerms;
            SourceFoodTerms = sourceFoodTerms;
        }
예제 #4
0
        private DocumentScore scoreDocumentForTermsAsync(SearchResultDocument document, FoodNameTerms terms)
        {
            var documentVector = document.DocumentVector;
            var score          = new Double[documentVector.Length];

            for (var i = 0; i < documentVector.Length; i++)
            {
                if (terms.Contains(documentVector[i]))
                {
                    score[i] = 1.0;
                }
            }

            return(new DocumentScore(document, terms, new FoodNameScoreVector(score)));
        }
예제 #5
0
 public DebugProxy(FoodNameTerms instance)
 {
     Debug.Assert(instance != null);
     _instance = instance;
 }