From 3a5c048419eaf7e844bf0e2c0c1a8bfd4c44be5f Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 6 Feb 2018 02:30:03 -0500 Subject: [PATCH] [fix] in root expansions, if the current phrase has at least one valid expansion, and the current expansion is not valid, ignore it --- src/expand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/expand.c b/src/expand.c index e1fb5bb0..72b2958e 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1005,6 +1005,8 @@ string_tree_t *add_string_alternatives_phrase_option(char *str, libpostal_normal bool current_phrase_have_canonical = delete_phrases && address_phrase_has_canonical_interpretation(phrase); bool current_phrase_have_possible_root = delete_phrases && address_phrase_is_possible_root_for_components(phrase, options.address_components); + bool current_phrase_have_valid = address_phrase_is_valid_for_components(phrase, options.address_components); + log_debug("current_phrase_have_specifier = %d\n", current_phrase_have_specifier); bool current_phrase_have_unambiguous = delete_phrases && address_phrase_contains_unambiguous_expansion(phrase); @@ -1158,7 +1160,7 @@ string_tree_t *add_string_alternatives_phrase_option(char *str, libpostal_normal log_debug("current_phrase_ignorable = %d\n", current_phrase_ignorable); } else if (!is_valid_for_components && !is_ambiguous) { log_debug("!is_valid_for_components\n"); - current_phrase_ignorable = current_phrase_have_ignorable; + current_phrase_ignorable = current_phrase_have_ignorable || current_phrase_have_valid; log_debug("current_phrase_ignorable = %d\n", current_phrase_ignorable); } else { log_debug("none of the above\n");