Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DB5E2200C30 for ; Tue, 21 Feb 2017 01:12:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D9FA4160B78; Tue, 21 Feb 2017 00:12:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0F9DD160B73 for ; Tue, 21 Feb 2017 01:12:47 +0100 (CET) Received: (qmail 50717 invoked by uid 500); 21 Feb 2017 00:12:46 -0000 Mailing-List: contact user-help@lucy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@lucy.apache.org Delivered-To: mailing list user@lucy.apache.org Received: (qmail 50694 invoked by uid 99); 21 Feb 2017 00:12:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Feb 2017 00:12:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B9A1AC0AD8 for ; Tue, 21 Feb 2017 00:12:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.679 X-Spam-Level: * X-Spam-Status: No, score=1.679 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id tuPWlEM26fzm for ; Tue, 21 Feb 2017 00:12:44 +0000 (UTC) Received: from mail-qk0-f174.google.com (mail-qk0-f174.google.com [209.85.220.174]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 870DD5F4A8 for ; Tue, 21 Feb 2017 00:12:43 +0000 (UTC) Received: by mail-qk0-f174.google.com with SMTP id u188so33458482qkc.2 for ; Mon, 20 Feb 2017 16:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=iRefsRo6e+dfRAiadTfNtFfeF9JS57TEHpPGwduCiuk=; b=j5VcV3NZos/O787BobaT11iIwtvx8tVnixvJ79VpPFi8nlEdfapFx8qR0g/E/ditAF AWDHycWGwXi3RwOkYAipER2DmQGBc9KkLhmYQGN/CiRaepAsFjcgIyMnX6KInxcFqM/N 2RCLLsAfSL7SWVlFkAOaL/wcqeX8z5i1zX1zPSgo5pYshvXOlRPtQbpzeC7+A8HlVe4X 9AG+nkBJK/tLag4YRZ7JklNF8p5Q5vTh8iv3wb7pkSb//9hNMODpn+5TuzHug/38dOBY 4YkO9k9MLsi2f4KUIEU4p68XkeRqrYAEHbKKoRYQq1N4xI+lDe2bud2yocZaDjJNAElj BUWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=iRefsRo6e+dfRAiadTfNtFfeF9JS57TEHpPGwduCiuk=; b=smSswWGEKFlW5QeDdAiAWY/jsSn+yxi1KHwpXSaoxMclTzIaER0SQA5trxkrviX2dC RN0KIiw5earm0B8SxeijQ7/ikEcX99QyG1SaSSzfIHt/R+jAymCSpk1ADp+SqLLpUrJV BQzYuzkZVgS8IQxMZv/HYY7wlag1i3kH+vJNCSQpF0KBX4wF9whC08VGQNTMGKLlxHFb tUeOc1K4d8mBvyYO077Kxo8ZNOUAvb362d0ZLgetEUjKOp5NCy3mqKYOA+3dH5ubDcJo gdTEH0G2X+xHFlnx4Oh8l0xleBFJLr1/m5RV0BqHJsQes6nvJtRAla3u3KNA3qjE2zj4 PyRw== X-Gm-Message-State: AMke39mFzi6Bh63WMqWkYnixQI7x2UTF+Y/Zn/n1sC8O2hJ4KcBYOhhiktA2cXC9un7w8DxNjWmGUEeiFB2VGw== X-Received: by 10.55.183.133 with SMTP id h127mr24654279qkf.121.1487635957734; Mon, 20 Feb 2017 16:12:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.104.205 with HTTP; Mon, 20 Feb 2017 16:12:37 -0800 (PST) In-Reply-To: <5bfe0128-67d4-fd14-0d15-64529fc7ccea@aevum.de> References: <5bfe0128-67d4-fd14-0d15-64529fc7ccea@aevum.de> From: Hao Wu Date: Mon, 20 Feb 2017 16:12:37 -0800 Message-ID: To: user@lucy.apache.org Content-Type: multipart/alternative; boundary=94eb2c060056d0e4470548ff3c1f Subject: Re: [lucy-user] Chinese support? archived-at: Tue, 21 Feb 2017 00:12:49 -0000 --94eb2c060056d0e4470548ff3c1f Content-Type: text/plain; charset=UTF-8 Still have problem when I try to update the index using the custom analyzer. If I comment out the truncate => 1 rerun I got the following errror. 'body' assigned conflicting FieldType LUCY_Schema_Spec_Field_IMP at cfcore/Lucy/Plan/Schema.c line 124 at /home/hwu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/Lucy.pm line 118. Lucy::Index::Indexer::new('Lucy::Index::Indexer', 'index', '/home/hwu/data/lucy/mitbbs.index', 'schema', 'Lucy::Plan::Schema=SCALAR(0x211c758)', 'create', 1) called at mitbbs_index.pl line 26 *** Error in `perl': corrupted double-linked list: 0x00000000021113a0 *** If I switch the analyzer to Lucy::Analysis::StandardTokenize. works fine. a new seg_2 is created. my $tokenizer = Lucy::Analysis::StandardTokenizer->new; my $raw_type = Lucy::Plan::FullTextType->new( analyzer => $tokenizer, ); So I guess I must miss something in the custom Chinese Analyzer. ------------------my script-------------------- #!/usr/local/bin/perl #TODO: update doc, instead create everytime use DBI; use File::Spec::Functions qw( catfile ); use Lucy::Plan::Schema; use Lucy::Plan::FullTextType; use Lucy::Index::Indexer; use ChineseAnalyzer; my $path_to_index = '/home/hwu/data/lucy/mitbbs.index'; # Create Schema. my $schema = Lucy::Plan::Schema->new; my $chinese = ChineseAnalyzer->new(); my $raw_type = Lucy::Plan::FullTextType->new( analyzer => $chinese, ); $schema->spec_field( name => 'body', type => $raw_type); # Create an Indexer object. my $indexer = Lucy::Index::Indexer->new( index => $path_to_index, schema => $schema, create => 1, truncate => 1, ); my $driver = "SQLite"; my $database = "/home/hwu/data/mitbbs.db"; my $dsn = "DBI:$driver:dbname=$database"; my $dbh = DBI->connect($dsn,{ RaiseError => 1 }) or die $DBI::errstr; my $stmt = qq(SELECT id, text from post where id >= 100 and id < 200;); #my $stmt = qq(SELECT id, text from post where id < 100;); my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; while(my @row = $sth->fetchrow_array()) { print "id = ". $row[0] . "\n"; print $row[1]; my $doc = { body => $row[1] }; $indexer->add_doc($doc); } $indexer->commit; print "Finished.\n"; On Sat, Feb 18, 2017 at 6:46 AM, Nick Wellnhofer wrote: > On 18/02/2017 07:22, Hao Wu wrote: > >> Thanks. Get it work. >> > > Lucy's StandardTokenizer breaks up the text at the word boundaries defined > in Unicode Standard Annex #29. Then we treat every Alphabetic character > that doesn't have a Word_Break property as a single term. These are > characters that match \p{Ideographic}, \p{Script: Hiragana}, or > \p{Line_Break: Complex_Context}. This should work for Chinese but as Peter > mentioned, we don't support n-grams. > > If you're using QueryParser, you're likely to run into problems, though. > QueryParser will turn a sequence of Chinese characters into a PhraseQuery > which is obviously wrong. A quick hack is to insert a space after every > Chinese character before passing a query string to QueryParser: > > $query_string =~ s/\p{Ideographic}/$& /g; > > Nick > > --94eb2c060056d0e4470548ff3c1f--