NAME
Geo::Parser::Text - Perl extension for parsing and geocoding locations from free form text. (See Geocode.xyz for coverage details)
VERSION
Version 0.01
SYNOPSIS
use Geo::Parser::Text;
# initialize with your host my $g = Geo::Parser::Text->new([geo_host]);
# Scan text for locations... $g->scantext($text);
if ($g->geocode) { my $hashref = $g->geodata; }
# Example...
use Geo::Parser::Text;
my $g = Geo::Parser::Text->new('http://geocode.xyz');
$g->scantext('The most important museums of Amsterdam are located on the Museumplein, located at the southwestern side of the Rijksmuseum.'); if ($g->geocode) { my $ref = $g->geocode; my @matches = @{$ref->{match}}; my $number_of_matches = 0; foreach (@matches) { my $match = $_; $number_of_matches++; print "Match: $number_of_matches\n"; foreach (keys %$match) { print "\t" . $_ . " -> " . $match->{$_} . "\n"; } } }
Output: Match: 1 longt -> 4.89546848846317 location -> Amsterdam, NL confidence -> 0.7 latt -> 52.35968449881906 Match: 2 longt -> 4.8798549000 location -> MUSEUMPLEIN, AMSTERDAM, NL confidence -> 0.4 latt -> 52.3579099000
DESCRIPTION
This module provides a Perl frontend for the geocode.xyz API. It allows the programmer to extract locations containing street addresses, street intersections and city names along with their geocoded latitude,longitude from bodies of text such as microblogs or wikipedia entries. (It should work with any type of text, but dumping html text or paragraphs containing over 200 words, will slow down the response considerably. If you need faster parsing grab the geocode.xyz server image on the AWS, and run it on a faster server (it is currenly running on a micro instance and is shared as a free public API without any throttling or rate limiting in place.) If you run your own instance, make sure to pass the instance ip address or domain name at invocation eg, Geo::Parser::Text->new($server). For explanation on the API responses see http://geocode.xyz/?premium_api=1
METHODS
new ( host => 'geocode.xyz');
- geocode()
-
Send the text to geocode.xyz and return the hash reference with the response. You are required to set the scantext method before calling geocode().
EXPORT
None by default.
REQUIREMENTS
XML::Simple, LWP::UserAgent, HTTP::Request, URI
AUTHOR
Ervin Ruci, <eruci at geocoder.ca>
BUGS
Please report any bugs or feature requests to bug-geo-parser-text at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-Parser-Text. 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 Geo::Parser::Text
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2016 Ervin Ruci.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SEE ALSO
Geo::Coder::Canada Geo::Parse::OSM Text::NLP
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 171:
'=item' outside of any '=over'
- Around line 179:
You forgot a '=back' before '=head1'