[expansion] Language prefixed keys
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
#include "address_dictionary.h"
|
||||
|
||||
#include "address_expansion_data.c"
|
||||
#include "config.h"
|
||||
#include "collections.h"
|
||||
#include "config.h"
|
||||
#include "constants.h"
|
||||
#include "gazetteer_data.c"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@@ -34,6 +35,8 @@ int main(int argc, char **argv) {
|
||||
kh_value(dictionary_components, k) = (uint32_t) gazetteer.address_components;
|
||||
}
|
||||
|
||||
char_array *key = char_array_new();
|
||||
|
||||
for (int i = 0; i < sizeof(expansion_languages) / sizeof(address_language_index_t); i++) {
|
||||
address_language_index_t lang_index = expansion_languages[i];
|
||||
char *language = lang_index.language;
|
||||
@@ -55,7 +58,13 @@ int main(int argc, char **argv) {
|
||||
canonical = canonical_strings[expansion_rule.canonical_index];
|
||||
}
|
||||
|
||||
if (!address_dictionary_add_expansion(address_dict, expansion_rule.phrase, canonical, language, dictionary_id, address_components)) {
|
||||
char_array_clear(key);
|
||||
char_array_cat(key, language);
|
||||
char_array_cat(key, NAMESPACE_SEPARATOR_CHAR);
|
||||
char_array_cat(key, expansion_rule.phrase);
|
||||
char *token = char_array_get_string(key);
|
||||
|
||||
if (!address_dictionary_add_expansion(address_dict, token, canonical, language, dictionary_id, address_components)) {
|
||||
log_error("Could not add expansion {%s, %s}\n", language, expansion_rule.phrase);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -63,9 +72,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
address_dictionary_save(output_file);
|
||||
|
||||
char_array_destroy(key);
|
||||
|
||||
kh_destroy(int_int, dictionary_components);
|
||||
|
||||
address_dictionary_module_teardown();
|
||||
|
||||
Reference in New Issue
Block a user