blob: 9188397898e13e604ea4cfbc0cd37e31162fe924 (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "fuzzy_matching_algorithm.h"
namespace vespalib {
namespace {
const vespalib::string brute_force = "brute_force";
const vespalib::string dfa_implicit = "dfa_implicit";
const vespalib::string dfa_explicit = "dfa_explicit";
const vespalib::string dfa_table = "dfa_table";
}
vespalib::string
to_string(FuzzyMatchingAlgorithm algo)
{
switch (algo) {
case FuzzyMatchingAlgorithm::BruteForce:
return brute_force;
case FuzzyMatchingAlgorithm::DfaImplicit:
return dfa_implicit;
case FuzzyMatchingAlgorithm::DfaExplicit:
return dfa_explicit;
case FuzzyMatchingAlgorithm::DfaTable:
return dfa_table;
default:
return "";
}
}
FuzzyMatchingAlgorithm
fuzzy_matching_algorithm_from_string(const vespalib::string& algo,
FuzzyMatchingAlgorithm default_algo)
{
if (algo == brute_force) {
return FuzzyMatchingAlgorithm::BruteForce;
} else if (algo == dfa_implicit) {
return FuzzyMatchingAlgorithm::DfaImplicit;
} else if (algo == dfa_explicit) {
return FuzzyMatchingAlgorithm::DfaExplicit;
} else if (algo == dfa_table) {
return FuzzyMatchingAlgorithm::DfaTable;
}
return default_algo;
}
std::ostream&
operator<<(std::ostream& out, FuzzyMatchingAlgorithm algo)
{
out << to_string(algo);
return out;
}
}
|