I needed a simple way to test if a list of keywords (tags) had the required words, but one moment later, conditional operators other than AND were required. I didn't find a public module that satisfied my needs. Some of this was discussed in AND and OR on Regular Expressions.
I took my subs and group them in a module, then changed into objects (my first attempt in OOP) and worked nice.
Examples of use:
# Simple query (same as: +xxx -ppp -jjj): my $query = "xxx-(ppp,jjj)"; use Keywords; my $kw = Keywords->new(ignorecase => 1); $kw->prepare($query); # Simple test: print "Match!" if $kw->test($list_of_tags); # @ids has some keys %table: @ok = grep {$kw->test($table{$_}[$col])} @ids; # Same as before: @ok = $kw->grep_keys(map {$_ => $table{$_}[$col]} @ids); # Hash only has keywords lists: @ok = $kw->grep_keys(%tags); # When ids are full keywords: @ok = $kw->grep(@ids);
Now, I want to share my efforts and decided to upload this to CPAN, but I need to define or append to a namespace. I thought on Search::Keywords, but Keywords::Match might be a better one.
Hints for a proper namespace?
Hints for extra features? I'm thinking on set/get parms, reparse, sentences (when tags have more than one word), UTF8 (un)support...
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RFC: A module to evaluate keywords expressions on tag lists.
by ikegami (Patriarch) on Sep 03, 2009 at 18:33 UTC | |
by vitoco (Hermit) on Sep 03, 2009 at 20:20 UTC | |
by ikegami (Patriarch) on Sep 03, 2009 at 20:29 UTC | |
|
Re: RFC: A module to evaluate keywords expressions on tag lists.
by vitoco (Hermit) on Sep 30, 2009 at 13:44 UTC |