Esempio n. 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));
            }
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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)));
        }
Esempio n. 5
0
 public DebugProxy(FoodNameTerms instance)
 {
     Debug.Assert(instance != null);
     _instance = instance;
 }