本文整理汇总了Java中org.apache.lucene.analysis.util.CharArraySet.add方法的典型用法代码示例。如果您正苦于以下问题:Java CharArraySet.add方法的具体用法?Java CharArraySet.add怎么用?Java CharArraySet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.util.CharArraySet
的用法示例。
在下文中一共展示了CharArraySet.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uniqueStems
import org.apache.lucene.analysis.util.CharArraySet; //导入方法依赖的package包/类
/**
* Find the unique stem(s) of the provided word
*
* @param word Word to find the stems for
* @return List of stems for the word
*/
public List<CharsRef> uniqueStems(char word[], int length) {
List<CharsRef> stems = stem(word, length);
if (stems.size() < 2) {
return stems;
}
CharArraySet terms = new CharArraySet(8, dictionary.ignoreCase);
List<CharsRef> deduped = new ArrayList<>();
for (CharsRef s : stems) {
if (!terms.contains(s)) {
deduped.add(s);
terms.add(s);
}
}
return deduped;
}
示例2: resolveNamedWords
import org.apache.lucene.analysis.util.CharArraySet; //导入方法依赖的package包/类
private static CharArraySet resolveNamedWords(Collection<String> words, Map<String, Set<?>> namedWords, boolean ignoreCase) {
if (namedWords == null) {
return new CharArraySet(words, ignoreCase);
}
CharArraySet setWords = new CharArraySet(words.size(), ignoreCase);
for (String word : words) {
if (namedWords.containsKey(word)) {
setWords.addAll(namedWords.get(word));
} else {
setWords.add(word);
}
}
return setWords;
}
示例3: getStopFilter
import org.apache.lucene.analysis.util.CharArraySet; //导入方法依赖的package包/类
private TokenStream getStopFilter(String lang, Set<String> metadataStopWords, TokenStream stream) {
if (metadataStopWords != null && !metadataStopWords.isEmpty()) {
return new StopFilter(stream, new CharArraySet(metadataStopWords, false));
} else {
try {
InputStream in = ClassLoader.getSystemResourceAsStream(lang.toLowerCase() + ".stopwords");
if (in != null) {
logger.debug("Loading Stop words for lang={}", lang);
CharArraySet stopWords = new CharArraySet(30, true);
try (BufferedReader bin = new BufferedReader(new InputStreamReader(in))) {
String line;
String[] parts;
while ((line = bin.readLine()) != null) {
parts = line.split(Pattern.quote("|"));
line = parts[0].trim();
if (line.length() > 0) {
stopWords.add(line);
}
}
return new StopFilter(stream, stopWords);
}
} else {
logger.warn("No stop words found for lang={}", lang);
}
} catch (Exception e) {
logger.error("Error creating stop filter for lang={}", lang, e);
}
}
return stream;
}