genesis
This commit is contained in:
45
similarity_search.h
Normal file
45
similarity_search.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef SIMILARITY_SEARCH_H
|
||||
#define SIMILARITY_SEARCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_STRING_LEN 100
|
||||
#define MAX_WORDS 20
|
||||
|
||||
// Public API
|
||||
|
||||
// Structure representing the search index
|
||||
typedef struct {
|
||||
char **strings;
|
||||
int num_strings;
|
||||
} SearchIndex;
|
||||
|
||||
// Structure to hold a search result
|
||||
typedef struct {
|
||||
const 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 */
|
||||
Reference in New Issue
Block a user