diff --git a/src/libpostal.c b/src/libpostal.c index 066a3015..754093f0 100644 --- a/src/libpostal.c +++ b/src/libpostal.c @@ -40,7 +40,8 @@ static libpostal_normalize_options_t LIBPOSTAL_DEFAULT_OPTIONS = { .drop_english_possessives = true, .delete_apostrophes = true, .expand_numex = true, - .roman_numerals = true + .roman_numerals = true, + .root = true }; libpostal_normalize_options_t libpostal_get_default_options(void) { @@ -78,7 +79,8 @@ static libpostal_near_dupe_hash_options_t LIBPOSTAL_NEAR_DUPE_HASH_DEFAULT_OPTIO .geohash_precision = DEFAULT_NEAR_DUPE_GEOHASH_PRECISION, .name_and_address_keys = true, .name_only_keys = false, - .address_only_keys = false + .address_only_keys = false, + .street_root = true }; libpostal_near_dupe_hash_options_t libpostal_get_near_dupe_hash_default_options(void) { diff --git a/src/libpostal.h b/src/libpostal.h index 42a13e3c..c532c00c 100644 --- a/src/libpostal.h +++ b/src/libpostal.h @@ -133,6 +133,9 @@ typedef struct libpostal_normalize_options { bool expand_numex; bool roman_numerals; + // Expansion options + bool root; + } libpostal_normalize_options_t; LIBPOSTAL_EXPORT libpostal_normalize_options_t libpostal_get_default_options(void); @@ -202,6 +205,7 @@ typedef struct libpostal_near_dupe_hash_options { bool name_and_address_keys; bool name_only_keys; bool address_only_keys; + bool street_root; } libpostal_near_dupe_hash_options_t; LIBPOSTAL_EXPORT libpostal_near_dupe_hash_options_t libpostal_get_near_dupe_hash_default_options(void); diff --git a/src/near_dupe.c b/src/near_dupe.c index 06a89ac4..3e77ceac 100644 --- a/src/near_dupe.c +++ b/src/near_dupe.c @@ -150,8 +150,8 @@ cstring_array *expanded_component_combined(char *input, libpostal_normalize_opti size_t num_root_expansions = 0; cstring_array *root_expansions = expand_address_root(input, options, &num_root_expansions); - - if (num_root_expansions == 0) { + + if (!options.root || num_root_expansions == 0) { cstring_array_destroy(root_expansions); *n = num_expansions; return expansions; @@ -706,6 +706,7 @@ cstring_array *near_dupe_hashes_languages(size_t num_components, char **labels, remove_spaces = true; log_debug("Doing street expansions for %s\n", place->street); normalize_options.address_components = LIBPOSTAL_ADDRESS_STREET | LIBPOSTAL_ADDRESS_ANY; + normalize_options.root = options.street_root; street_expansions = expanded_component_combined(place->street, normalize_options, remove_spaces, &num_street_expansions); log_debug("Got %zu street expansions\n", num_street_expansions); }