當前位置: 首頁>>代碼示例>>Java>>正文


Java AttributeSource.copyTo方法代碼示例

本文整理匯總了Java中org.apache.lucene.util.AttributeSource.copyTo方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributeSource.copyTo方法的具體用法?Java AttributeSource.copyTo怎麽用?Java AttributeSource.copyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.util.AttributeSource的用法示例。


在下文中一共展示了AttributeSource.copyTo方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: incrementToken

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
@Override
public final boolean incrementToken() throws IOException {
    clearAttributes();
    if (first) {
        String[] words = walkTokens();
        if (words.length == 0) {
            return false;
        }
        createTags(words);
        first = false;
        indexToken = 0;
    }
    if (indexToken == tokenAttrs.size()) {
        return false;
    }
    AttributeSource as = tokenAttrs.get(indexToken);
    Iterator<? extends Class<? extends Attribute>> it = as.getAttributeClassesIterator();
    while (it.hasNext()) {
        Class<? extends Attribute> attrClass = it.next();
        if (!hasAttribute(attrClass)) {
            addAttribute(attrClass);
        }
    }
    as.copyTo(this);
    indexToken++;
    return true;
}
 
開發者ID:jprante,項目名稱:elasticsearch-analysis-opennlp,代碼行數:28,代碼來源:OpenNLPTokenFilter.java

示例2: incrementToken

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
@Override
public boolean incrementToken() {
  if (tokenIterator.hasNext()) {
    clearAttributes();
    AttributeSource next = tokenIterator.next();
    Iterator<Class<? extends Attribute>> atts = next.getAttributeClassesIterator();
    while (atts.hasNext()) // make sure all att impls in the token exist here
      addAttribute(atts.next());
    next.copyTo(this);
    return true;
  } else {
    return false;
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:15,代碼來源:AnalysisRequestHandlerBase.java

示例3: incrementToken

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
@Override
public final boolean incrementToken() throws IOException {
	if (tokenQueue.size() > 0) {
		tokenQueue.remove(0).copyTo(this);
		return true;
	}
	if (endOfInput == false && input.incrementToken()) {
		if (termAtt.toString().equals("dogs")) {
			addSynonymAndRestoreOrigToken("dog", 1, offsetAtt.endOffset());
		} else if (termAtt.toString().equals("guinea")) {
			AttributeSource firstSavedToken = cloneAttributes();
			if (input.incrementToken()) {
				if (termAtt.toString().equals("pig")) {
					AttributeSource secondSavedToken = cloneAttributes();
					int secondEndOffset = offsetAtt.endOffset();
					firstSavedToken.copyTo(this);
					addSynonym("cavy", 2, secondEndOffset);
					tokenQueue.add(secondSavedToken);
				} else if (termAtt.toString().equals("dogs")) {
					tokenQueue.add(cloneAttributes());
					addSynonym("dog", 1, offsetAtt.endOffset());
				}
			} else {
				endOfInput = true;
			}
			firstSavedToken.copyTo(this);
		}
		return true;
	} else {
		endOfInput = true;
		return false;
	}
}
 
開發者ID:easynet-cn,項目名稱:resource-query-parser,代碼行數:34,代碼來源:MockSynonymFilter.java

示例4: incrementToken

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
@Override
public boolean incrementToken() throws IOException {
    //clearAttributes();
    if (first) {
        //gather all tokens from doc
        String[] words = walkTokens();
        if (words.length == 0) {
            return false;
        }
        //tagging
        posTags = createTags(words);
        first = false;
        tokenIdx = 0;
    }

    if (tokenIdx == tokenAttrs.size()) {
        resetParams();
        return false;
    }

    AttributeSource as = tokenAttrs.get(tokenIdx);
    Iterator<? extends Class<? extends Attribute>> it = as.getAttributeClassesIterator();
    while (it.hasNext()) {
        Class<? extends Attribute> attrClass = it.next();
        if (!hasAttribute(attrClass)) {
            addAttribute(attrClass);
        }
    }
    as.copyTo(this);
    MWEMetadata metadata = exitingPayload.getPayload() == null ? new MWEMetadata() :
            MWEMetadata.deserialize(exitingPayload.getPayload().utf8ToString());
    metadata.addMetaData(MWEMetadataType.POS, posTags[tokenIdx]);
    exitingPayload.setPayload(new BytesRef(MWEMetadata.serialize(metadata)));
    tokenIdx++;
    return true;
}
 
開發者ID:ziqizhang,項目名稱:jate,代碼行數:37,代碼來源:OpenNLPPOSTaggerFilter.java

示例5: copy

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
private void copy(AttributeSource target, AttributeSource source) {
  if (target != source)
    source.copyTo(target);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:SlowSynonymFilter.java

示例6: addSynonymAndRestoreOrigToken

import org.apache.lucene.util.AttributeSource; //導入方法依賴的package包/類
private void addSynonymAndRestoreOrigToken(String synonymText, int posLen, int endOffset) {
	AttributeSource origToken = cloneAttributes();
	addSynonym(synonymText, posLen, endOffset);
	origToken.copyTo(this);
}
 
開發者ID:easynet-cn,項目名稱:resource-query-parser,代碼行數:6,代碼來源:MockSynonymFilter.java


注:本文中的org.apache.lucene.util.AttributeSource.copyTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。