forked from atom/fuzzy-native
-
Notifications
You must be signed in to change notification settings - Fork 1
/
score_match.h
32 lines (29 loc) · 917 Bytes
/
score_match.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <cstddef>
#include <string>
#include <vector>
struct MatchOptions {
bool case_sensitive;
bool smart_case;
size_t max_gap;
bool fuzzaldrin = false;
std::string root_path;
};
/**
* Returns a matching score between 0-1.
* 0 represents no match at all, while 1 is a perfect match.
* See implementation for scoring details.
*
* If options.case_sensitive is false, haystack_lower and
* needle_lower must be provided.
*
* If match_indexes is non-null, the optimal match index in haystack
* will be computed for each value in needle (when score is non-zero).
*/
float score_match(const char *haystack,
const char *haystack_lower,
const char *needle,
const char *needle_lower,
const MatchOptions &options,
const float min_score,
std::vector<int> *match_indexes = nullptr);