Exemple #1
0
        public static TokenFrequencyAndScoreDictionary ProjectPrimaryTermsToScores(ProjectionDictionary projection, DocumentSelectResult scores, ILogBuilder logger)
        {
            var scoreByAssignedID = scores.GetByAssignedID(logger);


            TokenFrequencyAndScoreDictionary tokenFrequencyAndScoreDictionary = new TokenFrequencyAndScoreDictionary();

            foreach (var pair in projection)
            {
                DocumentSelectResultEntry entry = null; //drmContext.items.FirstOrDefault(x => x.AssignedID == pair.Key);

                if (scoreByAssignedID.ContainsKey(pair.Key))
                {
                    entry = scoreByAssignedID[pair.Key];
                }


                if (entry != null)
                {
                    Double score = entry.score;
                    tokenFrequencyAndScoreDictionary.Add(pair.Value.primary.terms, score);
                }
            }

            return(tokenFrequencyAndScoreDictionary);
        }
        //public static Dictionary<String, Dictionary<String, Dictionary<String, DocumentSelectResultEntry>>> GetByCategoryDomainAssignedID (this IEnumerable<DocumentSelectResultEntry> entries, SpaceModel model, ILogBuilder log)
        //{
        //    Dictionary<String, Dictionary<String, Dictionary<String, DocumentSelectResultEntry>>> output = new Dictionary<string, Dictionary<string, Dictionary<string, DocumentSelectResultEntry>>>();


        //    var byDomain = entries.GetByDomain(log);

        //    var byCategoryAssignedID = GetByAssignIDCategory()

        //}

        /// <summary>
        /// Gets the by assign identifier category.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="catIndex">Index of the cat.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public static Dictionary <String, List <DocumentSelectResultEntry> > GetByAssignIDCategory(this DocumentSelectResult context, Dictionary <string, List <string> > catIndex, ILogBuilder log)
        {
            Dictionary <String, List <DocumentSelectResultEntry> > output = new Dictionary <string, List <DocumentSelectResultEntry> >();


            Dictionary <String, DocumentSelectResultEntry> byID = context.GetByAssignedID(log);


            foreach (var pair in catIndex)
            {
                output.Add(pair.Key, new List <DocumentSelectResultEntry>());

                foreach (var k in pair.Value)
                {
                    output[pair.Key].Add(byID[k]);
                }
            }



            return(output);
        }
        /// <summary>
        /// Gets nested dictionaries: [category][domain][assignedID]
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public static Dictionary <String, Dictionary <String, Dictionary <String, DocumentSelectResultEntry> > > GetByCategoryDomainAssignedID(this DocumentSelectResult context, ILogBuilder log)
        {
            Dictionary <String, Dictionary <String, Dictionary <String, DocumentSelectResultEntry> > > output = new Dictionary <string, Dictionary <string, Dictionary <string, DocumentSelectResultEntry> > >();

            var byAssigned = context.GetByAssignedID(log);

            List <string> labels = context.spaceModel.LabelToDocumentLinks.GetAllDistinctNames();

            foreach (String label in labels)
            {
                output.Add(label, new Dictionary <String, Dictionary <String, DocumentSelectResultEntry> >());

                List <SpaceDocumentModel> linked_documents = context.spaceModel.LabelToDocumentLinks.GetAllLinkedB(label);

                List <DocumentSelectResultEntry> underLabel = new List <DocumentSelectResultEntry>();

                foreach (var sdoc in linked_documents)
                {
                    underLabel.Add(byAssigned[sdoc.name]);
                }


                var byDomain = underLabel.GetByDomain(log);

                foreach (var sitePair in byDomain)
                {
                    output[label].Add(sitePair.Key, new Dictionary <string, DocumentSelectResultEntry>());

                    foreach (var pagePair in sitePair.Value)
                    {
                        output[label][sitePair.Key].Add(pagePair.AssignedID, pagePair);
                    }
                }
            }



            return(output);
        }