Ejemplo n.º 1
0
 public override void AddPatterns(string sentId, IDictionary <int, ICollection <E> > patterns)
 {
     if (!patternsForEachToken.Contains(sentId))
     {
         patternsForEachToken[sentId] = new ConcurrentHashMap <int, ICollection <Pattern> >();
     }
     patternsForEachToken[sentId].PutAll(patterns);
 }
 // static void setCandidatePhraseMap(ConcurrentHashMap<String, CandidatePhrase> candmap){
 //  candidatePhraseMap = candmap;
 // }
 public static Edu.Stanford.Nlp.Patterns.CandidatePhrase CreateOrGet(string phrase)
 {
     phrase = phrase.Trim();
     if (candidatePhraseMap.Contains(phrase))
     {
         return(candidatePhraseMap[phrase]);
     }
     else
     {
         Edu.Stanford.Nlp.Patterns.CandidatePhrase p = new Edu.Stanford.Nlp.Patterns.CandidatePhrase(phrase);
         candidatePhraseMap[phrase] = p;
         return(p);
     }
 }
 /// <summary>Increments the entry for this guess and gold by the given increment amount.</summary>
 public virtual void Add(U guess, U gold, int increment)
 {
     lock (this)
     {
         Pair <U, U> pair = new Pair <U, U>(guess, gold);
         if (confTable.Contains(pair))
         {
             confTable[pair] = confTable[pair] + increment;
         }
         else
         {
             confTable[pair] = increment;
         }
     }
 }
Ejemplo n.º 4
0
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual void CloseFileSystem(FileSystem fs)
 {
     if (fsCache.Contains(fs.GetConf().Get(HttpfsFsUser)))
     {
         fsCache[fs.GetConf().Get(HttpfsFsUser)].Release();
     }
 }
Ejemplo n.º 5
0
 /*
  * Update the file-count statistics for a local cache-directory.
  * This will retrieve the localized path for the resource from
  * 1) inProgressRsrcMap if the resource was under localization and it
  * failed.
  * 2) LocalizedResource if the resource is already localized.
  * From this path it will identify the local directory under which the
  * resource was localized. Then rest of the path will be used to decrement
  * file count for the HierarchicalSubDirectory pointing to this relative
  * path.
  */
 private void DecrementFileCountForLocalCacheDirectory(LocalResourceRequest req, LocalizedResource
                                                       rsrc)
 {
     if (useLocalCacheDirectoryManager)
     {
         Path rsrcPath = null;
         if (inProgressLocalResourcesMap.Contains(req))
         {
             // This happens when localization of a resource fails.
             rsrcPath = Sharpen.Collections.Remove(inProgressLocalResourcesMap, req);
         }
         else
         {
             if (rsrc != null && rsrc.GetLocalPath() != null)
             {
                 rsrcPath = rsrc.GetLocalPath().GetParent().GetParent();
             }
         }
         if (rsrcPath != null)
         {
             Path parentPath = new Path(rsrcPath.ToUri().GetRawPath());
             while (!directoryManagers.Contains(parentPath))
             {
                 parentPath = parentPath.GetParent();
                 if (parentPath == null)
                 {
                     return;
                 }
             }
             if (parentPath != null)
             {
                 string parentDir = parentPath.ToUri().GetRawPath().ToString();
                 LocalCacheDirectoryManager dir = directoryManagers[parentPath];
                 string rsrcDir = rsrcPath.ToUri().GetRawPath();
                 if (rsrcDir.Equals(parentDir))
                 {
                     dir.DecrementFileCountForPath(string.Empty);
                 }
                 else
                 {
                     dir.DecrementFileCountForPath(Sharpen.Runtime.Substring(rsrcDir, parentDir.Length
                                                                             + 1));
                 }
             }
         }
     }
 }
        public virtual int AddToIndex(E o)
        {
            int index = item2Index[o];

            if (index != null)
            {
                return(index);
            }
            Lock.Lock();
            try
            {
                // Recheck state
                if (item2Index.Contains(o))
                {
                    return(item2Index[o]);
                }
                else
                {
                    int      newIndex = indexSize++;
                    object[] arr      = index2Item.Get();
                    System.Diagnostics.Debug.Assert(newIndex <= arr.Length);
                    if (newIndex == arr.Length)
                    {
                        // Increase size of array if necessary
                        object[] newArr = new object[2 * newIndex];
                        System.Array.Copy(arr, 0, newArr, 0, arr.Length);
                        arr = newArr;
                    }
                    arr[newIndex] = o;
                    index2Item.Set(arr);
                    item2Index[o] = newIndex;
                    return(newIndex);
                }
            }
            finally
            {
                Lock.Unlock();
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns true if the module is active in this channel;
 /// </summary>
 /// <param name="module"></param>
 /// <returns></returns>
 public bool HasModule(ISockNetChannelModule module)
 {
     return(modules.Contains(module));
 }
Ejemplo n.º 8
0
 public virtual bool ContainsToken(string nodeAddr)
 {
     return(nmTokens.Contains(nodeAddr));
 }