PA(trie_t) tries;
A(int) weights;
A(bool) reverses;
+ A(bool) partiales;
int soft_threshold;
int hard_threshold;
array_deep_wipe((*config)->tries, trie_delete);
array_wipe((*config)->weights);
array_wipe((*config)->reverses);
+ array_wipe((*config)->partiales);
p_delete(config);
}
}
bool lock = false;
int weight = 0;
bool reverse = false;
+ bool partial = false;
trie_t *trie = NULL;
const char *current = param->value;
const char *p = m_strchrnul(param->value, ':');
break;
case 1:
+ if (p - current > (ssize_t)strlen("partial-")
+ && strncmp(current, "partial-", strlen("partial-")) == 0) {
+ partial = true;
+ current += strlen("partial-");
+ }
if ((p - current) == 6 && strncmp(current, "suffix", 6) == 0) {
reverse = true;
} else if ((p - current) == 6 && strncmp(current, "prefix", 6) == 0) {
array_add(config->tries, trie);
array_add(config->weights, weight);
array_add(config->reverses, reverse);
+ array_add(config->partiales, partial);
break;
}
if (i != 3) {
return HTK_ABORT;
}
#define LOOKUP(Flag, Field) \
- if (config->match_ ## Flag) { \
- const int len = m_strlen(query->Field); \
- strlist_copy(normal, query->Field, len, false); \
- strlist_copy(reverse, query->Field, len, true); \
- for (int i = 0 ; i < config->tries.len ; ++i) { \
- const int weight = array_elt(config->weights, i); \
- const trie_t *trie = array_elt(config->tries, i); \
- const bool rev = array_elt(config->reverses, i); \
- if (trie_lookup(trie, rev ? reverse : normal)) { \
- sum += weight; \
- } \
- } \
+ if (config->match_ ## Flag) { \
+ const int len = m_strlen(query->Field); \
+ strlist_copy(normal, query->Field, len, false); \
+ strlist_copy(reverse, query->Field, len, true); \
+ for (uint32_t i = 0 ; i < config->tries.len ; ++i) { \
+ const int weight = array_elt(config->weights, i); \
+ const trie_t *trie = array_elt(config->tries, i); \
+ const bool rev = array_elt(config->reverses, i); \
+ const bool part = array_elt(config->partiales, i); \
+ if ((!part && trie_lookup(trie, rev ? reverse : normal)) \
+ || (part && trie_prefix(trie, rev ? reverse : normal))) { \
+ sum += weight; \
+ } \
+ } \
}
if (config->is_email) {
LOOKUP(sender, sender);