示例#1
0
 /// <summary>
 /// Determines if collection contains a node with given identifier
 /// </summary>
 /// <param name="identifier">Identifier to check</param>
 /// <returns>True if contains</returns>
 public bool Contains(TIdentifier identifier)
 {
     rwLock.AcquireReaderLock(-1);
     try
     {
         return(storage.Contains(identifier));
     }
     finally
     {
         rwLock.ReleaseLock();
     }
 }
        public Task <SimilarityResult> GetSimilarityScoreAsync(Dictionary <string, double> tfIdfSourceContext, Document targetDocument)
        {
            var tfIdfSourceVector = tfIdfSourceContext.Values.ToList();
            var tfIdfTargetVector = tfIdfSourceContext.Keys.Select(t =>
            {
                var key = _tfIdfCacheKey(targetDocument, t);

                return(_keyValueStorage.Contains(key)
                        ? _keyValueStorage.Get <double>(key)
                        : 0d);
            })
                                    .ToList();

            return(Task.FromResult(new SimilarityResult
            {
                Id = targetDocument.Id,
                Score = GetCosineSimilarity(tfIdfSourceVector, tfIdfTargetVector)
            }));
        }
示例#3
0
 /// <summary>
 /// Determines if collection contains a node with given identifier
 /// </summary>
 /// <param name="identifier">Identifier to check</param>
 /// <returns>True if contains</returns>
 public bool Contains(TIdentifier identifier)
 {
     return(storage.Contains(identifier));
 }