WebService::Yahoo::TermExtractor - Perl wrapper for the Yahoo! Term Extraction WebService
use WebService::Yahoo::TermExtractor; my $yte = WebService::Yahoo::TermExtractor->new( appid => 'your_app_id', context => $source_text); my $terms = $yte->get_terms; # returns an array ref
WebService::Yahoo::TermExtractor provides a simple object-oriented wrapper around the Yahoo! Term Extraction WebService.
The Yahoo! Term Extraction WebService attempts to extract a list of significant words or phrases from the content submitted.
use WebService::Yahoo::TermExtractor; my $source_text = 'A chunk of text, that mentions perl, to extract terms from...'; my $yte = WebService::Yahoo::TermExtractor->new( appid => 'your_app_id', context => $source_text); my $terms = $yte->get_terms; die "An error occured while trying to extract terms..." unless $terms; print "This article is about:\n"; foreach my $term (@$terms) { print "\t$term\n"; }
If you are making multiple calls, each with different source text, and have already initialised a WebService::Yahoo::TermExtractor object you can reuse the object and call get_terms with the text to extract from.
get_terms
my $yte = WebService::Yahoo::TermExtractor->new( appid => 'textextract', context => $source_text); my $terms = $yte->get_terms; ... do stuff and then later ... $terms = $yte->get_terms($new_source_text);
The following example shows input text from the London PM home page:
"We are a group of people dedicated to the encouragement of all things Perl-like in London. This involves helping each other, discussing topics, sharing information and the occasional drink and mention of Buffy the Vampire Slayer."
Which returns the following terms:
buffy the vampire slayer occasional drink encouragement perl london
As an object-oriented module WebService::Yahoo::TermExtractor exports no functions.
This is the constructor for a new WebService::Yahoo::TermExtractor object. The appid is required for you to use the Yahoo webservice and must be requested from them. See "SEE ALSO" for more details.
appid
context is the source text that terms should be extracted from. Both arguments are required.
context
This method sends the request and returns an array reference of any extracted terms. If invoked without an argument the context provided in new is used. If an argument is passed it is assumed to be source text that terms should be extracted from. This was added as a convience for working with multiple pieces of text.
new
get_terms returns an array reference pointing to the list of terms on success and undef on failure.
WebService::Yahoo::TermExtractor requires the following module:
LWP::UserAgent
For information about the Yahoo! Term Extractor service - http://developer.yahoo.com/search/content/V1/termExtraction.html
To sign up for an application key - http://api.search.yahoo.com/webservices/register_application
Copyright (C) 2006 Dean Wilson. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Dean Wilson <dean.wilson@gmail.com>
To install WebService::Yahoo::TermExtractor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Yahoo::TermExtractor
CPAN shell
perl -MCPAN -e shell install WebService::Yahoo::TermExtractor
For more information on module installation, please visit the detailed CPAN module installation guide.