Beispiel #1
0
 private double cossim_denumerator(TermInDoc item)
 {
     double sum = 0;
     
     foreach (var item2 in _tf_all_docs[item._doc_id])
     {
         sum += Math.Pow(tf_idf(item._doc_id,  item2.Key),2);
     }
     
     return Math.Sqrt(sum * _num_terms_in_query);
 }
Beispiel #2
0
        private double cossim_numerator(TermInDoc item)
        {
            double sum = 0;
            
            foreach (string term in _ExistingTerms)
            {
                sum += tf_idf(item._doc_id, term);
                if (is_in_headline(item._doc_id, term))
                    sum *= 2;
            }

            if (sum == 0)
                Console.WriteLine();
            
            return sum;
        }
Beispiel #3
0
 // using the psaudo LRU idea, when a term is already in cache, promote it by a flag is_popular
 private void promote_queue(string key, TermInDoc term)
 {
      // needs to promote
     cache[key].Add(term);
     main_dic[key].is_popular = true;
 }
Beispiel #4
0
 // adding to the inverted files dictionary
 private void add_to_dic(string p, TermInDoc termInDoc)
 {
     Posting post = new Posting();
     main_dic.TryAdd(p, post);
 }
Beispiel #5
0
 // add term to the cache
 private void add_to_cache(string key, TermInDoc term)
 {
     ConcurrentBag<TermInDoc> list = new ConcurrentBag<TermInDoc>();
     list.Add(term);
     if (queue.Count < _cache_size)
     {
         queue.Enqueue(key);
     }
     else
     {
         write2(_numOfTermsInPosting);
         queue.Enqueue(key);
     }
     cache.TryAdd(key, list);
 }