From 2c8ac7259c72c39ea21de15e6fc68d8d8489a131 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 22 Oct 2021 11:30:27 +0100 Subject: [PATCH] Look for more variations of street names --- web_view.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/web_view.py b/web_view.py index 09bfb16..ac6cac1 100755 --- a/web_view.py +++ b/web_view.py @@ -430,20 +430,22 @@ def api_get_item_tags(item_id): duration=t1) -def expand_street_name(name): - ret = {name} - if any(name.startswith(st) for st in ('St ', 'St. ')): - first_space = name.find(' ') - ret.add("Saint" + name[first_space:]) +def expand_street_name(from_names): + ret = set(from_names) + for name in from_names: + if any(name.startswith(st) for st in ('St ', 'St. ')): + first_space = name.find(' ') + ret.add("Saint" + name[first_space:]) - if ', ' in name: - for n in set(ret): - comma = n.find(", ") - ret.add(name[:comma]) - elif '/' in name: - for n in set(ret): - ret.extend(part.strip() for part in n.split("/")) + if ', ' in name: + for n in set(ret): + comma = n.find(", ") + ret.add(name[:comma]) + elif '/' in name: + for n in set(ret): + ret.extend(part.strip() for part in n.split("/")) + ret.update({"The " + name for name in ret if not name.startswith("The ")}) return ret