Blender  V3.3
Namespaces | Functions | Variables
blender::string_search Namespace Reference

Namespaces

 tests
 

Functions

static int64_t count_utf8_code_points (StringRef str)
 
int damerau_levenshtein_distance (StringRef a, StringRef b)
 
int get_fuzzy_match_errors (StringRef query, StringRef full)
 
static bool match_word_initials (StringRef query, Span< StringRef > words, Span< int > word_match_map, MutableSpan< bool > r_word_is_matched, int start=0)
 
static int get_shortest_word_index_that_startswith (StringRef query, Span< StringRef > words, Span< int > word_match_map)
 
static int get_word_index_that_fuzzy_matches (StringRef query, Span< StringRef > words, Span< int > word_match_map, int *r_error_count)
 
static int score_query_against_words (Span< StringRef > query_words, Span< StringRef > result_words)
 
void extract_normalized_words (StringRef str, LinearAllocator<> &allocator, Vector< StringRef, 64 > &r_words)
 

Variables

static constexpr int unused_word = -1
 

Function Documentation

◆ count_utf8_code_points()

static int64_t blender::string_search::count_utf8_code_points ( StringRef  str)
static

Definition at line 19 of file string_search.cc.

References BLI_strnlen_utf8(), and str.

Referenced by damerau_levenshtein_distance(), and get_fuzzy_match_errors().

◆ damerau_levenshtein_distance()

int blender::string_search::damerau_levenshtein_distance ( StringRef  a,
StringRef  b 
)

◆ extract_normalized_words()

void blender::string_search::extract_normalized_words ( StringRef  str,
LinearAllocator<> &  allocator,
Vector< StringRef, 64 > &  r_words 
)

◆ get_fuzzy_match_errors()

int blender::string_search::get_fuzzy_match_errors ( StringRef  query,
StringRef  full 
)

◆ get_shortest_word_index_that_startswith()

static int blender::string_search::get_shortest_word_index_that_startswith ( StringRef  query,
Span< StringRef words,
Span< int >  word_match_map 
)
static

◆ get_word_index_that_fuzzy_matches()

static int blender::string_search::get_word_index_that_fuzzy_matches ( StringRef  query,
Span< StringRef words,
Span< int >  word_match_map,
int *  r_error_count 
)
static

◆ match_word_initials()

static bool blender::string_search::match_word_initials ( StringRef  query,
Span< StringRef words,
Span< int >  word_match_map,
MutableSpan< bool r_word_is_matched,
int  start = 0 
)
static

Takes a query and tries to match it with the first characters of some words. For example, "msfv" matches "Mark Sharp from Vertices". Multiple letters of the beginning of a word can be matched as well. For example, "seboulo" matches "select boundary loop". The order of words is important. So "bose" does not match "select boundary". However, individual words can be skipped. For example, "rocc" matches "rotate edge ccw".

Returns
true when the match was successful. If it was successful, the used words are tagged in r_word_is_matched.

Definition at line 166 of file string_search.cc.

References BLI_assert, BLI_str_utf8_as_unicode_step(), blender::StringRefBase::data(), blender::MutableSpan< T >::fill(), query, blender::Span< T >::size(), blender::StringRefBase::size(), and unused_word.

Referenced by score_query_against_words().

◆ score_query_against_words()

static int blender::string_search::score_query_against_words ( Span< StringRef query_words,
Span< StringRef result_words 
)
static

Variable Documentation

◆ unused_word

constexpr int blender::string_search::unused_word = -1
staticconstexpr