lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mário André <mario...@infonet.com.br>
Subject RES: Question about TokenStream lucene 3.0
Date Wed, 30 Dec 2009 17:40:41 GMT
System.out.println(typeAtt.type()); ??? And this typeAtt?

Thanks!

---------------------------------------------------------------------
Mário André
Instituto Federal de Educação, Ciência e Tecnologia de Sergipe - IFS
Mestrando em MCC - Universidade Federal de Alagoas - UFAL
http://www.marioandre.com.br/
Skype: mario-fa
----------------------------------------------------------------------------
----------


-----Mensagem original-----
De: AHMET ARSLAN [mailto:iorixxx@yahoo.com] 
Enviada em: quarta-feira, 30 de dezembro de 2009 15:26
Para: java-user@lucene.apache.org
Assunto: Re: Question about TokenStream lucene 3.0


> Using PorterStemFilter and removing the stopwords, but how
> can I use
> TokenStream in release 3.0 (print the result this method).
> 
> I tried to use:
> 
>     public static void main(String[] args) throws
> IOException,
> ParseException 
>     {
>       StringReader sr = new
> StringReader("The man is very good. He talked
> about many thigs");
>       PorterStemAnalyzer ps = new
> PorterStemAnalyzer();
>       TokenStream tokenstream =
> ps.tokenStream(null, sr);
> 
>       //Tokenizer token = (Tokenizer)
> ps.tokenStream(null, sr);
>       while(tokenstream.incrementToken())
>       {
>           ????????
>       }
>       
>     }
> 
> Thanks.

You can use this method to display:

   public static void displayTokenStream(TokenStream tokenStream) throws
IOException {

        TermAttribute termAtt = (TermAttribute)
tokenStream.getAttribute(TermAttribute.class);
        TypeAttribute typeAtt = (TypeAttribute)
tokenStream.getAttribute(TypeAttribute.class);

        while (tokenStream.incrementToken()) {
            System.out.print(termAtt.term());
            System.out.print(' ');
            System.out.println(typeAtt.type());
        }
    }


      

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message