
org.deeplearning4j.word2vec.util.Util Maven / Gradle / Ivy
The newest version!
package org.deeplearning4j.word2vec.util;
import java.util.List;
import java.util.Map;
import org.deeplearning4j.berkeley.Counter;
import org.deeplearning4j.berkeley.MapFactory;
public class Util {
/**
* Returns a thread safe counter
* @return
*/
public static Counter parallelCounter() {
MapFactory factory = new MapFactory() {
private static final long serialVersionUID = 5447027920163740307L;
@Override
public Map buildMap() {
return new java.util.concurrent.ConcurrentHashMap();
}
};
Counter totalWords = new Counter(factory);
return totalWords;
}
public static boolean matchesAnyStopWord(List stopWords,String word) {
for(String s : stopWords)
if(s.equalsIgnoreCase(word))
return true;
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy