com.mayabot.nlp.collection.dat.FastDatCharSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mynlp Show documentation
Show all versions of mynlp Show documentation
Maya Nlp subproject :mynlp
package com.mayabot.nlp.collection.dat;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
public class FastDatCharSet {
private DoubleArrayTrie map;
public FastDatCharSet(char... chars) {
HashSet set = new HashSet<>();
for (char aChar : chars) {
set.add(aChar);
}
set(set);
}
public FastDatCharSet(Set characterSet) {
set(characterSet);
}
private void set(Set characterSet) {
TreeSet treeMap = new TreeSet<>();
for (Character character : characterSet) {
treeMap.add(character.toString());
}
this.map = new DoubleArrayTrie(treeMap);
}
public boolean contains(char ch) {
return map.indexOf(ch) != -1;
}
}