lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikhail Khludnev <mkhlud...@griddynamics.com>
Subject Re: any general way of getting which attributes token stream has?
Date Tue, 20 Mar 2012 07:15:43 GMT
Hello Koji,

Can't it be done via tokenStrem.reflectWith(AttributeReflector) with
reflector which puts all attrs properties into Token via reflection or into
AttributeSource?
WDYT?

2012/3/20 Koji Sekiguchi <koji@r.email.ne.jp>

> Is there any general way of getting/looking what attributes a token stream
> has?
>
> I want to use spell checker with a query analyzer, which the analyzer
> generates
> ReadingAttribute for each tokens, and I want to use the ReadingAttributes
> for
> spell checking. I think I can have my own SpellingQueryConverter extension
> to
> override analyze method, but I saw the TODO comment in
> SpellingQueryConverter:
>
>  protected void analyze(Collection<Token> result, Reader text, int offset)
> throws IOException {
>    TokenStream stream = analyzer.reusableTokenStream("", text);
>    // TODO: support custom attributes
>    CharTermAttribute termAtt =
> stream.addAttribute(CharTermAttribute.class);
>    FlagsAttribute flagsAtt = stream.addAttribute(FlagsAttribute.class);
>    TypeAttribute typeAtt = stream.addAttribute(TypeAttribute.class);
>    PayloadAttribute payloadAtt =
> stream.addAttribute(PayloadAttribute.class);
>    PositionIncrementAttribute posIncAtt =
> stream.addAttribute(PositionIncrementAttribute.class);
>    OffsetAttribute offsetAtt = stream.addAttribute(OffsetAttribute.class);
>       :
>
> If we can have a general way of getting such information, I think it would
> be helpful
> not only for spell checking. (For example, SynonymFilter can add
> PartOfSpeechAttribute
> if the original token has.)
>
> koji
> --
> Query Log Visualizer for Apache Solr
> http://soleami.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>


-- 
Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics

<http://www.griddynamics.com>
 <mkhludnev@griddynamics.com>

Mime
View raw message