File: editdist2.hpp

package info (click to toggle)
aspell 0.60.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,336 kB
  • sloc: cpp: 24,378; sh: 12,340; perl: 1,924; ansic: 1,661; makefile: 852; sed: 16
file content (28 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (12)
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

#include "leditdist.hpp"
#include "editdist.hpp"

#include <cassert>

namespace aspeller {
  inline int edit_distance(ParmString a, ParmString b, 
			   int level, // starting level
			   int limit, // maximum level
			   const EditDistanceWeights & w 
			   = EditDistanceWeights()) 
  {
    int score;
    assert(level > 0  && limit >= level);
    do {
      if (level == 2) {
	score = limit2_edit_distance(a,b,w);
      } else if (level < 5) {
	score = limit_edit_distance(a,b,level,w);
      } else {
	score = edit_distance(a,b,w);
      }
      ++level;
    } while (score >= LARGE_NUM && level <= limit);
    return score;
  }
}