forked from rapidfuzz/RapidFuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuzz_cpp.hpp
120 lines (108 loc) · 5.08 KB
/
fuzz_cpp.hpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#pragma once
#include "cpp_common.hpp"
static inline double ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool RatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedRatio, double>(self, str_count, str);
}
static inline double partial_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::partial_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool PartialRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedPartialRatio, double>(self, str_count, str);
}
rapidfuzz::ScoreAlignment<double> partial_ratio_alignment_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::partial_ratio_alignment(first1, last1, first2, last2, score_cutoff);
});
}
static inline double token_sort_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::token_sort_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool TokenSortRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedTokenSortRatio, double>(self, str_count, str);
}
static inline double token_set_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::token_set_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool TokenSetRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedTokenSetRatio, double>(self, str_count, str);
}
static inline double token_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::token_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool TokenRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedTokenRatio, double>(self, str_count, str);
}
static inline double partial_token_sort_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::partial_token_sort_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool PartialTokenSortRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedPartialTokenSortRatio, double>(self, str_count, str);
}
static inline double partial_token_set_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::partial_token_set_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool PartialTokenSetRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedPartialTokenSetRatio, double>(self, str_count, str);
}
static inline double partial_token_ratio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::partial_token_ratio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool PartialTokenRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedPartialTokenRatio, double>(self, str_count, str);
}
static inline double WRatio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::WRatio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool WRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedWRatio, double>(self, str_count, str);
}
static inline double QRatio_func(const RF_String& s1, const RF_String& s2, double score_cutoff)
{
return visitor(s1, s2, [&](auto first1, auto last1, auto first2, auto last2) {
return fuzz::QRatio(first1, last1, first2, last2, score_cutoff);
});
}
static inline bool QRatioInit(RF_ScorerFunc* self, const RF_Kwargs*, int64_t str_count, const RF_String* str)
{
return similarity_init<fuzz::CachedQRatio, double>(self, str_count, str);
}