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

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

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

    DANCE WITH JAVA

    開發(fā)出高質(zhì)量的系統(tǒng)

    常用鏈接

    統(tǒng)計(jì)

    積分與排名

    好友之家

    最新評論

    比較lucene各種英文分析器Analyzer

    比較常用的幾種英文分析器,他們之間的區(qū)別見程序中的注釋。
    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等無實(shí)際意義的詞");
            
    //停止詞
            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 閱讀(4017) 評論(2)  編輯  收藏 所屬分類: 搜索引擎lucence

    評論

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

    不錯(cuò)  回復(fù)  更多評論   

    # 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   回復(fù)  更多評論   

    主站蜘蛛池模板: 丰满妇女做a级毛片免费观看| 在线成人a毛片免费播放| 久久亚洲精品无码gv| 久久亚洲春色中文字幕久久久| 亚洲国产综合精品中文字幕| 黄页免费的网站勿入免费直接进入| 少妇性饥渴无码A区免费| 粉色视频免费入口| 国产午夜精品理论片免费观看| 亚洲欧美日韩中文无线码| 精品亚洲国产成AV人片传媒| 中文字幕精品亚洲无线码一区应用| 四虎AV永久在线精品免费观看| 99久久99久久精品免费看蜜桃| 久久大香香蕉国产免费网站| 黄视频在线观看免费| 无码人妻一区二区三区免费视频 | 亚洲精品无码永久在线观看男男| 亚洲经典在线中文字幕| 亚洲国产精品成人精品无码区在线 | 在线观看亚洲免费| 国产精品亚洲一区二区三区| 亚洲校园春色另类激情| 亚洲欧洲日产国码二区首页| 久久精品九九亚洲精品| 亚洲一区综合在线播放| 亚洲AV无码欧洲AV无码网站| 精品国产免费观看久久久| 中国在线观看免费国语版| 永久免费观看黄网站| 黄色毛片免费网站| 色五月五月丁香亚洲综合网| 丰满亚洲大尺度无码无码专线| 亚洲乱亚洲乱妇无码| 337P日本欧洲亚洲大胆艺术图| 亚洲精品无码不卡在线播放| jzzijzzij在线观看亚洲熟妇| 色天使色婷婷在线影院亚洲| 黄网站色视频免费看无下截| 一级A毛片免费观看久久精品 | 99爱视频99爱在线观看免费|