当前位置: 首页>>代码示例>>Java>>正文


Java AttributeImpl类代码示例

本文整理汇总了Java中org.apache.lucene.util.AttributeImpl的典型用法代码示例。如果您正苦于以下问题:Java AttributeImpl类的具体用法?Java AttributeImpl怎么用?Java AttributeImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AttributeImpl类属于org.apache.lucene.util包,在下文中一共展示了AttributeImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
  if (target instanceof PackedTokenAttributeImpl) {
    final PackedTokenAttributeImpl to = (PackedTokenAttributeImpl) target;
    to.copyBuffer(buffer(), 0, length());
    to.positionIncrement = positionIncrement;
    to.positionLength = positionLength;
    to.startOffset = startOffset;
    to.endOffset = endOffset;
    to.type = type;
  } else {
    super.copyTo(target);
    ((OffsetAttribute) target).setOffset(startOffset, endOffset);
    ((PositionIncrementAttribute) target).setPositionIncrement(positionIncrement);
    ((PositionLengthAttribute) target).setPositionLength(positionLength);
    ((TypeAttribute) target).setType(type);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PackedTokenAttributeImpl.java

示例2: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
  if (target instanceof Token) {
    final Token to = (Token) target;
    to.reinit(this);
    // reinit shares the payload, so clone it:
    if (payload !=null) {
      to.payload = payload.clone();
    }
  } else {
    super.copyTo(target);
    ((OffsetAttribute) target).setOffset(startOffset, endOffset);
    ((PositionIncrementAttribute) target).setPositionIncrement(positionIncrement);
    ((PayloadAttribute) target).setPayload((payload == null) ? null : payload.clone());
    ((FlagsAttribute) target).setFlags(flags);
    ((TypeAttribute) target).setType(type);
  }
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:19,代码来源:Token.java

示例3: getTokens

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
/**
 * Returns the list of tokens extracted from the query string using the specified analyzer.
 *
 * @param field document field.
 *
 * @param queryTerms query string.
 *
 * @param distinctTokens if true, return the distinct tokens in the query string.
 *
 * @return the list of tokens extracted from the given query.
 *
 * @throws IOException
 */
List<String> getTokens(String field, String queryTerms, boolean distinctTokens) throws IOException {

    List<String> tokens = new ArrayList<String>();

    StringReader topicTitleReader = new StringReader(queryTerms);

    Set<String> seenTokens = new TreeSet<String>();

    TokenStream tok;
    tok = analyzer.tokenStream(field, topicTitleReader);
    tok.reset();
    while (tok.incrementToken()) {
        Iterator<AttributeImpl> atts = tok.getAttributeImplsIterator();
        AttributeImpl token = atts.next();
        String text = "" + token;
        if (seenTokens.contains(text) && distinctTokens) {
            continue;
        }
        seenTokens.add(text);
        tokens.add(text);
    }
    tok.close();

    return tokens;
}
 
开发者ID:lucene4ir,项目名称:lucene4ir,代码行数:39,代码来源:Retriever.java

示例4: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
/**
 * We just want to create a new array if the length differs.
 */
@Override
public void copyTo(AttributeImpl input) {
   StemmingBufferAttributeImpl copyAttributeImpl = (StemmingBufferAttributeImpl) input;
   if (copyAttributeImpl.stemmedToken.length < stemmedTokenLength) {
      copyAttributeImpl.stemmedToken = new char[stemmedTokenLength];
   }
   System.arraycopy(stemmedToken, 0, copyAttributeImpl.stemmedToken, 0, stemmedTokenLength);

   if (copyAttributeImpl.originalToken.length < originalTokenLength) {
      copyAttributeImpl.originalToken = new char[originalTokenLength];
   }
   System.arraycopy(originalToken, 0, copyAttributeImpl.originalToken, 0, originalTokenLength);

   copyAttributeImpl.stemmedTokenLength = stemmedTokenLength;
   copyAttributeImpl.originalTokenLength = originalTokenLength;
   copyAttributeImpl.stemmedTokenHasBeenEmitted = stemmedTokenHasBeenEmitted;
}
 
开发者ID:shopping24,项目名称:solr-analyzers,代码行数:21,代码来源:StemmingBufferAttributeImpl.java

示例5: createComponents

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public TokenStreamComponents createComponents(String fieldName, Reader reader) {
  Tokenizer ts = new Tokenizer(Token.TOKEN_ATTRIBUTE_FACTORY, reader) {
    final AttributeImpl reusableToken = (AttributeImpl) addAttribute(CharTermAttribute.class);
    int p = 0;
    
    @Override
    public boolean incrementToken() {
      if( p >= tokens.length ) return false;
      clearAttributes();
      tokens[p++].copyTo(reusableToken);
      return true;
    }

    @Override
    public void reset() throws IOException {
      super.reset();
      this.p = 0;
    }
  };
  return new TokenStreamComponents(ts);
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:IndexTimeSynonymTest.java

示例6: test

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
public void test() throws IOException {
  Token token = new Token();
  SingleTokenTokenStream ts = new SingleTokenTokenStream(token);
  AttributeImpl tokenAtt = (AttributeImpl) ts.addAttribute(CharTermAttribute.class);
  assertTrue(tokenAtt instanceof Token);
  ts.reset();

  assertTrue(ts.incrementToken());
  assertEquals(token, tokenAtt);
  assertFalse(ts.incrementToken());
  
  token = new Token("hallo", 10, 20, "someType");
  ts.setToken(token);
  ts.reset();

  assertTrue(ts.incrementToken());
  assertEquals(token, tokenAtt);
  assertFalse(ts.incrementToken());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:TestSingleTokenTokenFilter.java

示例7: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
  final List<CompiledAutomaton> targetAutomata =
    ((LevenshteinAutomataAttribute) target).automata();
  targetAutomata.clear();
  targetAutomata.addAll(automata);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:FuzzyTermsEnum.java

示例8: addSinkTokenStream

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
/**
 * Adds a {@link SinkTokenStream} created by another <code>TeeSinkTokenFilter</code>
 * to this one. The supplied stream will also receive all consumed tokens.
 * This method can be used to pass tokens from two different tees to one sink.
 */
public void addSinkTokenStream(final SinkTokenStream sink) {
  // check that sink has correct factory
  if (!this.getAttributeFactory().equals(sink.getAttributeFactory())) {
    throw new IllegalArgumentException("The supplied sink is not compatible to this tee");
  }
  // add eventually missing attribute impls to the existing sink
  for (Iterator<AttributeImpl> it = this.cloneAttributes().getAttributeImplsIterator(); it.hasNext(); ) {
    sink.addAttributeImpl(it.next());
  }
  this.sinks.add(new WeakReference<>(sink));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:TeeSinkTokenFilter.java

示例9: delegatingAttributeFactory

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
/** Make this tokenizer get attributes from the delegate token stream. */
private static final AttributeFactory delegatingAttributeFactory(final AttributeSource source) {
    return new AttributeFactory() {
        @Override
        public AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass) {
            return (AttributeImpl) source.addAttribute(attClass);
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:NumericTokenizer.java

示例10: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
	AdditionalTermAttribute t = (AdditionalTermAttribute) target;
	for(int inx=0;inx < additionalTerms.size(); inx++) {
		String term = additionalTerms.get(inx);
		String type = types.get(inx);
		@SuppressWarnings("rawtypes")
		List synonyms = this.synonyms;
		int[] offset = offsets.get(inx);
		int subLength = this.subLength;
		t.addAdditionalTerm(term, type, synonyms, subLength, offset[0], offset[1]);
	}
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:14,代码来源:AdditionalTermAttributeImpl.java

示例11: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
  List<StringBuilder> cloned = null;
  if (tags != null) {
    cloned = new ArrayList<>(tags.size());
    for (StringBuilder b : tags) {
      cloned.add(new StringBuilder(b));
    }
  }
  ((MorphosyntacticTagsAttribute) target).setTags(cloned);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:MorphosyntacticTagsAttributeImpl.java

示例12: copyTo

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {

  if (!(target instanceof UniqueFieldAttributeImpl)) {
    throw new IllegalArgumentException(
        "cannot copy the values from attribute UniqueFieldAttribute to an instance of "
            + target.getClass().getName());
  }

  UniqueFieldAttributeImpl uniqueFieldAttr = (UniqueFieldAttributeImpl) target;
  uniqueFieldAttr.uniqueField = uniqueField.toString();

}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:UniqueFieldAttributeImpl.java

示例13: createAttributeInstance

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
@Override
public AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass) {
  if (attClass == TermToBytesRefAttribute.class)
    return new MyTermAttributeImpl();
  if (CharTermAttribute.class.isAssignableFrom(attClass))
    throw new IllegalArgumentException("no");
  return delegate.createAttributeInstance(attClass);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:Test2BTerms.java

示例14: assertCloneIsEqual

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
public static <T extends AttributeImpl> T assertCloneIsEqual(T att) {
  @SuppressWarnings("unchecked")
  T clone = (T) att.clone();
  assertEquals("Clone must be equal", att, clone);
  assertEquals("Clone's hashcode must be equal", att.hashCode(), clone.hashCode());
  return clone;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:TestCharTermAttributeImpl.java

示例15: assertCopyIsEqual

import org.apache.lucene.util.AttributeImpl; //导入依赖的package包/类
public static <T extends AttributeImpl> T assertCopyIsEqual(T att) throws Exception {
  @SuppressWarnings("unchecked")
  T copy = (T) att.getClass().newInstance();
  att.copyTo(copy);
  assertEquals("Copied instance must be equal", att, copy);
  assertEquals("Copied instance's hashcode must be equal", att.hashCode(), copy.hashCode());
  return copy;
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestCharTermAttributeImpl.java


注:本文中的org.apache.lucene.util.AttributeImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。