NAME

Data::Cloud - Utility for word cloud.

SYNOPSIS

use Data::Cloud;

my $cloud = Data::Cloud->new;
$cloud->set( wordA => 5, wordB => 3, wordC => 7 );
$cloud->add( wordA => 5, wordB => -2 wordC => 1 );

my $resource = $cloud->rating( rate => 5 );

DESCRIPTION

Data::Cloud is a utility for data cloud( tag cloud, word cloud, ...etc ).

This module does a count of a word and a rate separation.

METHODS

new

my $cloud = Data::Cloud->new( %options );

This method is constructor of Data::Cloud.

The following option can be specified as arguments:

'case_sensitive'

This option designates whether Data::Cloud distinguishes between uppercase and lowercase letters.

If this option is true, Data::Cloud distinguishes between uppercase and lowercase letters. And if this option is false, Data::Cloud does not distinguish.

This option is false by default.

'allow_negative_number'

This option designates whether Data::Cloud permits the negative number.

If this option is true, Data::Cloud permits the negative number. And if this option is false, Data::Cloud does not permits.

This option is false by default.

set

$cloud->set( wordA => 10, wordB => 5 );

This method sets the number of the word.

When the number exists already, the old number is overwritten by the new number.

add

$cloud->add( wordA => 3, wordB => -2 );

This method adds the number of the word.

remove

$cloud->remove( $word );
my $count = $cloud->remove( $word );

This method removes the number of word.

Return value is the number of the removed word.

clear

$cloud->clear;
my $removed = $cloud->clear;

This method removes all data.

A return value is hash reference including a word and the number. The form of this return value is same as $cloud->data.

Please see "data" for more information.

increment

$cloud->increment($word);

This method increases the number of the word.

decrement

$cloud->decrement($word);

This method decreased the number of the word.

count

my $count = $cloud->count($word);

This method gets the number of the word.

rating

my $resource = $cloud->rating( rate => 5 );

This method assigns the rate to a word.

The rate is specified as argument 'rate'. Argument 'rate' has to be an integer of more than zero.

A return value is the following feeling:

$resource = [
    { name => 'foo', count => 20, rank => 5 },
    { name => 'bar', count => 15, rank => 4 },
    { name => 'baz', count => 10, rank => 3 },
    ...
];

filter

my ( $word, $number ) = ( word => 5 );

$self->filter( word   => \$word );
$self->filter( number => \$number );

$self->filter( word   => \$word, number => \$number );

This method processes a word and its number with constructor's options.

When Data::Cloud operates a word and the number, this method is called certainly.

data

my $data  = $cloud->data;
my $count = $cloud->data->{$word};

This method is accessor to hash reference keeping data. Data is kept by the form as { word = $count }>.

AUTHOR

Naoki Okamura (Nyarla) <thotep@nayrla.net>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.