lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Karman <pe...@peknet.com>
Subject Re: [lucy-user] Custom Analyzer [was Chinese support?]
Date Thu, 23 Feb 2017 16:23:13 GMT
Nick Wellnhofer wrote on 2/23/17 6:49 AM:
> On 23/02/2017 04:52, Peter Karman wrote:
>> package MyAnalyzer {
>>     use base qw( Lucy::Analysis::Analyzer );
>>     sub transform { $_[1] }
>> }
>
> Every Analyzer needs an `equals` method. For simple Analyzers, it can simply
> check whether the class of the other object matches:
>
>     package MyAnalyzer {
>         use base qw( Lucy::Analysis::Analyzer );
>         sub transform { $_[1] }
>         sub equals { $_[1]->isa(__PACKAGE__) }
>     }
>
> If the Analyzer uses (inside-out) member variables, you'll also need dump and
> load methods. Unfortunately, we don't have good documentation for writing custom
> analyzers yet.
>


Thanks for the quick response and accurate diagnosis, Nick. I see you've already 
committed changes to the POD so that will be very helpful in future.

Hao, if you add the `sub equals` method to your ChineseAnalyzer, I think that 
should fix your problem. I have confirmed that locally with my own tests.


-- 
Peter Karman  .  https://peknet.com/  .  https://keybase.io/peterkarman

Mime
View raw message