1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Kshitij Bansal, Tim King |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Did-you-mean style suggestions. |
14 |
|
* |
15 |
|
* ``What do you mean? I don't understand.'' An attempt to be more |
16 |
|
* helpful than that. Similar to one in git. |
17 |
|
* |
18 |
|
* There are no dependencies on cvc5 (except namespace). |
19 |
|
*/ |
20 |
|
|
21 |
|
#pragma once |
22 |
|
|
23 |
|
#include "cvc5_export.h" |
24 |
|
|
25 |
|
#include <set> |
26 |
|
#include <string> |
27 |
|
#include <vector> |
28 |
|
|
29 |
|
namespace cvc5 { |
30 |
|
|
31 |
|
class CVC5_EXPORT DidYouMean { |
32 |
|
public: |
33 |
|
using Words = std::set<std::string>; |
34 |
|
|
35 |
|
DidYouMean() {} |
36 |
|
~DidYouMean() {} |
37 |
|
|
38 |
|
void addWord(std::string word) { d_words.insert(std::move(word)); } |
39 |
|
|
40 |
|
std::vector<std::string> getMatch(const std::string& input); |
41 |
|
|
42 |
|
/** |
43 |
|
* This is provided to make it easier to ensure consistency of |
44 |
|
* output. Returned string is empty if there are no matches. |
45 |
|
*/ |
46 |
|
std::string getMatchAsString(const std::string& input, |
47 |
|
uint64_t prefixNewLines = 2, |
48 |
|
uint64_t suffixNewLines = 0); |
49 |
|
|
50 |
|
private: |
51 |
|
int editDistance(const std::string& a, const std::string& b); |
52 |
|
Words d_words; |
53 |
|
}; |
54 |
|
|
55 |
|
} // namespace cvc5 |