27 Oct 2007 19:46:10 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (21 / 5 / 2)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (460.82KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
KinoSearch::Analysis::Token - Unit of text.
my $token = KinoSearch::Analysis::Token->new( text => 'horses', start_offset => 0, end_offset => 6, ); $token->set_text('hors');
Token is the fundamental unit used by KinoSearch's Analyzer subclasses. Each Token has 5 attributes:
text - a UTF-8 string.
start_offset - The start point of the token text, measured in UTF-8 characters from the top of the stored field.
end_offsetlocate the Token within a larger context, even if the Token's text attribute gets modified -- by stemming, for instance. The Token for "beating" in the text "beating a dead horse" begins life with a start_offset of 0 and an end_offset of 7; after stemming, the text is "beat", but the start_offset is still 0 and the end_offset is still 7. This allows "beating" to be highlighted correctly after a search matches "beat".
end_offset The end of the token text, measured in UTF-8 characters from the top of the field.
boost - a per-token weight. Use this when you want to assign more or less importance to a particular token, as you might for emboldened text within an HTML document, for example. (Note: The field this token belongs to must be spec'd to use a posting_type of KinoSearch::Posting::RichPosting.)
pos_inc - POSition INCrement, measured in Tokens. This attribute, which defaults to 1, is a an advanced tool for manipulating phrase matching. Ordinarily, Tokens are assigned consecutive position numbers: 0, 1, and 2 for
"three blind mice". However, if you set the position increment for "blind" to, say, 1000, then the three tokens will end up assigned to positions 0, 1, and 1001 -- and will no longer produce a phrase match for the query
"three blind mice".
my $token = KinoSearch::Analysis::Token->new( text => $text, # required start_offset => 0, # required end_offset => length($text), # required boost => 100.0, # default 1.0 pos_inc => 0, # default 1 );
Constructor. Takes hash-style parameters, corresponding to the token's attributes.
Token provides these set/get methods:
Copyright 2006-2007 Marvin Humphrey
See KinoSearch version 0.20.