From 64093dc2f6f7d8af3dea84f0a1a230297620d4d1 Mon Sep 17 00:00:00 2001 From: Kshitij Bansal Date: Mon, 28 Apr 2014 18:18:24 -0400 Subject: [PATCH] cleanup --- src/util/didyoumean.cpp | 10 +++++----- src/util/didyoumean.h | 6 +++++- src/util/didyoumean_test.cpp | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/util/didyoumean.cpp b/src/util/didyoumean.cpp index d64435ce7..228fe721e 100644 --- a/src/util/didyoumean.cpp +++ b/src/util/didyoumean.cpp @@ -14,15 +14,14 @@ ** ``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 CVC4, intentionally. + ** There are no dependencies on CVC4 (except namespace). **/ #include "didyoumean.h" #include #include -#include -#include using namespace std; +using namespace CVC4; vector DidYouMean::getMatch(string input) { /** Magic numbers */ @@ -31,14 +30,15 @@ vector DidYouMean::getMatch(string input) { set< pair > scores; vector ret; - BOOST_FOREACH(string s, d_words ) { + for(typeof(d_words.begin()) it = d_words.begin(); it != d_words.end(); ++it) { + string s = (*it); if( s == input ) { // if input matches AS-IS just return that ret.push_back(s); return ret; } int score; - if(boost::starts_with(s, input)) { + if(s.compare(0, input.size(), input) == 0) { score = 0; } else { score = editDistance(input, s) + 1; diff --git a/src/util/didyoumean.h b/src/util/didyoumean.h index 2907fcece..18a1101cf 100644 --- a/src/util/didyoumean.h +++ b/src/util/didyoumean.h @@ -14,7 +14,7 @@ ** ``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 CVC4, intentionally. + ** There are no dependencies on CVC4 (except namespace). **/ #pragma once @@ -23,6 +23,8 @@ #include #include +namespace CVC4 { + class DidYouMean { typedef std::set Words; Words d_words; @@ -47,3 +49,5 @@ public: private: int editDistance(const std::string& a, const std::string& b); }; + +}/*CVC4 namespace*/ diff --git a/src/util/didyoumean_test.cpp b/src/util/didyoumean_test.cpp index 5aa7cc105..2fe3331d9 100644 --- a/src/util/didyoumean_test.cpp +++ b/src/util/didyoumean_test.cpp @@ -5,6 +5,7 @@ #include #include using namespace std; +using namespace CVC4; set getDebugTags(); set getOptionStrings(); -- 2.30.2