--- trunk/Estraier.pm 2006/01/04 22:24:57 15 +++ trunk/Estraier.pm 2006/01/04 22:43:24 16 @@ -306,24 +306,11 @@ package Search::Estraier::Condition; +use Carp qw/confess croak/; + use Search::Estraier; our @ISA = qw/Search::Estraier/; -my $options = { - # check N-gram keys skipping by three - SURE => 1 << 0, - # check N-gram keys skipping by two - USUAL => 1 << 1, - # without TF-IDF tuning - FAST => 1 << 2, - # with the simplified phrase - AGITO => 1 << 3, - # check every N-gram key - NOIDF => 1 << 4, - # check N-gram keys skipping by one - SIMPLE => 1 << 10, -}; - =head1 Search::Estraier::Condition =head2 new @@ -340,6 +327,80 @@ $self ? return $self : return undef; } +=head2 set_phrase + + $cond->set_phrase('search phrase'); + +=cut + +sub set_phrase { + my $self = shift; + $self->{phrase} = $self->_s( shift ); +} + +=head2 add_attr + + $cond->add_attr('@URI STRINC /~dpavlin/'); + +=cut + +sub add_attr { + my $self = shift; + my $attr = shift || return; + push @{ $self->{attrs} }, $self->_s( $attr ); +} + +=head2 set_order + + $cond->set_order('@mdate NUMD'); + +=cut + +sub set_order { + my $self = shift; + $self->{order} = shift; +} + +=head2 set_max + + $cond->set_max(42); + +=cut + +sub set_max { + my $self = shift; + my $max = shift; + croak "set_max needs number" unless ($max =~ m/^\d+$/); + $self->{max} = $max; +} + +=head2 set_options + + $cond->set_options( SURE => 1 ); + +=cut + +my $options = { + # check N-gram keys skipping by three + SURE => 1 << 0, + # check N-gram keys skipping by two + USUAL => 1 << 1, + # without TF-IDF tuning + FAST => 1 << 2, + # with the simplified phrase + AGITO => 1 << 3, + # check every N-gram key + NOIDF => 1 << 4, + # check N-gram keys skipping by one + SIMPLE => 1 << 10, +}; + +sub set_options { + my $self = shift; + my $option = shift; + confess "unknown option" unless ($options->{$option}); + $self->{options} ||= $options->{$option}; +} package Search::Estraier::Master;