Skip to content

Commit d86973f

Browse files
committed
apply formatting
1 parent e204e54 commit d86973f

11 files changed

+68
-79
lines changed

extras/rapidfuzz_amalgamated.hpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22
// SPDX-License-Identifier: MIT
33
// RapidFuzz v1.0.2
4-
// Generated: 2024-03-04 01:05:33.165575
4+
// Generated: 2024-04-06 15:39:26.940916
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -6408,7 +6408,10 @@ double jaro_winkler_similarity(const Range<InputIt1>& P, const Range<InputIt2>&
64086408
}
64096409

64106410
double Sim = jaro_similarity(P, T, jaro_score_cutoff);
6411-
if (Sim > 0.7) Sim += static_cast<double>(prefix) * prefix_weight * (1.0 - Sim);
6411+
if (Sim > 0.7) {
6412+
Sim += static_cast<double>(prefix) * prefix_weight * (1.0 - Sim);
6413+
Sim = std::min(Sim, 1.0);
6414+
}
64126415

64136416
return (Sim >= score_cutoff) ? Sim : 0;
64146417
}
@@ -6437,7 +6440,10 @@ double jaro_winkler_similarity(const BlockPatternMatchVector& PM, const Range<In
64376440
}
64386441

64396442
double Sim = jaro_similarity(PM, P, T, jaro_score_cutoff);
6440-
if (Sim > 0.7) Sim += static_cast<double>(prefix) * prefix_weight * (1.0 - Sim);
6443+
if (Sim > 0.7) {
6444+
Sim += static_cast<double>(prefix) * prefix_weight * (1.0 - Sim);
6445+
Sim = std::min(Sim, 1.0);
6446+
}
64416447

64426448
return (Sim >= score_cutoff) ? Sim : 0;
64436449
}
@@ -6593,6 +6599,7 @@ struct MultiJaroWinkler : public detail::MultiSimilarityBase<MultiJaroWinkler<Ma
65936599
if (static_cast<uint64_t>(s2[prefix]) != prefixes[i][prefix]) break;
65946600

65956601
scores[i] += static_cast<double>(prefix) * prefix_weight * (1.0 - scores[i]);
6602+
scores[i] = std::min(scores[i], 1.0);
65966603
}
65976604

65986605
if (scores[i] < score_cutoff) scores[i] = 0.0;

rapidfuzz/details/GrowingHashmap.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#pragma once
55

66
#include <array>
7-
#include <stdint.h>
87
#include <stddef.h>
8+
#include <stdint.h>
99

1010
namespace rapidfuzz::detail {
1111

rapidfuzz/details/Range.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <limits>
1010
#include <ostream>
1111
#include <stdexcept>
12+
#include <stdint.h>
1213
#include <sys/types.h>
1314
#include <vector>
14-
#include <stdint.h>
1515

1616
namespace rapidfuzz::detail {
1717

@@ -76,8 +76,7 @@ class Range {
7676
}
7777

7878
constexpr Range(Iter first, Iter last, size_t size) : _first(first), _last(last), _size(size)
79-
{
80-
}
79+
{}
8180

8281
template <typename T>
8382
constexpr Range(T& x) : _first(to_begin(x)), _last(to_end(x))
@@ -156,8 +155,7 @@ class Range {
156155

157156
Range res = *this;
158157
res.remove_prefix(pos);
159-
if(count < res.size())
160-
res.remove_suffix(res.size() - count);
158+
if (count < res.size()) res.remove_suffix(res.size() - count);
161159

162160
return res;
163161
}

rapidfuzz/distance/Indel.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ namespace rapidfuzz {
1111

1212
template <typename InputIt1, typename InputIt2>
1313
size_t indel_distance(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
14-
size_t score_cutoff = std::numeric_limits<size_t>::max())
14+
size_t score_cutoff = std::numeric_limits<size_t>::max())
1515
{
1616
return detail::Indel::distance(first1, last1, first2, last2, score_cutoff, score_cutoff);
1717
}
1818

1919
template <typename Sentence1, typename Sentence2>
2020
size_t indel_distance(const Sentence1& s1, const Sentence2& s2,
21-
size_t score_cutoff = std::numeric_limits<size_t>::max())
21+
size_t score_cutoff = std::numeric_limits<size_t>::max())
2222
{
2323
return detail::Indel::distance(s1, s2, score_cutoff, score_cutoff);
2424
}
2525

2626
template <typename InputIt1, typename InputIt2>
2727
size_t indel_similarity(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
28-
size_t score_cutoff = 0.0)
28+
size_t score_cutoff = 0.0)
2929
{
3030
return detail::Indel::similarity(first1, last1, first2, last2, score_cutoff, score_cutoff);
3131
}
@@ -146,8 +146,8 @@ struct MultiIndel
146146
#endif
147147

