Changeset 13375 for lang/perl/Data-Cloud

Show
Ignore:
Timestamp:
06/07/08 15:54:38 (7 years ago)
Author:
nyarla
Message:

I implemented count method.

Location:
lang/perl/Data-Cloud/trunk
Files:
1 added
1 removed
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Data-Cloud/trunk/lib/Data/Cloud.pm

    r12269 r13375  
    123123} 
    124124 
     125sub count { 
     126    my $self = shift; 
     127    my $word = shift or Carp::croak "Target word is not specified"; 
     128 
     129    $self->filter( word => \$word ); 
     130 
     131    my $count = ( exists $self->data->{$word} ) 
     132              ? $self->data->{$word} 
     133              : 0 ; 
     134 
     135    return $count; 
     136} 
     137 
    1251381; 
    126139__END__ 
     
    128141=head1 NAME 
    129142 
    130 Data::Cloud - Utility for data cloud. 
     143Data::Cloud - Utility for word cloud. 
    131144 
    132145=head1 SYNOPSIS 
     
    138151  $cloud->add( wordA => 5, wordB => -2 wordC => 1 ); 
    139152   
    140   my $resource = $cloud->rating( 5 ); 
     153  my $resource = $cloud->rating( rate => 5 ); 
    141154 
    142155=head1 DESCRIPTION 
     
    225238This method decreased the number of the word. 
    226239 
     240=head2 count 
     241 
     242  my $count = $cloud->count($word); 
     243 
     244This method gets the number of the word. 
     245 
    227246=head2 rating 
    228247 
    229248  my $resource = $cloud->rating( rate => 5 ); 
    230  
    231 =head2 count 
    232  
    233   my $count = $cloud->count($word); 
    234249 
    235250=head2 filter