41 lines
No EOL
1.4 KiB
C
41 lines
No EOL
1.4 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct MarisaTrie MarisaTrie;
|
|
typedef struct MarisaKeyset MarisaKeyset;
|
|
typedef struct MarisaAgent MarisaAgent;
|
|
|
|
// Keyset functions
|
|
MarisaKeyset* marisa_keyset_new();
|
|
void marisa_keyset_delete(MarisaKeyset* keyset);
|
|
void marisa_keyset_push_back(MarisaKeyset* keyset, const char* key, size_t length, float weight);
|
|
size_t marisa_keyset_size(const MarisaKeyset* keyset);
|
|
|
|
// Trie functions
|
|
MarisaTrie* marisa_trie_new();
|
|
void marisa_trie_delete(MarisaTrie* trie);
|
|
int marisa_trie_build(MarisaTrie* trie, MarisaKeyset* keyset);
|
|
int marisa_trie_lookup(const MarisaTrie* trie, MarisaAgent* agent);
|
|
int marisa_trie_reverse_lookup(const MarisaTrie* trie, MarisaAgent* agent);
|
|
int marisa_trie_common_prefix_search(const MarisaTrie* trie, MarisaAgent* agent);
|
|
int marisa_trie_predictive_search(const MarisaTrie* trie, MarisaAgent* agent);
|
|
size_t marisa_trie_size(const MarisaTrie* trie);
|
|
|
|
// Agent functions
|
|
MarisaAgent* marisa_agent_new();
|
|
void marisa_agent_delete(MarisaAgent* agent);
|
|
void marisa_agent_set_query(MarisaAgent* agent, const char* query, size_t length);
|
|
void marisa_agent_set_query_by_id(MarisaAgent* agent, size_t id);
|
|
const char* marisa_agent_key_ptr(const MarisaAgent* agent);
|
|
size_t marisa_agent_key_length(const MarisaAgent* agent);
|
|
size_t marisa_agent_key_id(const MarisaAgent* agent);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |