GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Hatena::Keyword(3) User Contributed Perl Documentation Hatena::Keyword(3)

Hatena::Keyword - Extract Hatena Keywords in a string

Version 0.03

    use Hatena::Keyword;

    @keywords = Hatena::Keyword->extract("Perl and Ruby and Python.");
    print $_->score, "\t", $_ for @keywords;

    $keywords = Hatena::Keyword->extract("Hello, Perl!", {
        score => 20,
        cname => [qw(hatena web book)],
    });
    print $_->refcount, "\t", $_->jcode->euc for @$keywords;

    my $cache = Cache::File->new(
        cache_root      => '/path/to/cache',
        default_expires => '3600 sec',
    );
    $keywords = Hatena::Keyword->extract("Hello, Hatena!",  {
        cache => $cache,
    });

    $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',
    });

This module allows you to extract Hatena keywords used in an arbitrary text and also allows you to mark up a text as HTML with the keywords.

A Hatena keyword is an element in a suite of web sites *.hatena.ne.jp having blogs and social bookmarks among others. Please refer to http://d.hatena.ne.jp/keyword/ (in Japanese) for details.

In Hatena Diary, a blog hosting service, a Hatena keyword found in a posting is linked to the keyword¡Çs page automatically. You can implement the same kind of feature outside Hatena using this module.

It queries Hatena Keyword Link API internally for retrieving terms.

Returns an array or an array reference which contains Hatena::Keyword objects extracted from specified text as first argument.

This method works correctly for Japanese characters but their encoding must be utf-8. And also returned words are encoded as utf-8 string.

Second argument is a option. Almost all key and values will be passed through to the XML-RPC API, excluding cache option.

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 "extract()".

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.

Returns a plain string of the word.

Returns a score of the word.

Returns a reference count of the word, which means used times of the term whole over the Hatena Diary.

Returns a category name of the word.

Returns a Jcode objet which contains the word.

Responses returned by Web API(XML-RPC) can be cached locally. "extract" method and "markup_as_html" accept a reference to a "Cache" object as cache option. This means that you can pick out one of Cache's companions like "Cache::Memory", "Cache::File", etc. In fact, any other type of cache implementation will do as well, see the requirements below.

    use Cache::File;
    my $cache = Cache::File->new(
        cache_root        => '/tmp/mycache',
        default_expires   => '30 min',
    );

    my $keywords = Hatena::Keyword->extract(
        "Perl and Ruby",
        { cache => $cache },
    );

"Hatena::Keyword" uses positive caching only, errors won't be cached. Erroneous requests will be sent to API server every time.

Caching isn't limited to the "Cache" class. Any cache object which adheres to the following interface can be used:

    # Set a cache value
    $cache->set($key, $value);

    # Return a cached value, 'undef' if it doesn't exist
    $cache->get($key);

Hideyo Imazu <http://d.hatena.ne.jp/himazublog/> helped me writing the English documents.

Hideyo and kosaki <http://mkosaki.blog46.fc2.com/> and tsupo <http://watcher.moe-nifty.com/> helped my decision to change the name of the method.

Kazuhiro Osawa <http://yappo.jp/> and Yuichi Tateno <http://d.hatena.ne.jp/secondlife/> gave me an inspiration for caching implementation.

Naoya Ito, "<naoya at bloghackers.net>"

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.

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>

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 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.

Hey! The above document had some coding errors, which are explained below:
Around line 157:
Non-ASCII character seen before =encoding in 'keyword¡Çs'. Assuming CP1252
2008-02-21 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.