« Perlモジュール「Net::Akismet」の和訳ドキュメントを追加 | メイン | プロジェクト:コラボ スタートしました。 »

WebService::OkiLab::ExtractPlace

隣のチームの Tsukamoto さんが位置表現特定APIを Perl プログラムで利用するためのモジュールWebService::OkiLab::ExtractPlaceを作って CPAN に登録してくれたのでご紹介します。

使い方は以下の通り。

#!/usr/bin/perl
use WebService::OkiLab::ExtractPlace;
use Data::Dumper;
# must be UTF-8
my $text = '東京から名古屋駅を通過して大阪駅に着きました。';
$text .= '大阪市中央区本町に到着しました。';
my $explace = WebService::OkiLab::ExtractPlace->new;
my $result = $explace->extract($text);
print Dumper($result);
実行結果
debian:~ 1007 % perl extract_place.pl
$VAR1 = {
          'result_select' => [
                               [
                                 {
                                   'lat' => '34.702499',
                                   'text' => '大阪駅',
                                   'weight' => '1',
                                   'type' => 'spot',
                                   'lng' => '135.494982'
                                 },
                                 {
                                   'lat' => '34.686394',
                                   'text' => '大阪',
                                   'weight' => '1',
                                   'type' => 'spot',
                                   'lng' => '135.519994'
                                 },
                                 {
                                   'lat' => '34.683764',
                                   'text' => '大阪市中央区本町',
                                   'weight' => '1',
                                   'type' => 'address',
                                   'lng' => '135.509592'
                                 },
                                 {
                                   'lat' => '34.682015',
                                   'text' => '本町',
                                   'weight' => '1',
                                   'type' => 'spot',
                                   'lng' => '135.499095'
                                 }
                               ]
                             ]
        };

詳細は perldoc を参照してください。

トラックバック

このエントリーのトラックバックURL:
http://www.mailpia.jp/cgi-bin/mt_32/mt-tb.cgi/105

コメントを投稿