<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    DANCE WITH JAVA

    開發出高質量的系統

    常用鏈接

    統計

    積分與排名

    好友之家

    最新評論

    比較lucene各種英文分析器Analyzer

    比較常用的幾種英文分析器,他們之間的區別見程序中的注釋。
    SimpleAnalyzer
    StandardAnalyzer
    WhitespaceAnalyzer
    StopAnalyzer
    package analyzer;

    import java.io.Reader;
    import java.io.StringReader;

    import org.apache.lucene.analysis.Analyzer;
    import org.apache.lucene.analysis.SimpleAnalyzer;
    import org.apache.lucene.analysis.StopAnalyzer;
    import org.apache.lucene.analysis.StopFilter;
    import org.apache.lucene.analysis.Token;
    import org.apache.lucene.analysis.Tokenizer;
    import org.apache.lucene.analysis.WhitespaceAnalyzer;
    import org.apache.lucene.analysis.standard.StandardAnalyzer;

    public class TestAnalyzer {
        
    private static String testString1 = "The quick brown fox jumped over the lazy dogs";
        
    private static String testString2 = "xy&z mail is - xyz@sohu.com";
        
    public static void testWhitespace(String testString) throws Exception{
            Analyzer analyzer 
    = new WhitespaceAnalyzer();      
            Reader r 
    = new StringReader(testString);      
            Tokenizer ts 
    = (Tokenizer) analyzer.tokenStream("", r);      
            System.err.println(
    "=====Whitespace analyzer====");
            System.err.println(
    "分析方法:空格分割");
            Token t;      
            
    while ((t = ts.next()) != null{      
               System.out.println(t.termText());      
            }
         
        }

        
    public static void testSimple(String testString) throws Exception{
            Analyzer analyzer 
    = new SimpleAnalyzer();      
            Reader r 
    = new StringReader(testString);      
            Tokenizer ts 
    = (Tokenizer) analyzer.tokenStream("", r);      
            System.err.println(
    "=====Simple analyzer====");
            System.err.println(
    "分析方法:空格及各種符號分割");
            Token t;      
            
    while ((t = ts.next()) != null{      
               System.out.println(t.termText());      
            }
         
        }

        
    public static void testStop(String testString) throws Exception{
            Analyzer analyzer 
    = new StopAnalyzer();      
            Reader r 
    = new StringReader(testString);      
            StopFilter sf 
    = (StopFilter) analyzer.tokenStream("", r);
            System.err.println(
    "=====stop analyzer====");  
            System.err.println(
    "分析方法:空格及各種符號分割,去掉停止詞,停止詞包括 is,are,in,on,the等無實際意義的詞");
            
    //停止詞
            Token t;      
            
    while ((t = sf.next()) != null{      
               System.out.println(t.termText());      
            }
         
        }

        
    public static void testStandard(String testString) throws Exception{
            Analyzer analyzer 
    = new StandardAnalyzer();      
            Reader r 
    = new StringReader(testString);      
            StopFilter sf 
    = (StopFilter) analyzer.tokenStream("", r);
            System.err.println(
    "=====standard analyzer====");
            System.err.println(
    "分析方法:混合分割,包括了去掉停止詞,支持漢語");
            Token t;      
            
    while ((t = sf.next()) != null{      
                System.out.println(t.termText());      
            }
         
        }

        
    public static void main(String[] args) throws Exception{
    //        String testString = testString1;
            String testString = testString2;
            System.out.println(testString);
            testWhitespace(testString);
            testSimple(testString);
            testStop(testString);
            testStandard(testString);
        }


    }

    posted on 2007-06-20 16:46 dreamstone 閱讀(4028) 評論(2)  編輯  收藏 所屬分類: 搜索引擎lucence

    評論

    # re: 比較lucene各種英文分析器Analyzer 2007-06-20 18:02 good

    不錯  回復  更多評論   

    # re: 比較lucene各種英文分析器Analyzer 2008-06-21 18:03 美女

    Me with the floorshow
    Kickin' with your torso
    Boys getting high
    And the girls even more so
    Wave your hands if your not with the man
    Can I kick it?
    (Yes you can)
    I got
    (Funk)
    You got
    (Soul)
    We got everybody
    I've got the gift
    Gonna stick it in the goal
    It's time to move your body
    Babylon back in business
    Can I get a witness?
    Every girl, every man
    Houston, can you hear me?
    Ground control, can you feel me?
    Need permission to land
    I don't wanna rock, DJ
    But your making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keepin' me up all night

    Singin' in the classes
    Music for your masses
    Give no head
    No backstage passes
    Have a proper giggle
    I'll be quite polite
    But when I rock the mic
    I rock the mic
    (Right)
    You got no love, then you're with the wrong man
    It's time to move your body
    If you can't get a girl
    But your best friend can
    It's time to move your body
    I don't wanna be sleazy
    Baby just tease me
    Got no family planned
    Houston, can you hear me?
    Need permission to land
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keeping me up all night
    I don't wanna rock, DJ
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos your keeping me up all night
    Pimpin' aint easy
    Most of them fleece me
    Every night
    Pimpin' ain't easy
    But if you're sellin' it
    It's alright
    Come on
    I don't wanna rock, DJ
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keeping me up all night
    I don't wanna rock, DJ
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keeping me up all night
    I don't wanna rock, DJ
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keeping me up all night
    I don't wanna rock, DJ
    But you're making me feel so nice
    When's it gonna stop, DJ?
    Cos you're keeping me up all night   回復  更多評論   

    主站蜘蛛池模板: 亚洲国产无套无码av电影| a级毛片免费高清视频| 亚洲成AV人片在线观看ww| 在线观看免费为成年视频| 久久免费观看国产精品| 特级毛片全部免费播放| 亚洲va精品中文字幕| 国产精品亚洲片在线观看不卡 | 亚洲国产精品一区二区第四页| 久草视频在线免费| 无码精品国产一区二区三区免费| 国产精品九九久久免费视频 | 久九九精品免费视频| 午夜免费福利小电影| 中文在线免费不卡视频| 日本特黄特色AAA大片免费| 亚洲av成人一区二区三区在线播放| 91亚洲国产成人久久精品| 久久久久亚洲AV片无码下载蜜桃 | 成在人线av无码免费高潮水| 男男gay做爽爽的视频免费| 亚洲国产美女精品久久久| 亚洲乱码中文字幕小综合| 精品亚洲麻豆1区2区3区| 666精品国产精品亚洲| 久久精品亚洲精品国产色婷| 国产l精品国产亚洲区在线观看| 国产亚洲AV夜间福利香蕉149| 亚洲视频精品在线观看| 亚洲成AV人片在线播放无码| 久久精品国产亚洲网站| 亚洲精品亚洲人成在线观看| 亚洲精品无码高潮喷水在线| 亚洲精品无码午夜福利中文字幕 | 一级毛片免费在线| 国产va免费精品| 拍拍拍无挡视频免费观看1000| 你是我的城池营垒免费观看完整版| 在线观看片免费人成视频播放| 一个人免费视频观看在线www| 无码人妻久久一区二区三区免费 |