/src/aspell/modules/speller/default/editdist2.hpp
Line | Count | Source |
1 | | |
2 | | #include "leditdist.hpp" |
3 | | #include "editdist.hpp" |
4 | | |
5 | | #include <cassert> |
6 | | |
7 | | namespace aspeller { |
8 | | inline int edit_distance(ParmString a, ParmString b, |
9 | | int level, // starting level |
10 | | int limit, // maximum level |
11 | | const EditDistanceWeights & w |
12 | | = EditDistanceWeights()) |
13 | 37.2M | { |
14 | 37.2M | int score; |
15 | 37.2M | assert(level > 0 && limit >= level); |
16 | 40.6M | do { |
17 | 40.6M | if (level == 2) { |
18 | 21.0M | score = limit2_edit_distance(a,b,w); |
19 | 21.0M | } else if (level < 5) { |
20 | 18.6M | score = limit_edit_distance(a,b,level,w); |
21 | 18.6M | } else { |
22 | 996k | score = edit_distance(a,b,w); |
23 | 996k | } |
24 | 40.6M | ++level; |
25 | 40.6M | } while (score >= LARGE_NUM && level <= limit); |
26 | 37.2M | return score; |
27 | 37.2M | } |
28 | | } |