Skip to content

Commit 07f5318

Browse files
mode level standardisation caching added
1 parent c81b507 commit 07f5318

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

fuzzy_address_matcher/matcher_funcs.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,21 @@ def _safe_file_stem(name: str, default: str) -> str:
193193
return stem
194194

195195

196-
def _stand_cache_path(output_folder: str, input_name: str, stand_kind: str) -> str:
196+
def _stand_cache_path(
197+
output_folder: str, input_name: str, stand_kind: str, blocker_mode: str
198+
) -> str:
197199
"""
198200
input_name: original input file name (or a descriptive label like 'API').
199201
stand_kind: 'stand_min' or 'stand_full'.
200-
Produces <output_folder>/<input_stem>_<stand_kind>.parquet
202+
blocker_mode: 'postcode' or 'street' (cache isolation by match mode).
203+
Produces <output_folder>/<input_stem>_<stand_kind>_<blocker_mode>.parquet
201204
"""
202205
stem = _safe_file_stem(input_name, default="data")
203206
out_dir = output_folder or ""
204207
if out_dir and not out_dir.endswith((os.sep, "/")):
205208
out_dir = out_dir + os.sep
206-
return os.path.join(out_dir, f"{stem}_{stand_kind}.parquet")
209+
mode = _safe_file_stem(blocker_mode, default="postcode")
210+
return os.path.join(out_dir, f"{stem}_{stand_kind}_{mode}.parquet")
207211

208212

209213
def _standardise_search_df(
@@ -1913,8 +1917,13 @@ def _notify_ui(level: str, message: str) -> None:
19131917
progress(0.1, desc="Performing minimal standardisation")
19141918

19151919
_stand_out = getattr(InitMatch, "output_folder", None) or output_folder
1916-
_path_min_s = _stand_cache_path(_stand_out, InitMatch.file_name, "stand_min")
1917-
_path_min_r = _stand_cache_path(_stand_out, InitMatch.ref_name, "stand_min")
1920+
_cache_mode = "postcode" if use_postcode_blocker else "street"
1921+
_path_min_s = _stand_cache_path(
1922+
_stand_out, InitMatch.file_name, "stand_min", _cache_mode
1923+
)
1924+
_path_min_r = _stand_cache_path(
1925+
_stand_out, InitMatch.ref_name, "stand_min", _cache_mode
1926+
)
19181927

19191928
def _cache_is_compatible(
19201929
cached_df: pd.DataFrame,
@@ -2063,8 +2072,12 @@ def _cache_is_compatible(
20632072

20642073
# Standardise - full
20652074
tic = time.perf_counter()
2066-
_path_full_s = _stand_cache_path(_stand_out, InitMatch.file_name, "stand_full")
2067-
_path_full_r = _stand_cache_path(_stand_out, InitMatch.ref_name, "stand_full")
2075+
_path_full_s = _stand_cache_path(
2076+
_stand_out, InitMatch.file_name, "stand_full", _cache_mode
2077+
)
2078+
_path_full_r = _stand_cache_path(
2079+
_stand_out, InitMatch.ref_name, "stand_full", _cache_mode
2080+
)
20682081

20692082
_loaded_full_s = False
20702083
if USE_EXISTING_STANDARDISED_FILES and os.path.isfile(_path_full_s):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "fuzzy_address_matcher"
7-
version = "2.1.0"
7+
version = "2.1.1"
88
description = "Match tabular address datasets together using address standardisation, rapidfuzz, and exact text matching via a Gradio GUI."
99
readme = "README.md"
1010
authors = [

0 commit comments

Comments
 (0)