WebService::OkiLab::ExtractPlace - Perl interface to the OkiLab ExtractPlace web service
This document describes WebService::OkiLab::ExtractPlace version 0.0.2
use WebService::OkiLab::ExtractPlace; use Data::Dumper; my $text = '東京から名古屋駅を通過して大阪駅に行きました。大阪市中央区本町に到着しました。'; # must be UTF-8 my $explace = WebService::OkiLab::ExtractPlace->new; my $result = $explace->extract($text); print Dumper($result);
or
use WebService::OkiLab::ExtractPlace; use Data::Dumper; my $text = '東京から名古屋駅を通過して大阪駅に行きました。大阪市中央区本町に到着しました。'; # must be UTF-8 print Dumper(WebService::OkiLab::ExtractPlace->new->extract($text));
WebService::OkiLab::ExtractPlace is a simple Perl interface to the okilab.jp ExtractPlace WebService API.
ExtractPlace is experimental service by okilab.jp. For details, see http://okilab.jp/location/2007/11/api_1.html .
Constructor method. It returns WebService::OkiLab::ExtractPlace object.
It is a method for the extraction of the place. The text with UTF-8 encoded that becomes an analytical target is received.
It returns the following hash references.
{ 'result_select' => [ [ { 'lat' => '34.702499', 'lng' => '135.494982', 'text' => '大阪駅', 'type' => 'spot', 'weight' => 1 }, { 'lat' => '34.686394', 'lng' => '135.519994', 'text' => '大阪', 'type' => 'spot', 'weight' => 1 }, ... ] ] };
When failed, it returns undef. Please confirm the content of the error by errstr().
It returns the text of the content of the latest error.
It returns LWP::UserAgent object which WebService::OkiLab::ExtractPlace uses to access web service. This method can be used to do some operations to LWP::UserAgent object such as specification of proxy information, etc.
It returns request url of the web services. Default url is 'http://okilab.jp/project/location/api/v1/extract_place/'. You can specify other url as argment.
It returns recent HTTP::Request object which is send to the WebService.
It returns recent HTTP::Response object which is send to the WebService.
Belows are internal method.
Accessor and mutator method to some params such as 'ua', 'url', 'req', 'res'. When no arguments has passed, it returns existing parameter name. When parameter name has passed, it returns the parameter value. When parameter name and value have passed, it set the value as the parameter value and returns set value.
It only return undef when something failed. In that time
The error text can be acquired in the errstr method at this time. These are as follows.
It occurs when WebService::OkiLab::ExtractPlace can't get LWP::UserAgent object. Maybe LWP::UserAgent is not available, or invalid value has been set with ua method.
It occurs when url of seb service is invalid. Current value is set into '%s'. Maybe invalid value has been set with url method.
It occurs when the text to be analyzed is empty (or blank). Please confirm the argument given to extract().
It occurs when it fails to receive response from the Web service. Please confirm the state of the LWP::UserAgent object, HTTP::Request object by ua() and req().
It occurs when response from the Web service does not indicate success. HTTP response code and message is set into '%s'. Please confirm the state of the HTTP::Request object, HTTP::Response object by req() and res().
It occurs when the response content is empty (or blank). Please confirm the state of the HTTP::Request object, HTTP::Response object by req() and res().
It occurs when the response content is not able to parse as JSON data. Please confirm the content of the HTTP::Request object by res().
WebService::OkiLab::ExtractPlace accesses to the Web service via http. When it is necessary to use proxy, you may set environment variable HTTP_PROXY. When proxy needs authentication, the following notations can be used.
HTTP_PROXY=http://user:password@host:port
You can specify proxy settings directory to LWP::UserAgent object instead of using environment variable.
Class::ErrorHandler
LWP::UserAgent
JSON
None reported.
No bugs have been reported.
http://okilab.jp/location/2007/11/api_1.html
Makio Tsukamoto <tsukamoto@gmail.com>
<tsukamoto@gmail.com>
Copyright (c) 2007, Makio Tsukamoto <tsukamoto@gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in ''東京から名古屋駅を通過して大阪駅に行きました。大阪市中央区本町に到着しました。';'. Assuming UTF-8
To install WebService::OkiLab::ExtractPlace, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::OkiLab::ExtractPlace
CPAN shell
perl -MCPAN -e shell install WebService::OkiLab::ExtractPlace
For more information on module installation, please visit the detailed CPAN module installation guide.