RAISE NOTICE '% postDir exact match: %', clock_timestamp(), result.postDirAbbrev;
END IF;
ELSE
- -- postDirection is not equal location, but may be contained in it.
+ -- postDirection is not equal location, but may be contained in it
+ -- It is only considered a postDirection if it is not preceded by a ,
SELECT INTO tempString substring(result.location, '(?i)(^' || name
|| ')' || ws) FROM direction_lookup WHERE
result.location ILIKE '%' || name || '%' AND texticregexeq(result.location, '(?i)(^' || name || ')' || ws)
+ AND NOT texticregexeq(rawInput, '(?i)(,' || ws || '+' || result.location || ')' || ws)
ORDER BY length(name) desc LIMIT 1;
IF debug_flag THEN
- RAISE NOTICE '% location trying to extract postdir: %', clock_timestamp(), result.location;
+ RAISE NOTICE '% location trying to extract postdir: %, tempstring: %, rawInput: %', clock_timestamp(), result.location, tempString, rawInput;
END IF;
IF tempString IS NOT NULL THEN
postDir := tempString;
#1125c|19799 State Rte O, COSBY, MO 64436|19799||O|State Rte|||COSBY|MO|64436|t
#1125d|I- 90, Boston, MA|||90|I-|||Boston|MA||t
#1125e|I-90, Boston, MA|||I-90||||Boston|MA||t
-#1125f|I- 90, Boston, MA|||90|I-|||Boston|MA||t
\ No newline at end of file
+#1125f|I- 90, Boston, MA|||90|I-|||Boston|MA||t
+#1310a|1110 W CAPITOL Ave, WEST SACRAMENTO, CA|1110|W|CAPITOL|Ave|||WEST SACRAMENTO|CA||t
\ No newline at end of file
-- this one is wrong (because the lack of space trips it up) but will fix later
SELECT '#1125e' As ticket, pprint_addy(addy), addy.* FROM normalize_address('I-90,Boston, MA') As addy;
SELECT '#1125f' As ticket, pprint_addy(addy), addy.* FROM normalize_address('I 90,Boston, MA') As addy;
+
+-- location with prefixes getting caught in post prefix
+SELECT '#1310a' As ticket, pprint_addy(addy), addy.* FROM normalize_address('1110 W CAPITOL AVE, WEST SACRAMENTO, CA') As addy;
\timing