예제 #1
0
        private WeightDictionaryEntry _AddEntry(String term)
        {
            WeightDictionaryEntry en = null;

            if (index.ContainsKey(term))
            {
                en = index[term];
            }
            else
            {
                lock (GetEntryAddLock)
                {
                    if (!index.ContainsKey(term))
                    {
                        en = new WeightDictionaryEntry(term, new double[nDimensions]);

                        index.Add(term, en);
                    }
                    else
                    {
                        en = index[term];
                    }
                }
            }
            return(en);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightDictionaryEntryPairs"/> class.
 /// </summary>
 /// <param name="vectorA">The vector a.</param>
 /// <param name="vectorB">The vector b.</param>
 /// <param name="vectorADimID">The vector a dim identifier.</param>
 /// <param name="vectorBDimID">The vector b dim identifier.</param>
 public WeightDictionaryEntryPairs(IEnumerable <WeightDictionaryEntry> vectorA, IEnumerable <WeightDictionaryEntry> vectorB, Int32 vectorADimID = 0, Int32 vectorBDimID = 0)
 {
     foreach (WeightDictionaryEntry entryA in vectorA)
     {
         WeightDictionaryEntry matchB = vectorB.FirstOrDefault(x => x.name == entryA.name);
         if (matchB != null)
         {
             Add(new WeightDictionaryEntryPair(entryA.name, entryA.dimensions[vectorADimID], matchB.dimensions[vectorBDimID]));
         }
     }
 }
예제 #3
0
 public WeightDictionaryEntry AddEntry(WeightDictionaryEntry en, Boolean sum = false)
 {
     if (sum == false)
     {
         var entry = _AddEntry(en.name);
         entry.dimensions = en.dimensions;
         return(entry);
     }
     else
     {
         return(AddEntry(en.name, en.dimensions, true));
     }
 }
예제 #4
0
 public void Merge(WeightDictionaryEntry entry)
 {
     if (!index.ContainsKey(entry.name))
     {
         index.Add(entry.name, entry);
     }
     else
     {
         for (int i = 0; i < index[entry.name].dimensions.Length; i++)
         {
             index[entry.name].dimensions[i] += entry.dimensions[i];
         }
     }
 }