apache / apache/lucene

The tokenstream create by SmartChineseAnalyzer can't reset [LUCENE-3834]

Open
#4,907 0 comments 0 reactions 0 assignees View on GitHub
affects-version:3.5 legacy-jira-priority:Minor module:analysis type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

That is because the field input in class SentenceTokenizer isn't reset after we call the method reset().

They are two input field,one is from Tokenizer and another is from TokenFilter,if we need to reset a tokenstream created by SmartChineseAnalyzer, both them need reset.This bug is because of the author forget reset input field in class SentenceTokenizer .

class path : org.apache.lucene.analysis.cn.smart.SentenceTokenizer

oringal code

public final class SentenceTokenizer extends Tokenizer {
....
`@Override`
public void reset() throws IOException {
super.reset();
tokenStart = tokenEnd = 0;
}

...
}

this method should changes as follow


public void reset() throws IOException {
super.reset();
/**should reset input**/
if (input.markSupported())
input.reset();
tokenStart = tokenEnd = 0;
}

---
Migrated from [LUCENE-3834](https://issues.apache.org/jira/browse/LUCENE-3834) by dingjin, updated Mar 01 2012

Contributor guide

Open the contributing guide

Research direction

Read org.apache.lucene.analysis.cn.smart.SentenceTokenizer, starting with its reset() method and the Tokenizer and TokenFilter input fields described in the issue. Verify that resetting a SmartChineseAnalyzer token stream handles both inputs and resets tokenStart and tokenEnd; done means repeated reset and reuse no longer retain prior input state.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.