diff options
author | Gereon Kremer <nafur42@gmail.com> | 2021-11-01 03:52:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 10:52:55 +0000 |
commit | ffdc8a3676aad41d0fcef0290241aa9df2e5be1b (patch) | |
tree | 8816ea1d63eabedd1722e78915038bef97755232 /src/options/didyoumean.h | |
parent | 47ddb344f317496928dddd4b017867b8c07dbded (diff) |
Refactor DidYouMean (#7535)
This refactors the `DidYouMean` class, which is used to make helpful suggestions for misspelled tags and options. It uses `std::vector` instead of `std::set`, moves it from `options` to `util` (so that we can keep using it in both libcvc5 and the driver) and generally modernizes the code a bit. Also, it replaces the stand-alone and never executed test by a regular unit test.
Diffstat (limited to 'src/options/didyoumean.h')
-rw-r--r-- | src/options/didyoumean.h | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/options/didyoumean.h b/src/options/didyoumean.h deleted file mode 100644 index 0118f1484..000000000 --- a/src/options/didyoumean.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * Top contributors (to current version): - * Kshitij Bansal, Tim King - * - * This file is part of the cvc5 project. - * - * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS - * in the top-level source directory and their institutional affiliations. - * All rights reserved. See the file COPYING in the top-level source - * directory for licensing information. - * **************************************************************************** - * - * Did-you-mean style suggestions. - * - * ``What do you mean? I don't understand.'' An attempt to be more - * helpful than that. Similar to one in git. - * - * There are no dependencies on cvc5 (except namespace). - */ - -#pragma once - -#include "cvc5_export.h" - -#include <set> -#include <string> -#include <vector> - -namespace cvc5 { - -class CVC5_EXPORT DidYouMean { - public: - using Words = std::set<std::string>; - - DidYouMean() {} - ~DidYouMean() {} - - void addWord(std::string word) { d_words.insert(std::move(word)); } - void addWords(const std::vector<std::string>& words) - { - d_words.insert(words.begin(), words.end()); - } - - std::vector<std::string> getMatch(const std::string& input); - - /** - * This is provided to make it easier to ensure consistency of - * output. Returned string is empty if there are no matches. - */ - std::string getMatchAsString(const std::string& input, - uint64_t prefixNewLines = 2, - uint64_t suffixNewLines = 0); - - private: - int editDistance(const std::string& a, const std::string& b); - Words d_words; -}; - -} // namespace cvc5 |