From f9c37e4c8a26fb3c31439b9491939a118a50c77f Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Sun, 7 Apr 2024 20:49:55 -0400 Subject: [PATCH] A bit more on the POC --- lib/Geo/Coder/Free.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Geo/Coder/Free.pm b/lib/Geo/Coder/Free.pm index ce68026e..e388ca41 100644 --- a/lib/Geo/Coder/Free.pm +++ b/lib/Geo/Coder/Free.pm @@ -207,11 +207,19 @@ sub geocode { if($w =~ /^[a-z]{2,}$/i) { my $peek = $iterator->peek(); last if(!defined($peek)); + my $offset; + if(exists($common_words{lc($peek)})) { + $peek = $iterator->peek(2); + last if(!defined($peek)); + $offset = 3; + } else { + $offset = 2; + } my $s; if((length($peek) == 2) && (Locale::US->new()->{code2state}{uc($peek)})) { $s = "$w $peek US"; } else { - my $peekpeek = $iterator->peek(2); + my $peekpeek = $iterator->peek($offset); last if(!defined($peekpeek)); $s = "$w $peek $peekpeek"; }