Hatena-Keyword-0.02
前のエントリのモジュール、とりあえず CPAN に up できる形にしてみました。
- http://bloghackers.net/~naoya/lib/perlmodules/Hatena-Keyword-0.02/
- http://bloghackers.net/~naoya/lib/perlmodules/Hatena-Keyword-0.02.tar.gz
それに合わせていくつか修正も加えてます。
RPC::XML::Client->new
の引数の渡し方が間違ってた。- Jcode は
$keyword->jcode
で取得するように変更した。 - POD 書いた。英語がやばげ。
という感じ。まだ CPAN には up してません。懸念事項が幾つか。
retrieve
というメソッド名。引数に与えたテキストに含まれるキーワードを取得する、というのでこの名前は適切か。- 名前空間。Hatena-API-Auth に合わせて Hatena-API-Keyword にするべきか。これは別に Hatena-Keyword でもいいかなとか思ってるけど。
あたりを決めかねてます。コメント歓迎。
NAME Hatena::Keyword - Extract Hatena Keywords used in your text VERSION Version 0.02 SYNOPSIS use Hatena::Keyword; @keywords = Hatena::Keyword->retrieve("Perl and Ruby and Python."); print $_->score, "?t", $_ for @keywords; $keywords = Hatena::Keyword->retrieve("Hello, Perl!", { score => 20, cname => qw[(hatena web book)], }); print $_->refcount, "?t", $_->jcode->euc for @$keywords; $html = Hatena::Keyword->markup_as_html("Perl and Ruby"); $html = Hatena::Keyword->markup_as_html("Hello, Perl!", { score => 20, cname => qw[(hatena web book)], a_class => 'keyword', a_target => '_blank', }); DESCRIPTION This module allows you to extract Hatena keywords used in your arbitrary text and also allows you to mark up your text as HTML with the keywords. It queries Hatena Keyword Link API internally for retrieving terms. CLASS METHODS retrieve($text, ?%options) Returns an array or an array reference which contains Hatena::Keyword objects extracted from specified text as first argument. Note that character encoding of the text must be utf-8. And also returned words are encoded as utf-8 string. Second argument is a option, which will be passed through to the XML-RPC API. markup_as_html($text, ?%options) Returns a tagged html string with Hatena Keywords like this: <a href="http://d.hatena.ne.jp/keyword/Perl">Perl</a> and <a href="http://d.hatena.ne.jp/keyword/Ruby">Ruby</a> It takes two arguments, same as "retrieve()". INSTANCE METHODS as_string Returns a Hatena::Keyword object to a plain string, an alias for "word()". Hatena::Keyword objects are also converted to plain strings automatically by overloading. This means that objects can be used as plain strings in most Perl constructs. word Returns a plain string of the word. score Returns a score of the word. refcount Returns a reference count of the word, which means used times of the term whole over the Hatena Diary. cname Returns a category name of the word. jcode Returns a Jcode objet which contains the word. AUTHOR Naoya Ito, "<naoya at bloghackers.net>" BUGS Please report any bugs or feature requests to "bug-hatena-keyword at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hatena-Keyword>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT You can find documentation for this module with the perldoc command. perldoc Hatena::Keyword You can also look for information at: * AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Hatena-Keyword> * CPAN Ratings <http://cpanratings.perl.org/d/Hatena-Keyword> * RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hatena-Keyword> * Search CPAN <http://search.cpan.org/dist/Hatena-Keyword> SEE ALSO Hatena Keyword Auto-Link API <http://tinyurl.com/m5dkm> (redirect to d.hatena.ne.jp) Hatena Diary <http://d.hatena.ne.jp/> Hatena <http://www.hatena.ne.jp/> COPYRIGHT & LICENSE Copyright 2006 Naoya Ito, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.