Skip to content

Commit

Permalink
Start a proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Apr 7, 2024
1 parent e985efa commit 48ed36a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ if(open(my $admin2, '>>', 'lib/Geo/Coder/Free/MaxMind/databases/admin2.db')) {
# For bin/create_sqlite
my $build_requires = {
'App::csv2sqlite' => 0,
'Array::Iterator' => 0,
'CHI' => 0,
'CHI::Driver::RawMemory' => 0,
'Cwd' => 0,
Expand Down
17 changes: 16 additions & 1 deletion lib/Geo/Coder/Free.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use warnings;

# use lib '.';

use Array::Iterator;
use Config::Auto;
use Geo::Coder::Abbreviations;
use Geo::Coder::Free::MaxMind;
Expand Down Expand Up @@ -198,9 +199,23 @@ sub geocode {
my @rc = $self->{'openaddr'}->geocode(\%params);
if((my $scantext = $params{'scantext'}) && (my $region = $params{'region'})) {
$scantext =~ s/\W+/ /g;
my @a = List::MoreUtils::uniq(split(/\s/, $scantext));
my $iterator = Array::Iterator->new({ __array__ => \@a });
while(my $w = $iterator->get_next()) {
next if(exists($common_words{lc($w)}));
if($w =~ /^[a-z]{2,}$/i) {
my $peek = $iterator->peek();
last if(!defined($peek));
my $peekpeek = $peek->peek();
last if(!defined($peekpeek));
my $s = "$w $peek $peekpeek";
::diag($s);
}
}

foreach my $word(List::MoreUtils::uniq(split(/\s/, $scantext))) {
# FIXME: There are a *lot* of false positives
next if(exists($common_words{lc$word}));
next if(exists($common_words{lc($word)}));
if($word =~ /^[a-z]{2,}$/i) {
my $key = "$word/$region";
my @matches;
Expand Down

0 comments on commit 48ed36a

Please sign in to comment.