Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable street name expansion for near dupes #594

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/libpostal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/libpostal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/near_dupe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down