Lucene - Token

Token representa o texto ou a palavra em um documento com detalhes relevantes, como seus metadados (posição, deslocamento inicial, deslocamento final, tipo de token e incremento de posição).

Declaração de Classe

A seguir está a declaração para o org.apache.lucene.analysis.Token classe:

public class Token
   extends TermAttributeImpl
      implements TypeAttribute, PositionIncrementAttribute, 
         FlagsAttribute, OffsetAttribute, 
         PayloadAttribute, PositionLengthAttribute

Campos

A seguir estão os campos para o org.apache.lucene.analysis.Token classe -

  • static AttributeSource.AttributeFactory TOKEN_ATTRIBUTE_FACTORY - Fábrica de conveniência que retorna Token como implementação para os atributos básicos e retorna o impl padrão (com "Impl" anexado) para todos os outros atributos.

Construtores de classe

A tabela a seguir mostra os diferentes construtores de classes -

S.No. Construtor e descrição
1

Token()

Constrói um Token que anula o texto.

2

Token(char[] startTermBuffer, int termBufferOffset, int termBufferLength, int start, int end)

Constrói um token com o buffer de termo dado (deslocamento e comprimento), deslocamento inicial e final

3

Token(int start, int end)

Constrói um Token com texto nulo e deslocamentos inicial e final.

4

Constructs a Token with null text and start & end offsets plus flags.

5

Constructs a Token with null text and start/ end offsets plus the Token type.

6

Token(String text, int start, int end)

Constrói um Token com o texto do termo fornecido e deslocamentos de início / fim.

7

Token(String text, int start, int end, int flags)

Constrói um Token com o texto, deslocamentos de início / fim e tipo fornecidos.

8

Token(String text, int start, int end, String typ)

Constrói um Token com o texto, deslocamentos de início / fim e tipo fornecidos.

Métodos de aula

A tabela a seguir mostra os diferentes métodos de classe -

S.No. Método e Descrição
1

void clear()

Redefine o termo text, payload, flags e positionIncrement, startOffset, endOffset e tipo de token para o padrão.

2

Object clone()

Este é um clone superficial.

3

Token clone(char[] newTermBuffer, int newTermOffset, int newTermLength, int newStartOffset, int newEndOffset)

Faz um clone, mas substitui o termo buffer e deslocamento inicial / final no processo.

4

void copyTo(AttributeImpl target)

Copia os valores deste Atributo para o atributo de destino transmitido.

5

int endOffset()

Retorna o deslocamento final do Token; um maior que a posição do último caractere correspondente a este token no texto de origem.

6

boolean equals(Object obj)

7

int getFlags()

Obtém o bitset para quaisquer bits que foram definidos.

8

Payload getPayload()

Retorna a carga útil deste Token.

9

int getPositionIncrement()

Retorna o incremento de posição deste token.

10

int getPositionLength()

Obtenha o comprimento da posição.

11

int hashCode()

12

void reflectWith(AttributeReflector reflector)

Este método é para introspecção de atributos, ele deve simplesmente adicionar a chave / valores que este atributo contém para o AttributeReflector fornecido.

13

Token reinit(char[] newTermBuffer, int newTermOffset, int newTermLength, int newStartOffset, int newEndOffset)

Abreviação para chamar clear (), CharTermAttributeImpl.copyBuffer (char [], int, int), setStartOffset (int), setEndOffset (int) setType (java.lang.String) em Token.DEFAULT_TYPE

14

Token reinit(char[] newTermBuffer, int newTermOffset, int newTermLength, int newStartOffset, int newEndOffset, String newType)

Abreviação para chamar clear (), CharTermAttributeImpl.copyBuffer (char [], int, int), setStartOffset (int), setEndOffset (int), setType (java.lang.String)

15

Token reinit(String newTerm, int newStartOffset, int newEndOffset)

Abreviação para chamar clear (), CharTermAttributeImpl.append (CharSequence), setStartOffset (int), setEndOffset (int) setType (java.lang.String) em Token.DEFAULT_TYPE

16

Token reinit(String newTerm, int newTermOffset, int newTermLength, int newStartOffset, int newEndOffset)

Abreviação para chamar clear (), CharTermAttributeImpl.append (CharSequence, int, int), setStartOffset (int), setEndOffset (int) setType (java.lang.String) em Token.DEFAULT_TYPE

17

Token reinit(String newTerm, int newTermOffset, int newTermLength, int newStartOffset, int newEndOffset, String newType)

Abreviação para chamar clear (), CharTermAttributeImpl.append (CharSequence, int, int), setStartOffset (int), setEndOffset (int) setType (java.lang.String)

18

Token reinit(String newTerm, int newStartOffset, int newEndOffset, String newType)

Abreviação para chamar clear (), CharTermAttributeImpl.append (CharSequence), setStartOffset (int), setEndOffset (int) setType (java.lang.String)

19

void reinit(Token prototype)

Copia os campos do token de protótipo para este.

20

void reinit(Token prototype, char[] newTermBuffer, int offset, int length)

Copia os campos do token de protótipo para este, com um termo diferente.

21

void reinit(Token prototype, String newTerm)

Copia os campos do token de protótipo para este, com um termo diferente.

22

void setEndOffset(int offset)

Define o deslocamento final.

23

void setFlags(int flags)

24

void setOffset(int startOffset, int endOffset)

Define o deslocamento inicial e final.

25

void setPayload(Payload payload)

Define a carga útil deste Token.

26

void setPositionIncrement(int positionIncrement)

Define o incremento da posição.

27

void setPositionLength(int positionLength)

Defina o comprimento da posição.

28

void setStartOffset(int offset)

Defina o deslocamento inicial.

29

void setType(String type)

Define o tipo léxico.

30

int startOffset()

Retorna o deslocamento inicial deste Token, a posição do primeiro caractere correspondente a este token no texto de origem.

31

String type()

Retorna o tipo léxico deste Token.

Métodos herdados

Esta classe herda métodos das seguintes classes -

  • org.apache.lucene.analysis.tokenattributes.TermAttributeImpl
  • org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
  • org.apache.lucene.util.AttributeImpl
  • java.lang.Object