Beispiel #1
0
        static List <ObjectId> SortResult(List <ObjectId> docIds, List <string> query_words)
        {
            List <ObjectId>    ret    = new List <ObjectId>();
            List <DocIdResult> result = new List <DocIdResult>();

            foreach (ObjectId docId in docIds)
            {
                DocIdResult dr = new DocIdResult();
                dr.docId     = docId;
                dr.sum_tfidf = GetSumOfTFIDF(docId, query_words);
                result.Add(dr);
            }
            result.Sort();
            int count = 0, limit = 200;

            foreach (DocIdResult dr in result)
            {
                ret.Add(dr.docId);
                count++;
                if (count > limit)
                {
                    break;
                }
            }
            return(ret);
        }
Beispiel #2
0
        public int CompareTo(object obj)
        {
            DocIdResult other  = obj as DocIdResult;
            double      result = sum_tfidf - other.sum_tfidf;

            if (result > 0)
            {
                return(-1);
            }
            else if (result < 0)
            {
                return(1);
            }
            return(0);
        }
Beispiel #3
0
 static List<ObjectId> SortResult(List<ObjectId> docIds, List<string> query_words)
 {
     List<ObjectId> ret = new List<ObjectId>();
     List<DocIdResult> result = new List<DocIdResult>();
     foreach (ObjectId docId in docIds)
     {
         DocIdResult dr = new DocIdResult();
         dr.docId = docId;
         dr.sum_tfidf = GetSumOfTFIDF(docId, query_words);
         result.Add(dr);
     }
     result.Sort();
     int count = 0, limit = 200;
     foreach (DocIdResult dr in result)
     {
         ret.Add(dr.docId);
         count++;
         if (count > limit) break;
     }
     return ret;
 }