Marvin Humphrey > KinoSearch-0.30_04 > KinoSearch::Analysis::Tokenizer

Download:
KinoSearch-0.30_04.tar.gz

Annotate this POD

CPAN RT

Open  7
View Bugs
Report a bug
Source   Latest Release: KinoSearch-0.30_07

NAME ^

KinoSearch::Analysis::Tokenizer - Split a string into tokens.

SYNOPSIS ^

    my $whitespace_tokenizer
        = KinoSearch::Analysis::Tokenizer->new( pattern => '\S+' );

    # or...
    my $word_char_tokenizer
        = KinoSearch::Analysis::Tokenizer->new( pattern => '\w+' );

    # or...
    my $apostrophising_tokenizer = KinoSearch::Analysis::Tokenizer->new;

    # Then... once you have a tokenizer, put it into a PolyAnalyzer:
    my $polyanalyzer = KinoSearch::Analysis::PolyAnalyzer->new(
        analyzers => [ $case_folder, $word_char_tokenizer, $stemmer ], );

DESCRIPTION ^

Generically, "tokenizing" is a process of breaking up a string into an array of "tokens". For instance, the string "three blind mice" might be tokenized into "three", "blind", "mice".

KinoSearch::Analysis::Tokenizer decides where it should break up the text based on a regular expression compiled from a supplied pattern matching one token. If our source string is...

    "Eats, Shoots and Leaves."

... then a "whitespace tokenizer" with a pattern of \S+ produces...

    Eats, 
    Shoots 
    and 
    Leaves.

... while a "word character tokenizer" with a pattern of \w+ produces...

    Eats 
    Shoots 
    and 
    Leaves

... the difference being that the word character tokenizer skips over punctuation as well as whitespace when determining token boundaries.

CONSTRUCTORS ^

new( [labeled params] )

    my $word_char_tokenizer = KinoSearch::Analysis::Tokenizer->new(
        pattern => '\w+',    # required
    );

INHERITANCE ^

KinoSearch::Analysis::Tokenizer isa KinoSearch::Analysis::Analyzer isa KinoSearch::Obj.

COPYRIGHT ^

Copyright 2005-2009 Marvin Humphrey

LICENSE, DISCLAIMER, BUGS, etc. ^

See KinoSearch version 0.30.