Files
node-similarity-search-native/similarity_search.h

46 lines
1.0 KiB
C

#ifndef SIMILARITY_SEARCH_H
#define SIMILARITY_SEARCH_H
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_STRING_LEN 1000
#define MAX_WORDS 100
// Public API
// Structure representing the search index
typedef struct {
char **strings;
int num_strings;
int capacity;
} SearchIndex;
// Structure to hold a search result
typedef struct {
char *string;
float similarity;
} SearchResult;
// Create a new search index
SearchIndex* create_search_index(int capacity);
// Add a string to the index
int add_string_to_index(SearchIndex* index, const char* string);
// Free the search index and all associated memory
void free_search_index(SearchIndex* index);
// Search the index with the given query and similarity cutoff
// Returns an array of SearchResult pointers that must be freed by the caller
SearchResult* search_index(SearchIndex* index, const char* query, float cutoff, int* num_results);
// Free the search results
void free_search_results(SearchResult* results, int num_results);
#ifdef __cplusplus
}
#endif
#endif /* SIMILARITY_SEARCH_H */