148148
template <typename CharT1>
149-
struct CachedIndel : public detail::CachedDistanceBase<CachedIndel<CharT1>, size_t, 0,
150-
std::numeric_limits<int64_t>::max()> {
149+
struct CachedIndel
150+
: public detail::CachedDistanceBase<CachedIndel<CharT1>, size_t, 0, std::numeric_limits<int64_t>::max()> {
151151
template <typename Sentence1>
152152
explicit CachedIndel(const Sentence1& s1_) : CachedIndel(detail::to_begin(s1_), detail::to_end(s1_))
153153
{}

rapidfuzz/distance/Indel_impl.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace rapidfuzz::detail {
1212

1313
template <typename InputIt1, typename InputIt2>
1414
size_t indel_distance(const BlockPatternMatchVector& block, const Range<InputIt1>& s1,
15-
const Range<InputIt2>& s2, size_t score_cutoff)
15+
const Range<InputIt2>& s2, size_t score_cutoff)
1616
{
1717
size_t maximum = s1.size() + s2.size();
1818
size_t lcs_cutoff = (maximum / 2 >= score_cutoff) ? maximum / 2 - score_cutoff : 0;
@@ -54,7 +54,7 @@ class Indel : public DistanceBase<Indel, size_t, 0, std::numeric_limits<int64_t>
5454

5555
template <typename InputIt1, typename InputIt2>
5656
static size_t _distance(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t score_cutoff,
57-
size_t score_hint)
57+
size_t score_hint)
5858
{
5959
size_t maximum = Indel::maximum(s1, s2);
6060
size_t lcs_cutoff = (maximum / 2 >= score_cutoff) ? maximum / 2 - score_cutoff : 0;

rapidfuzz/distance/Jaro_impl.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,9 @@ jaro_similarity_simd_long_s2(Range<double*> scores, const detail::BlockPatternMa
673673

674674
VecType PatternFlagMask = blsi(P_flag_cur);
675675

676-
uint64_t PM_j = block.get(
677-
cur_vec + cur_block, s2[countr_zero(T_flag_cur) + T_word_index * sizeof(VecType) * 8]);
676+
uint64_t PM_j =
677+
block.get(cur_vec + cur_block,
678+
s2[countr_zero(T_flag_cur) + T_word_index * sizeof(VecType) * 8]);
678679
Transpositions += !(PM_j & (static_cast<uint64_t>(PatternFlagMask) << offset));
679680

680681
T_flag_cur = blsr(T_flag_cur);

rapidfuzz/distance/LCSseq.hpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ namespace rapidfuzz {
1111

1212
template <typename InputIt1, typename InputIt2>
1313
size_t lcs_seq_distance(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
14-
size_t score_cutoff = std::numeric_limits<size_t>::max())
14+
size_t score_cutoff = std::numeric_limits<size_t>::max())
1515
{
1616
return detail::LCSseq::distance(first1, last1, first2, last2, score_cutoff, score_cutoff);
1717
}
1818

1919
template <typename Sentence1, typename Sentence2>
2020
size_t lcs_seq_distance(const Sentence1& s1, const Sentence2& s2,
21-
size_t score_cutoff = std::numeric_limits<size_t>::max())
21+
size_t score_cutoff = std::numeric_limits<size_t>::max())
2222
{
2323
return detail::LCSseq::distance(s1, s2, score_cutoff, score_cutoff);
2424
}
2525

2626
template <typename InputIt1, typename InputIt2>
2727
size_t lcs_seq_similarity(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
28-
size_t score_cutoff = 0)
28+
size_t score_cutoff = 0)
2929
{
3030
return detail::LCSseq::similarity(first1, last1, first2, last2, score_cutoff, score_cutoff);
3131
}
@@ -206,8 +206,7 @@ struct CachedLCSseq
206206
{}
207207

208208
private:
209-
friend detail::CachedSimilarityBase<CachedLCSseq<CharT1>, size_t, 0,
210-
std::numeric_limits<int64_t>::max()>;
209+
friend detail::CachedSimilarityBase<CachedLCSseq<CharT1>, size_t, 0, std::numeric_limits<int64_t>::max()>;
211210
friend detail::CachedNormalizedMetricBase<CachedLCSseq<CharT1>>;
212211

213212
template <typename InputIt2>
@@ -218,7 +217,7 @@ struct CachedLCSseq
218217

219218
template <typename InputIt2>
220219
size_t _similarity(const detail::Range<InputIt2>& s2, size_t score_cutoff,
221-
[[maybe_unused]] size_t score_hint) const
220+
[[maybe_unused]] size_t score_hint) const
222221
{
223222
return detail::lcs_seq_similarity(PM, detail::Range(s1), s2, score_cutoff);
224223
}

rapidfuzz/distance/LCSseq_impl.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ size_t longest_common_subsequence(const Range<InputIt1>& s1, const Range<InputIt
343343

344344
template <typename InputIt1, typename InputIt2>
345345
size_t lcs_seq_similarity(const BlockPatternMatchVector& block, Range<InputIt1> s1, Range<InputIt2> s2,
346-
size_t score_cutoff)
346+
size_t score_cutoff)
347347
{
348348
auto len1 = s1.size();
349349
auto len2 = s2.size();
@@ -520,7 +520,7 @@ class LCSseq : public SimilarityBase<LCSseq, size_t, 0, std::numeric_limits<int6
520520

521521
template <typename InputIt1, typename InputIt2>
522522
static size_t _similarity(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t score_cutoff,
523-
[[maybe_unused]] size_t score_hint)
523+
[[maybe_unused]] size_t score_hint)
524524
{
525525
return lcs_seq_similarity(s1, s2, score_cutoff);
526526
}

rapidfuzz/distance/Levenshtein.hpp

+17-23
Original file line numberDiff line numberDiff line change
@@ -139,34 +139,34 @@ namespace rapidfuzz {
139139
*/
140140
template <typename InputIt1, typename InputIt2>
141141
size_t levenshtein_distance(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
142-
LevenshteinWeightTable weights = {1, 1, 1},
143-
size_t score_cutoff = std::numeric_limits<size_t>::max(),
144-
size_t score_hint = std::numeric_limits<size_t>::max())
142+
LevenshteinWeightTable weights = {1, 1, 1},
143+
size_t score_cutoff = std::numeric_limits<size_t>::max(),
144+
size_t score_hint = std::numeric_limits<size_t>::max())
145145
{
146146
return detail::Levenshtein::distance(first1, last1, first2, last2, weights, score_cutoff, score_hint);
147147
}
148148

149149
template <typename Sentence1, typename Sentence2>
150150
size_t levenshtein_distance(const Sentence1& s1, const Sentence2& s2,
151-
LevenshteinWeightTable weights = {1, 1, 1},
152-
size_t score_cutoff = std::numeric_limits<size_t>::max(),
153-
size_t score_hint = std::numeric_limits<size_t>::max())
151+
LevenshteinWeightTable weights = {1, 1, 1},
152+
size_t score_cutoff = std::numeric_limits<size_t>::max(),
153+
size_t score_hint = std::numeric_limits<size_t>::max())
154154
{
155155
return detail::Levenshtein::distance(s1, s2, weights, score_cutoff, score_hint);
156156
}
157157

