[fix] Prefixes and suffixes that are the same length as the original token should be handled as regular expansions

This commit is contained in:
Al
2015-12-19 17:29:26 -05:00
parent aaecd7961a
commit cf2a0efa11

View File

@@ -437,8 +437,12 @@ inline void cat_affix_expansion(char_array *key, char *str, address_expansion_t
bool add_affix_expansions(string_tree_t *tree, char *str, char *lang, token_t token, phrase_t prefix, phrase_t suffix, normalize_options_t options) {
cstring_array *strings = tree->strings;
bool have_suffix = suffix.len > 0;
bool have_prefix = prefix.len > 0;
bool have_suffix = suffix.len > 0 && suffix.len < token.len;
bool have_prefix = prefix.len > 0 && prefix.len < token.len;
if (!have_suffix && !have_prefix) {
return false;
}
address_expansion_array *prefix_expansions = NULL;
address_expansion_array *suffix_expansions = NULL;
@@ -470,6 +474,7 @@ bool add_affix_expansions(string_tree_t *tree, char *str, char *lang, token_t to
}
if (!have_suffix && !have_prefix) {
char_array_destroy(key);
return false;
}
@@ -556,7 +561,6 @@ bool add_affix_expansions(string_tree_t *tree, char *str, char *lang, token_t to
char_array_clear(key);
root_word = cstring_array_get_string(root_strings, j);
char_array_cat(key, root_word);
root_end = key->n - 1;
for (int k = 0; k < suffix_expansions->n; k++) {
@@ -645,6 +649,7 @@ inline bool expand_affixes(string_tree_t *tree, char *str, char *lang, token_t t
if ((suffix.len == 0 && prefix.len == 0)) return false;
return add_affix_expansions(tree, str, lang, token, prefix, suffix, options);
}