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
121
122
123
124
125
126
127
128
//! Scoring constants and algorithm configuration.
/// Per-character penalty for unmatched characters **before** the first match.
pub const SCORE_GAP_LEADING: f64 = -0.005;
/// Per-character penalty for unmatched characters **after** the last match.
pub const SCORE_GAP_TRAILING: f64 = -0.005;
/// Per-character penalty for unmatched characters **between** two matches.
pub const SCORE_GAP_INNER: f64 = -0.01;
/// Bonus for a match that immediately follows the previous match.
pub const SCORE_MATCH_CONSECUTIVE: f64 = 1.0;
/// Bonus for a match on a character immediately after `/`.
pub const SCORE_MATCH_SLASH: f64 = 0.9;
/// Bonus for a match on a character that starts a word
/// (preceded by `-`, `_`, or ` `).
pub const SCORE_MATCH_WORD: f64 = 0.8;
/// Bonus for a match on a lowercase letter that follows an uppercase letter
/// (CamelCase boundary).
pub const SCORE_MATCH_CAPITAL: f64 = 0.7;
/// Bonus for a match on a character immediately after `.`.
pub const SCORE_MATCH_DOT: f64 = 0.6;
/// Leading-gap penalty used by [`Prefer::Prefix`].
///
/// Heavy enough to outweigh [`SCORE_MATCH_CONSECUTIVE`] after two skipped
/// characters, so any match at position 0 beats a consecutive match at
/// position 2 or later.
pub const SCORE_PREFIX_GAP_LEADING: f64 = -0.5;
/// Trailing-gap penalty used by [`Prefer::Suffix`].
///
/// Symmetric to [`SCORE_PREFIX_GAP_LEADING`]: a match ending two characters
/// before the haystack end is penalised more than a consecutive bonus is worth.
pub const SCORE_SUFFIX_GAP_TRAILING: f64 = -0.5;
/// Controls how the scoring algorithm weighs structural match patterns.
///
/// Each variant selects a different set of gap-penalty constants for the
/// Gotoh DP alignment kernel. The matching pass ([`has_match`]) is
/// unaffected; only relative ordering of scores changes.
///
/// [`has_match`]: crate::has_match
///
/// # Examples
///
/// ```rust
/// use neek_core::{Scorer, config::Prefer};
///
/// let scorer = Scorer::new(Prefer::Prefix);
/// // "build" starts with 'b'; "table" has a contiguous "bl" mid-string.
/// // Prefix-biased scoring ranks "build" higher.
/// assert!(scorer.score(b"bl", b"build") > scorer.score(b"bl", b"table"));
/// ```
/// Gap-penalty triplet passed into the DP kernel.
///
/// This is an implementation detail; callers use [`Prefer`] and [`Scorer`]
/// instead.
///
/// [`Scorer`]: crate::Scorer
pub