Esempio n. 1
0
        /// <summary>
        /// Queries table for specified terms and return aggregated score. The score source is specified by <see cref="termTableColumns.tf_idf"/> (only numeric columns are supported).
        /// </summary>
        /// <param name="queryTerms">Terms to test against the table, terms found are used in calculation.</param>
        /// <param name="scoreToUse">What numeric property of matched term to use for aggregation.</param>
        /// <param name="aggregation">The aggregation type</param>
        /// <returns>Any score information from the query terms is ignored.</returns>
        public static double GetScoreForMatch(this IWeightTable table, IEnumerable <string> queryTerms, termTableColumns scoreToUse = termTableColumns.tf_idf, dataPointAggregationType aggregation = dataPointAggregationType.sum)
        {
            List <IWeightTableTerm> output = new List <IWeightTableTerm>();

            output = table.GetMatches(queryTerms);
            return(output.GetScoreAggregate(table, scoreToUse, aggregation));
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the matching term entries
        /// </summary>
        /// <param name="queryTerms">The query terms.</param>
        /// <returns></returns>
        public static List <IWeightTableTerm> GetMatches(this IWeightTable table, IEnumerable <IWeightTableTerm> queryTerms)
        {
            List <IWeightTableTerm> output        = new List <IWeightTableTerm>();
            List <string>           expandedQuery = new List <string>();

            foreach (IWeightTableTerm qt in queryTerms)
            {
                expandedQuery.AddUnique(qt.GetAllForms());
            }

            //queryTerms.ForEach(x => expandedQuery.AddRangeUnique(x.GetAllForms()));
            return(table.GetMatches(expandedQuery));
        }