lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Karman <pe...@peknet.com>
Subject [lucy-user] Custom Analyzer [was Chinese support?]
Date Thu, 23 Feb 2017 03:52:40 GMT
Marvin, Nick, others with more Lucy-fu than I possess:

The example below is failing. I have created a similar test case to create a PR 
but am having trouble running tests within my local git checkout at the moment.

----------------------------------------------------------
#!/usr/bin/env perl

use strict;
use warnings;
use v5.10;
use Lucy;

package MyAnalyzer {
     use base qw( Lucy::Analysis::Analyzer );
     sub transform { $_[1] }
}

package main;

use Lucy::Plan::Schema;
use Lucy::Plan::FullTextType;
use Lucy::Index::Indexer;

my $path_to_index = shift(@ARGV) or die "usage: $0 path/to/index";

for my $try ( ( 1 .. 3 ) ) {
     my $schema = Lucy::Plan::Schema->new;

     my $my_analyzer = MyAnalyzer->new();

     my $raw_type = Lucy::Plan::FullTextType->new( analyzer => $my_analyzer, );

     $schema->spec_field( name => 'body', type => $raw_type );

     my $indexer = Lucy::Index::Indexer->new(
         index  => $path_to_index,
         schema => $schema,
         create => 1,
     );

     my $doc = { body => 'test' };
     $indexer->add_doc($doc);

     $indexer->commit;

     say "finished $try";
}
--------------------------------------------------------

Example above ^^ based on the gist below.

Hao Wu wrote on 2/20/17 11:40 PM:
> Hi Peter,
>
> Thanks for spending time in the script.
>
> I clean it up a bit, so there is no dependency now.
>
> https://gist.github.com/swuecho/1b960ae17a1f47466be006fd14e3b7ff
>
> still do not work.
>




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

Mime
View raw message