本文整理了Java中org.apache.lucene.analysis.Token.type()
方法的一些代码示例,展示了Token.type()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token.type()
方法的具体详情如下:
包路径:org.apache.lucene.analysis.Token
类名称:Token
方法名:type
[英]The lexical type of the token.
[中]标记的词汇类型。
代码示例来源:origin: org.compass-project/compass
public String getType() {
return token.type();
}
代码示例来源:origin: hibernate/hibernate-search
public static void displayTokensWithFullDetails(Analyzer analyzer, String field, String text) throws IOException {
Token[] tokens = tokensFromAnalysis( analyzer, field, text );
StringBuilder builder = new StringBuilder();
int position = 0;
for ( Token token : tokens ) {
int increment = token.getPositionIncrement();
if ( increment > 0 ) {
position = position + increment;
builder.append( "\n" ).append( position ).append( ": " );
}
builder.append( "[" )
.append( getTermText( token ) )
.append( ":" )
.append( token.startOffset() )
.append( "->" )
.append(
token.endOffset()
)
.append( ":" )
.append( token.type() )
.append( "] " );
log.debug( builder.toString() );
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
public static void displayTokensWithFullDetails(Analyzer analyzer, String field, String text) throws IOException {
Token[] tokens = tokensFromAnalysis( analyzer, field, text );
StringBuilder builder = new StringBuilder();
int position = 0;
for ( Token token : tokens ) {
int increment = token.getPositionIncrement();
if ( increment > 0 ) {
position = position + increment;
builder.append( "\n" ).append( position ).append( ": " );
}
builder.append( "[" )
.append( getTermText( token ) )
.append( ":" )
.append( token.startOffset() )
.append( "->" )
.append(
token.endOffset()
)
.append( ":" )
.append( token.type() )
.append( "] " );
log.debug( builder.toString() );
}
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
firstTok.startOffset(),
tok.endOffset(),
firstTok.type());
代码示例来源:origin: lucene/lucene
String type = t.type();
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
while(tok1!=null || tok2!=null) {
while (tok1 != null && (pos1 <= pos2 || tok2==null)) {
Token tok = new Token(tok1.startOffset(), tok1.endOffset(), tok1.type());
tok.setTermBuffer(tok1.termBuffer(), 0, tok1.termLength());
tok.setPositionIncrement(pos1-pos);
Token tok = new Token(tok2.startOffset(), tok2.endOffset(), tok2.type());
tok.setTermBuffer(tok2.termBuffer(), 0, tok2.termLength());
tok.setPositionIncrement(pos2-pos);
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
Token mergedToken = new Token(termText.toString(), startOffset, token.endOffset(), token.type());
mergedToken.setPositionIncrement(firstPositionIncrement);
return mergedToken;
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
if (prev != null && prev.type() != "gram") {
if (next != null && next.type() == "gram") {
.startOffset(), token.endOffset(), token.type());
token.setPositionIncrement(1);
return token;
token.endOffset(), token.type());
assert token.type() == "word";
return token;
代码示例来源:origin: lucene/lucene
/**
* @return Returns the next token in the stream, or null at EOS
*/
public final Token next() throws IOException
{
if ((token = input.next()) == null)
{
return null;
}
else
{
String s = stemmer.stem(token.termText());
if (!s.equals(token.termText()))
{
return new Token(s, token.startOffset(), token.endOffset(),
token.type());
}
return token;
}
}
代码示例来源:origin: lucene/lucene
/**
* @return Returns the next token in the stream, or null at EOS
*/
public final Token next()
throws IOException
{
if ( ( token = input.next() ) == null ) {
return null;
}
// Check the exclusiontable
else if ( exclusionSet != null && exclusionSet.contains( token.termText() ) ) {
return token;
}
else {
String s = stemmer.stem( token.termText() );
// If not stemmed, dont waste the time creating a new token
if ( !s.equals( token.termText() ) ) {
return new Token( s, token.startOffset(),
token.endOffset(), token.type() );
}
return token;
}
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
Token newTok = new Token(firstTok.startOffset(), lastTok.endOffset(), firstTok.type());
newTok.setTermBuffer(repTok.termBuffer(), 0, repTok.termLength());
repPos += repTok.getPositionIncrement();
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
final String type = nextToken.type();
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
final String type = nextToken.type();
代码示例来源:origin: treygrainger/solr-in-action
@Override
public boolean incrementToken() throws IOException {
if (this.tokens == null) {
String data = convertReaderToString(this.multiTextInput.Reader);
if (data.equals("")) {
return false;
}
// get tokens
this.tokens = mergeToSingleTokenStream(createPositionsToTokensMap(
this.namedAnalyzers, data));
if (this.tokens == null) {
// at end of stream for some reason
return false;
}
}
if (tokens.isEmpty()) {
this.tokens = null;
return false;
} else {
clearAttributes();
Token token = tokens.removeFirst();
this.charTermAttribute.copyBuffer(token.buffer(), 0, token.length());
this.offsetAttribute.setOffset(token.startOffset(), token.endOffset()
+ this.startingOffset);
this.typeAttribute.setType(token.type());
this.positionAttribute.setPositionIncrement(token.getPositionIncrement());
return true;
}
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
tokenNamedList.add("raw_text", token.term());
tokenNamedList.add("type", token.type());
tokenNamedList.add("start", token.startOffset());
tokenNamedList.add("end", token.endOffset());
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
static NamedList<NamedList<Object>> getTokens(TokenStream tstream) throws IOException {
// outer is namedList since order of tokens is important
NamedList<NamedList<Object>> tokens = new NamedList<NamedList<Object>>();
Token t = null;
while (((t = tstream.next()) != null)) {
NamedList<Object> token = new SimpleOrderedMap<Object>();
tokens.add("token", token);
token.add("value", new String(t.termBuffer(), 0, t.termLength()));
token.add("start", t.startOffset());
token.add("end", t.endOffset());
token.add("posInc", t.getPositionIncrement());
token.add("type", t.type());
//TODO: handle payloads
}
return tokens;
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
private void setCurrentToken(Token token) {
if (token == null) return;
clearAttributes();
termAtt.copyBuffer(token.buffer(), 0, token.length());
posIncrAtt.setPositionIncrement(token.getPositionIncrement());
flagsAtt.setFlags(token.getFlags());
offsetAtt.setOffset(token.startOffset(), token.endOffset());
typeAtt.setType(token.type());
payloadAtt.setPayload(token.getPayload());
}
代码示例来源:origin: org.apache.lucene/lucene-analyzers
private void setCurrentToken(Token token) {
if (token == null) return;
clearAttributes();
termAtt.copyBuffer(token.buffer(), 0, token.length());
posIncrAtt.setPositionIncrement(token.getPositionIncrement());
flagsAtt.setFlags(token.getFlags());
offsetAtt.setOffset(token.startOffset(), token.endOffset());
typeAtt.setType(token.type());
payloadAtt.setPayload(token.getPayload());
}
代码示例来源:origin: org.apache.lucene/lucene-analyzers
@Override
public final boolean incrementToken() throws IOException {
if (matrix == null) {
matrix = new Matrix();
// fill matrix with maximumShingleSize columns
while (matrix.columns.size() < maximumShingleSize && readColumn()) {
// this loop looks ugly
}
}
// this loop exists in order to avoid recursive calls to the next method
// as the complexity of a large matrix
// then would require a multi gigabyte sized stack.
Token token;
do {
token = produceNextToken(reusableToken);
} while (token == request_next_token);
if (token == null) return false;
clearAttributes();
termAtt.copyBuffer(token.buffer(), 0, token.length());
posIncrAtt.setPositionIncrement(token.getPositionIncrement());
flagsAtt.setFlags(token.getFlags());
offsetAtt.setOffset(token.startOffset(), token.endOffset());
typeAtt.setType(token.type());
payloadAtt.setPayload(token.getPayload());
return true;
}
内容来源于网络,如有侵权,请联系作者删除!