158158
template <typename InputIt1, typename InputIt2>
159159
size_t levenshtein_similarity(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
160-
LevenshteinWeightTable weights = {1, 1, 1}, size_t score_cutoff = 0,
161-
size_t score_hint = 0)
160+
LevenshteinWeightTable weights = {1, 1, 1}, size_t score_cutoff = 0,
161+
size_t score_hint = 0)
162162
{
163163
return detail::Levenshtein::similarity(first1, last1, first2, last2, weights, score_cutoff, score_hint);
164164
}
165165

166166
template <typename Sentence1, typename Sentence2>
167167
size_t levenshtein_similarity(const Sentence1& s1, const Sentence2& s2,
168-
LevenshteinWeightTable weights = {1, 1, 1}, size_t score_cutoff = 0,
169-
size_t score_hint = 0)
168+
LevenshteinWeightTable weights = {1, 1, 1}, size_t score_cutoff = 0,
169+
size_t score_hint = 0)
170170
{
171171
return detail::Levenshtein::similarity(s1, s2, weights, score_cutoff, score_hint);
172172
}
@@ -389,17 +389,13 @@ struct MultiLevenshtein : public detail::MultiDistanceBase<MultiLevenshtein<MaxL
389389

390390
detail::Range scores_(scores, scores + score_count);
391391
if constexpr (MaxLen == 8)
392-
detail::levenshtein_hyrroe2003_simd<uint8_t>(scores_, PM, str_lens, s2,
393-
score_cutoff);
392+
detail::levenshtein_hyrroe2003_simd<uint8_t>(scores_, PM, str_lens, s2, score_cutoff);
394393
else if constexpr (MaxLen == 16)
395-
detail::levenshtein_hyrroe2003_simd<uint16_t>(scores_, PM, str_lens, s2,
396-
score_cutoff);
394+
detail::levenshtein_hyrroe2003_simd<uint16_t>(scores_, PM, str_lens, s2, score_cutoff);
397395
else if constexpr (MaxLen == 32)
398-
detail::levenshtein_hyrroe2003_simd<uint32_t>(scores_, PM, str_lens, s2,
399-
score_cutoff);
396+
detail::levenshtein_hyrroe2003_simd<uint32_t>(scores_, PM, str_lens, s2, score_cutoff);
400397
else if constexpr (MaxLen == 64)
401-
detail::levenshtein_hyrroe2003_simd<uint64_t>(scores_, PM, str_lens, s2,
402-
score_cutoff);
398+
detail::levenshtein_hyrroe2003_simd<uint64_t>(scores_, PM, str_lens, s2, score_cutoff);
403399
}
404400

