blog/content/post/2009/06/27/2009-06-27-00001182.md

9.2 KiB

title author date wordtwit_post_info categories
日本語の中から住所を抽出 kazu634 2009-06-27
O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4669;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}
Perl

Geography::AddressExtract::Japanを使って住所抽出 : cotalog」で紹介されているGeography::AddressExtract::Japanをインストールしてみました。

基本的には下記のログの通りで大丈夫です。ただし事前にModule::installをCPANからインストールする必要があります。

~/working/tmp_perl/lib on simoom634 [579] $: svn checkout http://svn.coderepos.org/share/lang/perl/Geography-AddressExtract-Japan
A    Geography-AddressExtract-Japan/trunk
A    Geography-AddressExtract-Japan/trunk/MANIFEST
A    Geography-AddressExtract-Japan/trunk/META.yml
A    Geography-AddressExtract-Japan/trunk/lib
A    Geography-AddressExtract-Japan/trunk/lib/Geography
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Address.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Filter
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Regexp
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Regexp/City.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Regexp/Number.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Regexp/Aza.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Regexp/Dupe.pm
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Map
A    Geography-AddressExtract-Japan/trunk/lib/Geography/AddressExtract/Japan/Map/City.pm
A    Geography-AddressExtract-Japan/trunk/Makefile.PL
A    Geography-AddressExtract-Japan/trunk/bin
A    Geography-AddressExtract-Japan/trunk/bin/make_maps.pl
A    Geography-AddressExtract-Japan/trunk/test.pl
A    Geography-AddressExtract-Japan/branches
A    Geography-AddressExtract-Japan/tags
U   Geography-AddressExtract-Japan
Checked out revision 34168.
~/working/tmp_perl/lib on simoom634 [580] $: cd Geography-AddressExtract-Japan/
~/working/tmp_perl/lib/Geography-AddressExtract-Japan on simoom634 [581] $: ls
branches/ tags/     trunk/
~/working/tmp_perl/lib/Geography-AddressExtract-Japan on simoom634 [582] $: cd trunk
~/working/tmp_perl/lib/Geography-AddressExtract-Japan/trunk on simoom634 [583] $: ls
MANIFEST     META.yml     Makefile.PL  bin/         lib/         test.pl
~/working/tmp_perl/lib/Geography-AddressExtract-Japan/trunk on simoom634 [584] $: perl Makefile.PL
include /Users/simoom634/working/tmp_perl/lib/Geography-AddressExtract-Japan/trunk/inc/Module/Install.pm
include inc/Module/Install/Metadata.pm
include inc/Module/Install/Base.pm
Cannot determine perl version info from lib/Geography/AddressExtract/Japan.pm
Cannot determine license info from lib/Geography/AddressExtract/Japan.pm
include inc/Module/Install/Include.pm
include inc/Test/More.pm
include inc/Module/Install/AutoInstall.pm
include inc/Module/AutoInstall.pm
*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies...
[Core Features]
- Test::More ...loaded. (.88 >= .42)
*** Module::AutoInstall configuration finished.
include inc/Module/Install/Makefile.pm
include inc/Module/Install/WriteAll.pm
include inc/Module/Install/Win32.pm
include inc/Module/Install/Can.pm
include inc/Module/Install/Fetch.pm
Checking if your kit is complete...
Warning: the following files are missing in your kit:
lib/Geography/AddressExtract/Japan/Normalize.pm
Please inform the author.
Writing Makefile for Geography::AddressExtract::Japan
Writing META.yml
No license specified, setting license = 'unknown'
~/working/tmp_perl/lib/Geography-AddressExtract-Japan/trunk on simoom634 [585] $: sudo Make install
sudo: Make: command not found
~/working/tmp_perl/lib/Geography-AddressExtract-Japan/trunk on simoom634 [586] $: sudo make install
cp lib/Geography/AddressExtract/Japan/Address.pm blib/lib/Geography/AddressExtract/Japan/Address.pm
cp lib/Geography/AddressExtract/Japan/Map/City.pm blib/lib/Geography/AddressExtract/Japan/Map/City.pm
cp lib/Geography/AddressExtract/Japan.pm blib/lib/Geography/AddressExtract/Japan.pm
cp lib/Geography/AddressExtract/Japan/Regexp/Number.pm blib/lib/Geography/AddressExtract/Japan/Regexp/Number.pm
cp lib/Geography/AddressExtract/Japan/Regexp/Dupe.pm blib/lib/Geography/AddressExtract/Japan/Regexp/Dupe.pm
cp lib/Geography/AddressExtract/Japan/Regexp/City.pm blib/lib/Geography/AddressExtract/Japan/Regexp/City.pm
cp lib/Geography/AddressExtract/Japan/Regexp/Aza.pm blib/lib/Geography/AddressExtract/Japan/Regexp/Aza.pm
Manifying blib/man3/Geography::AddressExtract::Japan::Map::City.3pm
Manifying blib/man3/Geography::AddressExtract::Japan::Regexp::Dupe.3pm
Manifying blib/man3/Geography::AddressExtract::Japan::Regexp::City.3pm
Appending installation info to /opt/local/lib/perl5/5.8.9/darwin-2level/perllocal.pod

サンプル

#!/usr/local/bin/perl
# === Libraries ===
use strict;
use warnings;
use Data::Dumper;
# === Main part ===
use strict;
use Geography::AddressExtract::Japan;
use encoding "utf8", STDOUT => "utf8";
my $addr = "千葉県市川市八幡2-6-15川長ビル地下1階";
my $t = Geography::AddressExtract::Japan->extract($addr);
print map { $_->{"city"} . $_->{"aza"} . $_->{"number"} . "
"; }@{$t};

実行例

~/working/tmp_perl/projects/scrape/starbucks on simoom634 [591] $: perl address.pl
千葉県市川市八幡2-6-15