[trie] Making methods to construct string phrases from phrase matches available through trie_search.h
This commit is contained in:
@@ -774,3 +774,26 @@ inline phrase_t trie_search_prefixes(trie_t *self, char *word, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline char *cstring_array_get_phrase_with_char_array(cstring_array *str, char_array *phrase_tokens, phrase_t phrase) {
|
||||||
|
char_array_clear(phrase_tokens);
|
||||||
|
|
||||||
|
size_t phrase_end = phrase.start + phrase.len;
|
||||||
|
|
||||||
|
for (int k = phrase.start; k < phrase_end; k++) {
|
||||||
|
char *w = cstring_array_get_string(str, k);
|
||||||
|
char_array_append(phrase_tokens, w);
|
||||||
|
if (k < phrase_end - 1) {
|
||||||
|
char_array_append(phrase_tokens, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char_array_terminate(phrase_tokens);
|
||||||
|
|
||||||
|
return char_array_get_string(phrase_tokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline char *cstring_array_get_phrase(tokenized_string_t *str, char_array *phrase_tokens, phrase_t phrase) {
|
||||||
|
return cstring_array_get_phrase_with_char_array(str->strings, phrase_tokens, phrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ phrase_t trie_search_prefixes_from_index(trie_t *self, char *word, size_t len, u
|
|||||||
phrase_t trie_search_prefixes_from_index_get_prefix_char(trie_t *self, char *word, size_t len, uint32_t start_node_id);
|
phrase_t trie_search_prefixes_from_index_get_prefix_char(trie_t *self, char *word, size_t len, uint32_t start_node_id);
|
||||||
phrase_t trie_search_prefixes(trie_t *self, char *word, size_t len);
|
phrase_t trie_search_prefixes(trie_t *self, char *word, size_t len);
|
||||||
|
|
||||||
|
char *cstring_array_get_phrase_with_char_array(cstring_array *str, char_array *phrase_tokens, phrase_t phrase);
|
||||||
|
char *cstring_array_get_phrase(tokenized_string_t *str, char_array *phrase_tokens, phrase_t phrase);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user