Suggest::PrePop - suggestions based on prefix and popularity
use Suggest::PrePop; my $suggestor = Suggest::Prepop->new; $suggestor->add("item - complete", 10); $suggestor->ask("item"); ["item - complete"];
Suggest::PrePop is a suggestion engine which uses a string prefix and the popularity of items to make suggestions. This is pattern is most often used for suggestions of partially typed items (e.g. web search forms.)
Constructor. The following attributes (with defaults) may be set:
- cache_namespace ('SUGGEST-PREPOP') - Cache::RedisDB namespace to use for our accounting
cache_namespace
Cache::RedisDB
- min_activity (5) - The minimum number of times an item must have been seen to be suggested
min_activity
- entries_limit (32768) - The count of most popular entries to maintain in a purge event
entries_limit
- top_count (5) - The default number of entries to return from 'ask'
top_count
Return an array reference with all currently known scopes. Lazily computed on first call. Scopes are case-insensitive.
Add $item to the scope indices, or increment its current popularity. Any $count is taken as the number of times it was seen; defaults to 1. ASCII character 0x02 (STX) is reserved for internal use.
$item
$count
Drop all of the items which match the supplied prefiex from the index.
Suggest the $count most popular items n the given scopes matching the supplied $prefix. Defaults to 5.
$prefix
Prune all but the $count most popular items from the given scopes. Defaults to the instance entries_limit.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Suggest::PrePop, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Suggest::PrePop
CPAN shell
perl -MCPAN -e shell install Suggest::PrePop
For more information on module installation, please visit the detailed CPAN module installation guide.