# New Ticket Created by  Itsuki Toyota 
# Please include the string:  [perl #129994]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129994 >


I'm creating a Perl 6 bindings for MeCab ( http://taku910.github.io/mecab/ )

See the following codes and documentations(translations).

My repository is:
https://github.com/titsuki/p6-MeCab/tree/for-RT


The following subtest in the t/02-lattice.t in the above repository is hung up.
----
subtest {
    my MeCab::Model $model .= new;
    my @texts = (("私","僕") xx 3).flat;

    my @actual = (@texts.hyper(:batch(1))\
                  .map(
                         {
                             my MeCab::Tagger $tagger = $model.create-tagger;
                             my MeCab::Lattice $lattice = $model.create-lattice;
                             $lattice.sentence($_);
                             $lattice.tostr if $tagger.parse($lattice);
                             $tagger.DESTROY;
                             $lattice.DESTROY;
                         }
                     ).list);

    my Str $r1 = ("私\t名詞,代名詞,一般,*,*,*,私,ワタシ,ワタシ\nEOS\n");
    my Str $r2 = ("僕\t名詞,代名詞,一般,*,*,*,僕,ボク,ボク\nEOS\n");
    my @expected = (($r1, $r2) xx 3).flat;
    is @actual, @expected;
}, "MeCab::Tagger should work in the multithread environment";
---


In the MeCab documentation page(Japanese) 
https://taku910.github.io/mecab/libmecab.html
"C++ サンプルコード" (en: C++ sample code) section says that:
In the multithread environment (MeCab::Tagger, MeCab::Model, MeCab::Lattice)

* Call MeCab::createModel() and create the Model object.

* Call model->createTagger and create the Tagger object. The Tagger objects 
share the same model, even though you create the multiple models under the one 
model per thread constraint.

* Call model->createLattice or MeCab::createLattice() and crate the Lattice 
object. The Lattice objects include all local variables for the morpheme 
analyze. Must keep the constraint that you can create only one object per 
thread.

* model->swap(antoher_model) function replaces the Tagger object models created 
from the invocant model by another_model. This operation is thread-safe.




I think I properly call the MeCab functions from Perl 6(e.g. 
$model.create-tagger, $model.create-lattice) according to the above 
instructions.
So I think something is wrong in the NativeCall.    

Reply via email to