405401
template <typename InputIt2>
@@ -458,9 +454,8 @@ struct CachedLevenshtein : public detail::CachedDistanceBase<CachedLevenshtein<C
458454
// max can make use of the common divisor of the three weights
459455
size_t new_score_cutoff = detail::ceil_div(score_cutoff, weights.insert_cost);
460456
size_t new_score_hint = detail::ceil_div(score_hint, weights.insert_cost);
461-
size_t dist = detail::uniform_levenshtein_distance(
462-
PM, detail::Range(s1), s2, new_score_cutoff,
463-
new_score_hint);
457+
size_t dist = detail::uniform_levenshtein_distance(PM, detail::Range(s1), s2,
458+
new_score_cutoff, new_score_hint);
464459
dist *= weights.insert_cost;
465460

466461
return (dist <= score_cutoff) ? dist : score_cutoff + 1;
@@ -478,8 +473,7 @@ struct CachedLevenshtein : public detail::CachedDistanceBase<CachedLevenshtein<C
478473
}
479474
}
480475

481-
return detail::generalized_levenshtein_distance(
482-
detail::Range(s1), s2, weights, score_cutoff);
476+
return detail::generalized_levenshtein_distance(detail::Range(s1), s2, weights, score_cutoff);
483477
}
484478

485479
std::vector<CharT1> s1;

0 commit comments

Comments
 (0)