Example usage for org.apache.lucene.analysis.tokenattributes CharTermAttributeImpl CharTermAttributeImpl

List of usage examples for org.apache.lucene.analysis.tokenattributes CharTermAttributeImpl CharTermAttributeImpl

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.tokenattributes CharTermAttributeImpl CharTermAttributeImpl.

Prototype

public CharTermAttributeImpl() 

Source Link

Document

Initialize this attribute with empty term text

Usage

From source file:lux.search.highlight.StreamingElementTokens.java

License:Mozilla Public License

public StreamingElementTokens(TokenStream tokens) {
    super(tokens); // share the same attributes
    wrapped = tokens;/*w w  w  .  j  a v  a2s .c om*/
    termAtt = addAttribute(CharTermAttribute.class);
    posIncrAtt = addAttribute(PositionIncrementAttribute.class);
    term = new CharTermAttributeImpl();
    qnames = new ArrayList<QName>();
}

From source file:org.hibernate.search.test.serialization.SerializationTest.java

License:Open Source License

private List<List<AttributeImpl>> buildTokenSteamWithAttributes() {
    List<List<AttributeImpl>> tokens = new ArrayList<List<AttributeImpl>>();
    tokens.add(new ArrayList<AttributeImpl>());
    AnalysisRequestHandlerBase.TokenTrackingAttributeImpl attrImpl = new AnalysisRequestHandlerBase.TokenTrackingAttributeImpl();
    attrImpl.reset(new int[] { 1, 2, 3 }, 4);
    tokens.get(0).add(attrImpl);/*from  w  w w .  j  ava2 s  .c  om*/

    CharTermAttributeImpl charAttr = new CharTermAttributeImpl();
    charAttr.append("Wazzza");
    tokens.get(0).add(charAttr);

    PayloadAttributeImpl payloadAttribute = new PayloadAttributeImpl();
    payloadAttribute.setPayload(new Payload(new byte[] { 0, 1, 2, 3 }));
    tokens.get(0).add(payloadAttribute);

    KeywordAttributeImpl keywordAttr = new KeywordAttributeImpl();
    keywordAttr.setKeyword(true);
    tokens.get(0).add(keywordAttr);

    PositionIncrementAttributeImpl posIncrAttr = new PositionIncrementAttributeImpl();
    posIncrAttr.setPositionIncrement(3);
    tokens.get(0).add(posIncrAttr);

    FlagsAttributeImpl flagsAttr = new FlagsAttributeImpl();
    flagsAttr.setFlags(435);
    tokens.get(0).add(flagsAttr);

    TypeAttributeImpl typeAttr = new TypeAttributeImpl();
    typeAttr.setType("acronym");
    tokens.get(0).add(typeAttr);

    OffsetAttributeImpl offsetAttr = new OffsetAttributeImpl();
    offsetAttr.setOffset(4, 7);
    tokens.get(0).add(offsetAttr);
    return tokens;
}

From source file:org.hibernate.search.test.util.SerializationTestHelper.java

License:LGPL

public static List<List<AttributeImpl>> buildTokenStreamWithAttributes() {
    List<List<AttributeImpl>> tokens = new ArrayList<>();
    tokens.add(new ArrayList<AttributeImpl>());

    CharTermAttributeImpl charAttr = new CharTermAttributeImpl();
    charAttr.append("Wazzza");
    tokens.get(0).add(charAttr);/*from   w  w w . jav  a 2 s.  c  o m*/

    PayloadAttributeImpl payloadAttribute = new PayloadAttributeImpl();
    payloadAttribute.setPayload(new BytesRef(new byte[] { 0, 1, 2, 3 }));
    tokens.get(0).add(payloadAttribute);

    KeywordAttributeImpl keywordAttr = new KeywordAttributeImpl();
    keywordAttr.setKeyword(true);
    tokens.get(0).add(keywordAttr);

    PositionIncrementAttributeImpl posIncrAttr = new PositionIncrementAttributeImpl();
    posIncrAttr.setPositionIncrement(3);
    tokens.get(0).add(posIncrAttr);

    FlagsAttributeImpl flagsAttr = new FlagsAttributeImpl();
    flagsAttr.setFlags(435);
    tokens.get(0).add(flagsAttr);

    TypeAttributeImpl typeAttr = new TypeAttributeImpl();
    typeAttr.setType("acronym");
    tokens.get(0).add(typeAttr);

    OffsetAttributeImpl offsetAttr = new OffsetAttributeImpl();
    offsetAttr.setOffset(4, 7);
    tokens.get(0).add(offsetAttr);
    return tokens;
}