本文整理汇总了Java中org.apache.lucene.analysis.CharArraySet.add方法的典型用法代码示例。如果您正苦于以下问题:Java CharArraySet.add方法的具体用法?Java CharArraySet.add怎么用?Java CharArraySet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.CharArraySet
的用法示例。
在下文中一共展示了CharArraySet.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveNamedWords
import org.apache.lucene.analysis.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;
}
示例2: getStopWordList
import org.apache.lucene.analysis.CharArraySet; //导入方法依赖的package包/类
public static CharArraySet getStopWordList(Version luceneVersion, String stopwordList, boolean ignoreCase) {
String[] terms = stopwordList.split(",");
CharArraySet stopwordSet = new CharArraySet(luceneVersion, terms.length, ignoreCase);
for (String term : terms) {
stopwordSet.add(term);
}
return CharArraySet.unmodifiableSet(stopwordSet);
}
示例3: remove
import org.apache.lucene.analysis.CharArraySet; //导入方法依赖的package包/类
private CharArraySet remove(char[] charArray) {
CharArraySet newSet = new CharArraySet(5, false);
for (Object aCurrentSetToCheck : currentSetToCheck) {
char[] phrase = (char[]) aCurrentSetToCheck;
if (!isEqualTo(phrase, charArray) && startsWith(phrase, charArray) || endsWith(charArray, phrase)) {
newSet.add(phrase);
}
}
return newSet;
}
示例4: processDoc
import org.apache.lucene.analysis.CharArraySet; //导入方法依赖的package包/类
private void processDoc(int docid, String fieldName, Set<String> selector,
CharArraySet set) throws IOException {
Terms terms = searcher.getIndexReader().getTermVector(docid, fieldName);
if (terms != null) {
TermsEnum te = terms.iterator();
BytesRef bytes = te.next();
while (bytes != null) {
set.add(bytes);
bytes = te.next();
}
} else if (analyzer != null) {
Document document = searcher.doc(docid, selector);
IndexableField[] fields = document.getFields(fieldName);
if (fields == null) {
return;
}
for (IndexableField field : fields) {
String s = field.stringValue();
//is this possible
if (s == null) {
continue;
}
processFieldEntry(fieldName, s, set);
}
} else {
throw new IllegalArgumentException("The field must have a term vector or the analyzer must" +
" not be null.");
}
}
示例5: processFieldEntry
import org.apache.lucene.analysis.CharArraySet; //导入方法依赖的package包/类
private void processFieldEntry(String fieldName, String s, CharArraySet set) throws IOException {
TokenStream ts = analyzer.tokenStream(fieldName, s);
CharTermAttribute cattr = ts.getAttribute(CharTermAttribute.class);
ts.reset();
while (ts.incrementToken()) {
set.add(cattr.toString());
}
ts.end();
ts.close();
}