Skip to content

Instantly share code, notes, and snippets.

@pcdinh
Created September 24, 2009 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcdinh/192934 to your computer and use it in GitHub Desktop.
Save pcdinh/192934 to your computer and use it in GitHub Desktop.
package lucene1;
import java.io.StringReader;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
/**
* @see Lucene 2.4.1
* @since September 25, 2009
* @author Pcdinh
*/
public class StandardAnalyzerTest {
public static void main(String[] args) {
try {
Analyzer analyzer = new StandardAnalyzer(); // or any other analyzer
TokenStream ts = analyzer.tokenStream("myfield", new StringReader("some text goes here"));
Token t = ts.next(new Token());
while (t != null) {
System.out.println("Token: " + String.valueOf(t.termBuffer()));
t = ts.next(t);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment