⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analyzerdemo.java

📁 LuceneInAction配套源码,LuceneInAction是对lucene api的详细讲解及具体应用.此源码即应用例子
💻 JAVA
字号:
package lia.analysis;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.StopAnalyzer;import org.apache.lucene.analysis.SimpleAnalyzer;import org.apache.lucene.analysis.WhitespaceAnalyzer;import org.apache.lucene.analysis.standard.StandardAnalyzer;import java.io.IOException;/** * Adapted from code which first appeared in a java.net article * written by Erik */public class AnalyzerDemo {  private static final String[] examples = {    "The quick brown fox jumped over the lazy dogs",    "XY&Z Corporation - xyz@example.com"  };  private static final Analyzer[] analyzers = new Analyzer[]{    new WhitespaceAnalyzer(),    new SimpleAnalyzer(),    new StopAnalyzer(),    new StandardAnalyzer()  };  public static void main(String[] args) throws IOException {    // Use the embedded example strings, unless    // command line arguments are specified, then use those.    String[] strings = examples;    if (args.length > 0) {      strings = args;    }    for (int i = 0; i < strings.length; i++) {      analyze(strings[i]);    }  }  private static void analyze(String text) throws IOException {    System.out.println("Analyzing \"" + text + "\"");    for (int i = 0; i < analyzers.length; i++) {      Analyzer analyzer = analyzers[i];      String name = analyzer.getClass().getName();      name = name.substring(name.lastIndexOf(".") + 1);      System.out.println("  " + name + ":");      System.out.print("    ");      AnalyzerUtils.displayTokens(analyzer, text);      System.out.println("\n");    }  } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -