From 0d4bdf12dec000cf2dc8a6318ef18aa8c8ae53f9 Mon Sep 17 00:00:00 2001 From: rjawor Date: Wed, 15 Apr 2015 14:14:10 +0200 Subject: [PATCH] removed using namespace std Former-commit-id: dbb5129e1f94d83eca887ada0f89d6bb45250f1e --- concordia-console/concordia-console.cpp | 6 +- concordia/anubis_search_result.hpp | 2 - concordia/anubis_searcher.cpp | 99 ++++++++++++------------ concordia/anubis_searcher.hpp | 11 ++- concordia/common/text_utils.cpp | 4 +- concordia/common/text_utils.hpp | 7 +- concordia/common/utils.cpp | 16 ++-- concordia/common/utils.hpp | 18 ++--- concordia/concordia.cpp | 21 ++--- concordia/concordia_config.cpp | 8 +- concordia/concordia_config.hpp | 51 ++++++------ concordia/concordia_exception.cpp | 2 +- concordia/concordia_exception.hpp | 8 +- concordia/concordia_index.cpp | 62 +++++++-------- concordia/concordia_index.hpp | 36 ++++----- concordia/example.cpp | 3 +- concordia/example.hpp | 11 ++- concordia/hash_generator.cpp | 23 +++--- concordia/hash_generator.hpp | 8 +- concordia/index_searcher.cpp | 16 ++-- concordia/index_searcher.hpp | 10 +-- concordia/interval.cpp | 7 +- concordia/interval.hpp | 5 +- concordia/regex_replacement.cpp | 7 +- concordia/regex_replacement.hpp | 12 ++- concordia/sentence_anonymizer.cpp | 34 ++++---- concordia/sentence_anonymizer.hpp | 16 ++-- concordia/substring_occurence.cpp | 5 +- concordia/substring_occurence.hpp | 6 +- concordia/t/test_anubis_searcher.cpp | 24 +++--- concordia/t/test_concordia.cpp | 22 +++--- concordia/t/test_concordia_config.cpp | 6 +- concordia/t/test_concordia_index.cpp | 14 ++-- concordia/t/test_example.cpp | 4 +- concordia/t/test_hash_generator.cpp | 27 +++---- concordia/t/test_interval.cpp | 2 - concordia/t/test_logging.cpp | 2 - concordia/t/test_regex_replacement.cpp | 4 +- concordia/t/test_sentence_anonymizer.cpp | 15 ++-- concordia/t/test_text_utils.cpp | 6 +- concordia/t/test_tm_matches.cpp | 2 - concordia/t/test_utils.cpp | 23 +++--- concordia/t/test_word_map.cpp | 4 - concordia/tm_matches.cpp | 4 +- concordia/tm_matches.hpp | 16 ++-- concordia/word_map.cpp | 2 +- concordia/word_map.hpp | 8 +- tests/common/test_resources_manager.cpp | 16 ++-- tests/common/test_resources_manager.hpp | 10 +-- 49 files changed, 333 insertions(+), 392 deletions(-) diff --git a/concordia-console/concordia-console.cpp b/concordia-console/concordia-console.cpp index aaf9e1e..f458583 100644 --- a/concordia-console/concordia-console.cpp +++ b/concordia-console/concordia-console.cpp @@ -84,11 +84,11 @@ int main(int argc, char** argv) { std::string filePath = cli["read-file"].as(); std::cout << "\tReading sentences from file: " << filePath << std::endl; - ifstream text_file(filePath.c_str()); + std::ifstream text_file(filePath.c_str()); std::string line; if (text_file.is_open()) { long lineCount = 0; - vector buffer; + std::vector buffer; boost::posix_time::ptime timeStart = boost::posix_time::microsec_clock::local_time(); while (getline(text_file, line)) { @@ -147,7 +147,7 @@ int main(int argc, char** argv) { << "Terminating execution." << std::endl; return 1; - } catch(exception & e) { + } catch(std::exception & e) { std::cerr << "Unexpected exception caught with message: " << std::endl << e.what() diff --git a/concordia/anubis_search_result.hpp b/concordia/anubis_search_result.hpp index 819ca67..b036ecc 100644 --- a/concordia/anubis_search_result.hpp +++ b/concordia/anubis_search_result.hpp @@ -8,8 +8,6 @@ */ -using namespace std; - class AnubisSearchResult { public: explicit AnubisSearchResult(const SUFFIX_MARKER_TYPE & exampleId, diff --git a/concordia/anubis_searcher.cpp b/concordia/anubis_searcher.cpp index 7aa739f..6896757 100644 --- a/concordia/anubis_searcher.cpp +++ b/concordia/anubis_searcher.cpp @@ -18,8 +18,9 @@ std::vector AnubisSearcher::anubisSearch( boost::shared_ptr > SA, const std::vector & pattern) throw(ConcordiaException) { - boost::shared_ptr tmMatchesMap = getTmMatches(T, markers, SA, pattern); - + boost::shared_ptr tmMatchesMap = + getTmMatches(T, markers, SA, pattern); + // get the tmMatches list sorted descending by score std::vector result; return result; @@ -31,7 +32,6 @@ boost::shared_ptr AnubisSearcher::getTmMatches( boost::shared_ptr > SA, const std::vector & pattern) throw(ConcordiaException) { - std::vector patternVector = Utils::indexVectorToSaucharVector(pattern); @@ -45,7 +45,7 @@ boost::shared_ptr AnubisSearcher::getTmMatches( int highResOffset = offset * sizeof(INDEX_CHARACTER_TYPE); std::vector currentPattern( patternVector.begin()+highResOffset, patternVector.end()); - + saidx_t patternLength = 0; saidx_t size = SA->size(); saidx_t left = 0; @@ -64,8 +64,8 @@ boost::shared_ptr AnubisSearcher::getTmMatches( saidx_t localLeft; size = sa_search(T->data(), (saidx_t) T->size(), - (const sauchar_t *) patternArray, patternLength, - SAleft, size, &localLeft); + (const sauchar_t *) patternArray, patternLength, + SAleft, size, &localLeft); left += localLeft; @@ -75,20 +75,24 @@ boost::shared_ptr AnubisSearcher::getTmMatches( // Add to tm matches map results surrounding the main stream. // from left for (saidx_t i = prevLeft; i < left; i++) { - _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), (patternLength / sizeof(INDEX_CHARACTER_TYPE)) -1, offset); - } + _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), + (patternLength / sizeof(INDEX_CHARACTER_TYPE)) -1, + offset); + } // from right for (saidx_t i = left+size; i < prevLeft+prevSize; i++) { - _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), (patternLength / sizeof(INDEX_CHARACTER_TYPE)) -1, offset); - } - + _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), + (patternLength / sizeof(INDEX_CHARACTER_TYPE)) - 1, + offset); + } } } while (patternLength < currentPattern.size() && size > 0); if (size > 0) { for (saidx_t i = left; i < left+size; i++) { - _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), patternLength / sizeof(INDEX_CHARACTER_TYPE), offset); - } + _addToMap(SA, markers, tmMatchesMap, i, pattern.size(), + patternLength / sizeof(INDEX_CHARACTER_TYPE), offset); + } } } @@ -121,16 +125,16 @@ std::vector AnubisSearcher::lcpSearch( saidx_t localLeft; size = sa_search(T->data(), (saidx_t) T->size(), (const sauchar_t *) patternArray, patternLength, - SAleft, size, &localLeft); + SAleft, size, &localLeft); left += localLeft; SAleft += localLeft; } while (patternLength < pattern.size() && size > 0); - vector result; + std::vector result; if (size == 0) { // The search managed to find exactly the longest common prefixes. - + length = patternLength - sizeof(INDEX_CHARACTER_TYPE); if (length > 0) { // Get the results of the previous search @@ -149,27 +153,28 @@ std::vector AnubisSearcher::lcpSearch( } void AnubisSearcher::_collectResults( - vector & result, + std::vector & result, boost::shared_ptr > markers, boost::shared_ptr > SA, saidx_t left, saidx_t size) { for (saidx_t i = 0; i < size; i++) { saidx_t resultPos = SA->at(left + i); - + if (resultPos % sizeof(INDEX_CHARACTER_TYPE) == 0) { - SUFFIX_MARKER_TYPE marker = markers->at(resultPos / sizeof(INDEX_CHARACTER_TYPE)); + SUFFIX_MARKER_TYPE marker = + markers->at(resultPos / sizeof(INDEX_CHARACTER_TYPE)); result.push_back(SubstringOccurence(marker)); } } } void AnubisSearcher::_addToMap(boost::shared_ptr > SA, - boost::shared_ptr > markers, - boost::shared_ptr tmMatchesMap, - saidx_t sa_pos, - SUFFIX_MARKER_TYPE totalPatternLength, - SUFFIX_MARKER_TYPE matchedFragmentLength, - SUFFIX_MARKER_TYPE patternOffset) { + boost::shared_ptr > markers, + boost::shared_ptr tmMatchesMap, + saidx_t sa_pos, + SUFFIX_MARKER_TYPE totalPatternLength, + SUFFIX_MARKER_TYPE matchedFragmentLength, + SUFFIX_MARKER_TYPE patternOffset) { SubstringOccurence occurence; if (_getOccurenceFromSA(SA, markers, sa_pos, occurence)) { _addOccurenceToMap(tmMatchesMap, @@ -178,24 +183,24 @@ void AnubisSearcher::_addToMap(boost::shared_ptr > SA, matchedFragmentLength, patternOffset); } -} - - -bool AnubisSearcher::_getOccurenceFromSA( - boost::shared_ptr > SA, - boost::shared_ptr > markers, - saidx_t sa_pos, - SubstringOccurence & occurence) { - saidx_t resultPos = SA->at(sa_pos); - - if (resultPos % sizeof(INDEX_CHARACTER_TYPE) == 0) { - SUFFIX_MARKER_TYPE marker = markers->at(resultPos / sizeof(INDEX_CHARACTER_TYPE)); - occurence.enterDataFromMarker(marker); - } - } -void AnubisSearcher::_addOccurenceToMap(boost::shared_ptr tmMatchesMap, +bool AnubisSearcher::_getOccurenceFromSA( + boost::shared_ptr > SA, + boost::shared_ptr > markers, + saidx_t sa_pos, + SubstringOccurence & occurence) { + saidx_t resultPos = SA->at(sa_pos); + + if (resultPos % sizeof(INDEX_CHARACTER_TYPE) == 0) { + SUFFIX_MARKER_TYPE marker = + markers->at(resultPos / sizeof(INDEX_CHARACTER_TYPE)); + occurence.enterDataFromMarker(marker); + } +} + +void AnubisSearcher::_addOccurenceToMap( + boost::shared_ptr tmMatchesMap, SubstringOccurence & occurence, SUFFIX_MARKER_TYPE totalPatternLength, SUFFIX_MARKER_TYPE matchedFragmentLength, @@ -213,16 +218,12 @@ void AnubisSearcher::_addOccurenceToMap(boost::shared_ptr tmMatche SUFFIX_MARKER_TYPE key = occurence.getId(); tmMatchesMap->insert(key, tmMatches); } - + // add intervals to tmMatches tmMatches->addExampleInterval( - occurence.getOffset(), - occurence.getOffset() + matchedFragmentLength - ); + occurence.getOffset(), + occurence.getOffset() + matchedFragmentLength); tmMatches->addPatternInterval( patternOffset, - patternOffset + matchedFragmentLength - ); - + patternOffset + matchedFragmentLength); } - diff --git a/concordia/anubis_searcher.hpp b/concordia/anubis_searcher.hpp index ef2a58a..72df7a4 100644 --- a/concordia/anubis_searcher.hpp +++ b/concordia/anubis_searcher.hpp @@ -10,6 +10,7 @@ #include "concordia/anubis_search_result.hpp" #include "concordia/tm_matches.hpp" +#include #include /*! @@ -17,8 +18,6 @@ */ -using namespace std; - class AnubisSearcher { public: explicit AnubisSearcher(); @@ -49,7 +48,7 @@ public: SUFFIX_MARKER_TYPE & length) throw(ConcordiaException); private: - void _collectResults(vector & result, + void _collectResults(std::vector & result, boost::shared_ptr > markers, boost::shared_ptr > SA, saidx_t left, saidx_t size); @@ -63,9 +62,9 @@ private: SUFFIX_MARKER_TYPE patternOffset); bool _getOccurenceFromSA(boost::shared_ptr > SA, - boost::shared_ptr > markers, - saidx_t sa_pos, - SubstringOccurence & occurence); + boost::shared_ptr > markers, + saidx_t sa_pos, + SubstringOccurence & occurence); void _addOccurenceToMap(boost::shared_ptr tmMatchesMap, SubstringOccurence & occurence, diff --git a/concordia/common/text_utils.cpp b/concordia/common/text_utils.cpp index b51c2f1..c7704bd 100644 --- a/concordia/common/text_utils.cpp +++ b/concordia/common/text_utils.cpp @@ -10,10 +10,10 @@ TextUtils::TextUtils() { StringCaseConverterManager::getInstance().getUpperCaseConverter("pl"); } -string TextUtils::toLowerCase(const string & text) { +std::string TextUtils::toLowerCase(const std::string & text) { return simpleConvert(*_lowerConverter, text); } -string TextUtils::toUpperCase(const string & text) { +std::string TextUtils::toUpperCase(const std::string & text) { return simpleConvert(*_upperConverter, text); } diff --git a/concordia/common/text_utils.hpp b/concordia/common/text_utils.hpp index a061abd..98d0087 100644 --- a/concordia/common/text_utils.hpp +++ b/concordia/common/text_utils.hpp @@ -7,9 +7,6 @@ #include "utf8case/case_converter_factory.hpp" #include "utf8case/string_case_converter_manager.hpp" - -using namespace std; - /*! Utility class for performing simple string operations. */ class TextUtils { @@ -26,13 +23,13 @@ public: \param text input string \returns lower case version of the input string. */ - string toLowerCase(const string & text); + std::string toLowerCase(const std::string & text); /*! A method for converting all string letters to upper case. \param text input string \returns upper case version of the input string. */ - string toUpperCase(const string & text); + std::string toUpperCase(const std::string & text); private: explicit TextUtils(TextUtils const&); // Don't Implement diff --git a/concordia/common/utils.cpp b/concordia/common/utils.cpp index 6d30008..7b38494 100644 --- a/concordia/common/utils.cpp +++ b/concordia/common/utils.cpp @@ -7,35 +7,35 @@ Utils::Utils() { Utils::~Utils() { } -void Utils::writeIndexCharacter(ofstream & file, +void Utils::writeIndexCharacter(std::ofstream & file, INDEX_CHARACTER_TYPE character) { file.write(reinterpret_cast(&character), sizeof(character)); } -void Utils::writeMarker(ofstream & file, +void Utils::writeMarker(std::ofstream & file, SUFFIX_MARKER_TYPE marker) { file.write(reinterpret_cast(&marker), sizeof(marker)); } -INDEX_CHARACTER_TYPE Utils::readIndexCharacter(ifstream & file) { +INDEX_CHARACTER_TYPE Utils::readIndexCharacter(std::ifstream & file) { INDEX_CHARACTER_TYPE character; file.read(reinterpret_cast(&character), sizeof(character)); return character; } -SUFFIX_MARKER_TYPE Utils::readMarker(ifstream & file) { +SUFFIX_MARKER_TYPE Utils::readMarker(std::ifstream & file) { SUFFIX_MARKER_TYPE marker; file.read(reinterpret_cast(&marker), sizeof(marker)); return marker; } sauchar_t * Utils::indexVectorToSaucharArray( - const vector & input) { + const std::vector & input) { const int kArraySize = input.size()*sizeof(INDEX_CHARACTER_TYPE); sauchar_t * patternArray = new sauchar_t[kArraySize]; int pos = 0; - for (vector::const_iterator it = input.begin(); + for (std::vector::const_iterator it = input.begin(); it != input.end(); ++it) { _insertCharToSaucharArray(patternArray, *it, pos); pos += sizeof(INDEX_CHARACTER_TYPE); @@ -44,9 +44,9 @@ sauchar_t * Utils::indexVectorToSaucharArray( } std::vector Utils::indexVectorToSaucharVector( - const vector & input) { + const std::vector & input) { std::vector result; - for (vector::const_iterator it = input.begin(); + for (std::vector::const_iterator it = input.begin(); it != input.end(); ++it) { appendCharToSaucharVector(result, *it); } diff --git a/concordia/common/utils.hpp b/concordia/common/utils.hpp index 9175a60..8803a4d 100644 --- a/concordia/common/utils.hpp +++ b/concordia/common/utils.hpp @@ -11,8 +11,6 @@ #include "concordia/concordia_exception.hpp" #include -using namespace std; - class Utils { public: explicit Utils(); @@ -21,21 +19,21 @@ public: */ virtual ~Utils(); - static void writeIndexCharacter(ofstream & file, + static void writeIndexCharacter(std::ofstream & file, INDEX_CHARACTER_TYPE character); - static void writeMarker(ofstream & file, + static void writeMarker(std::ofstream & file, SUFFIX_MARKER_TYPE marker); - static INDEX_CHARACTER_TYPE readIndexCharacter(ifstream & file); + static INDEX_CHARACTER_TYPE readIndexCharacter(std::ifstream & file); - static SUFFIX_MARKER_TYPE readMarker(ifstream & file); + static SUFFIX_MARKER_TYPE readMarker(std::ifstream & file); static sauchar_t * indexVectorToSaucharArray( - const vector & input); + const std::vector & input); static std::vector indexVectorToSaucharVector( - const vector & input); + const std::vector & input); static void appendCharToSaucharVector( boost::shared_ptr > vector, @@ -70,8 +68,8 @@ private: template void Utils::printVector(const std::vector & vector) { for (int i = 0; i < vector.size(); i++) { - cout << static_cast(vector.at(i)) << " "; + std::cout << static_cast(vector.at(i)) << " "; } - cout << endl; + std::cout << std::endl; } #endif diff --git a/concordia/concordia.cpp b/concordia/concordia.cpp index d07338d..976d21c 100644 --- a/concordia/concordia.cpp +++ b/concordia/concordia.cpp @@ -62,12 +62,13 @@ void Concordia::loadRAMIndexFromDisk() throw(ConcordiaException) { && boost::filesystem::exists(_config->getMarkersFilePath())) { // reading index from file _T->clear(); - ifstream hashedIndexFile; - hashedIndexFile.open(_config->getHashedIndexFilePath().c_str(), ios::in - | ios::ate | ios::binary); + std::ifstream hashedIndexFile; + hashedIndexFile.open( + _config->getHashedIndexFilePath().c_str(), std::ios::in + | std::ios::ate | std::ios::binary); saidx_t hiFileSize = hashedIndexFile.tellg(); if (hiFileSize > 0) { - hashedIndexFile.seekg(0, ios::beg); + hashedIndexFile.seekg(0, std::ios::beg); while (!hashedIndexFile.eof()) { INDEX_CHARACTER_TYPE character = @@ -82,12 +83,12 @@ void Concordia::loadRAMIndexFromDisk() throw(ConcordiaException) { // reading markers from file _markers->clear(); - ifstream markersFile; - markersFile.open(_config->getMarkersFilePath().c_str(), ios::in - | ios::ate | ios::binary); + std::ifstream markersFile; + markersFile.open(_config->getMarkersFilePath().c_str(), std::ios::in + | std::ios::ate | std::ios::binary); saidx_t maFileSize = markersFile.tellg(); if (maFileSize > 0) { - markersFile.seekg(0, ios::beg); + markersFile.seekg(0, std::ios::beg); while (!markersFile.eof()) { SUFFIX_MARKER_TYPE marker = @@ -132,7 +133,7 @@ void Concordia::_initializeIndex() throw(ConcordiaException) { } std::vector Concordia::simpleSearch( - const string & pattern) + const std::string & pattern) throw(ConcordiaException) { if (_T->size() > 0) { return _searcher->simpleSearch(_hashGenerator, _T, @@ -144,7 +145,7 @@ std::vector Concordia::simpleSearch( } std::vector Concordia::anubisSearch( - const string & pattern) + const std::string & pattern) throw(ConcordiaException) { if (_T->size() > 0) { return _searcher->anubisSearch(_hashGenerator, _T, diff --git a/concordia/concordia_config.cpp b/concordia/concordia_config.cpp index 97b55d6..a60d42c 100644 --- a/concordia/concordia_config.cpp +++ b/concordia/concordia_config.cpp @@ -13,13 +13,13 @@ #define NAMED_ENTITIES_PARAM "named_entities_path" #define STOP_SYMBOLS_PARAM "stop_symbols_path" -ConcordiaConfig::ConcordiaConfig(const string & configFilePath) +ConcordiaConfig::ConcordiaConfig(const std::string & configFilePath) throw(ConcordiaException) { try { _config.readFile(configFilePath.c_str()); - } catch(ParseException & e) { + } catch(libconfig::ParseException & e) { throw ConcordiaException("Error parsing config file: "+configFilePath); - } catch(FileIOException & e) { + } catch(libconfig::FileIOException & e) { throw ConcordiaException("I/O error reading config file: " +configFilePath); } @@ -49,7 +49,7 @@ ConcordiaConfig::ConcordiaConfig(const string & configFilePath) ConcordiaConfig::~ConcordiaConfig() { } -string ConcordiaConfig::_readConfigParameterStr(const string & name) +std::string ConcordiaConfig::_readConfigParameterStr(const std::string & name) throw(ConcordiaException) { if (!_config.exists(name)) { throw ConcordiaException("Config error: "+name+" setting not found"); diff --git a/concordia/concordia_config.hpp b/concordia/concordia_config.hpp index 9850f37..b8cebea 100644 --- a/concordia/concordia_config.hpp +++ b/concordia/concordia_config.hpp @@ -7,9 +7,6 @@ #include "concordia/concordia_exception.hpp" -using namespace std; -using namespace libconfig; - /*! Class representing the Concordia configuration. */ @@ -20,8 +17,8 @@ public: \param configFilePath path of the configuration file (see \ref running3 for file specification). \throws ConcordiaException */ - explicit ConcordiaConfig(const string & configFilePath) - throw(ConcordiaException); + explicit ConcordiaConfig(const std::string & configFilePath) + throw(ConcordiaException); /*! Destructor. */ @@ -30,70 +27,70 @@ public: /*! Getter for the puddle file path parameter. \returns file path of the puddle tagset */ - string & getPuddleTagsetFilePath() { + std::string & getPuddleTagsetFilePath() { return _puddleTagsetFilePath; } - string & getWordMapFilePath() { + std::string & getWordMapFilePath() { return _wordMapFilePath; } - string & getHashedIndexFilePath() { + std::string & getHashedIndexFilePath() { return _hashedIndexFilePath; } - string & getMarkersFilePath() { + std::string & getMarkersFilePath() { return _markersFilePath; } - string & getSuffixArrayFilePath() { + std::string & getSuffixArrayFilePath() { return _suffixArrayFilePath; } - string & getHtmlTagsFilePath() { + std::string & getHtmlTagsFilePath() { return _htmlTagsFilePath; } - string & getSpaceSymbolsFilePath() { + std::string & getSpaceSymbolsFilePath() { return _spaceSymbolsFilePath; } - string & getStopWordsFilePath() { + std::string & getStopWordsFilePath() { return _stopWordsFilePath; } - string & getNamedEntitiesFilePath() { + std::string & getNamedEntitiesFilePath() { return _namedEntitiesFilePath; } - string & getStopSymbolsFilePath() { + std::string & getStopSymbolsFilePath() { return _stopSymbolsFilePath; } private: - Config _config; + libconfig::Config _config; - string _puddleTagsetFilePath; + std::string _puddleTagsetFilePath; - string _wordMapFilePath; + std::string _wordMapFilePath; - string _hashedIndexFilePath; + std::string _hashedIndexFilePath; - string _markersFilePath; + std::string _markersFilePath; - string _suffixArrayFilePath; + std::string _suffixArrayFilePath; - string _htmlTagsFilePath; + std::string _htmlTagsFilePath; - string _spaceSymbolsFilePath; + std::string _spaceSymbolsFilePath; - string _stopWordsFilePath; + std::string _stopWordsFilePath; - string _namedEntitiesFilePath; + std::string _namedEntitiesFilePath; - string _stopSymbolsFilePath; + std::string _stopSymbolsFilePath; - string _readConfigParameterStr(const string & name) + std::string _readConfigParameterStr(const std::string & name) throw(ConcordiaException); }; diff --git a/concordia/concordia_exception.cpp b/concordia/concordia_exception.cpp index 45c8610..26251cb 100644 --- a/concordia/concordia_exception.cpp +++ b/concordia/concordia_exception.cpp @@ -4,7 +4,7 @@ ConcordiaException::ConcordiaException() throw(): _message("Concordia exception") { } -ConcordiaException::ConcordiaException(const string & message) throw(): +ConcordiaException::ConcordiaException(const std::string & message) throw(): _message(message) { } diff --git a/concordia/concordia_exception.hpp b/concordia/concordia_exception.hpp index dcffb3a..b94e281 100644 --- a/concordia/concordia_exception.hpp +++ b/concordia/concordia_exception.hpp @@ -5,12 +5,10 @@ #include #include -using namespace std; - /*! Class representing an internal exception thrown in the Concordia library. */ -class ConcordiaException : public exception { +class ConcordiaException : public std::exception { public: /*! Constructor. */ @@ -19,7 +17,7 @@ public: /*! Constructor with a message. \param message message of the exception */ - explicit ConcordiaException(const string & message) throw(); + explicit ConcordiaException(const std::string & message) throw(); /*! Destructor. */ @@ -30,7 +28,7 @@ public: virtual const char* what() const throw(); private: - string _message; + std::string _message; }; #endif diff --git a/concordia/concordia_index.cpp b/concordia/concordia_index.cpp index ca3254a..339d275 100644 --- a/concordia/concordia_index.cpp +++ b/concordia/concordia_index.cpp @@ -7,8 +7,8 @@ #include #include -ConcordiaIndex::ConcordiaIndex(const string & hashedIndexFilePath, - const string & markersFilePath) +ConcordiaIndex::ConcordiaIndex(const std::string & hashedIndexFilePath, + const std::string & markersFilePath) throw(ConcordiaException) : _hashedIndexFilePath(hashedIndexFilePath), _markersFilePath(markersFilePath) { @@ -17,15 +17,15 @@ ConcordiaIndex::ConcordiaIndex(const string & hashedIndexFilePath, ConcordiaIndex::~ConcordiaIndex() { } -boost::shared_ptr > ConcordiaIndex::generateSuffixArray( - boost::shared_ptr > T) { +boost::shared_ptr > ConcordiaIndex::generateSuffixArray( + boost::shared_ptr > T) { saidx_t * SA_array = new saidx_t[T->size()]; if (divsufsort(T->data(), SA_array, (saidx_t) T->size()) != 0) { throw ConcordiaException("Error creating suffix array."); } - boost::shared_ptr > result = - boost::shared_ptr >(new vector); + boost::shared_ptr > result = + boost::shared_ptr >(new std::vector); for (int i = 0; i < T->size(); i++) { result->push_back(SA_array[i]); } @@ -36,15 +36,15 @@ boost::shared_ptr > ConcordiaIndex::generateSuffixArray( void ConcordiaIndex::addExample( boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, + boost::shared_ptr > T, + boost::shared_ptr > markers, const Example & example) { - ofstream hashedIndexFile; - hashedIndexFile.open(_hashedIndexFilePath.c_str(), ios::out| - ios::app|ios::binary); - ofstream markersFile; - markersFile.open(_markersFilePath.c_str(), ios::out| - ios::app|ios::binary); + std::ofstream hashedIndexFile; + hashedIndexFile.open(_hashedIndexFilePath.c_str(), std::ios::out| + std::ios::app|std::ios::binary); + std::ofstream markersFile; + markersFile.open(_markersFilePath.c_str(), std::ios::out| + std::ios::app|std::ios::binary); _addSingleExample(hashedIndexFile, markersFile, hashGenerator, T, markers, example); hashedIndexFile.close(); @@ -54,15 +54,15 @@ void ConcordiaIndex::addExample( void ConcordiaIndex::addAllExamples( boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, - const vector & examples) { - ofstream hashedIndexFile; - hashedIndexFile.open(_hashedIndexFilePath.c_str(), ios::out| - ios::app|ios::binary); - ofstream markersFile; - markersFile.open(_markersFilePath.c_str(), ios::out| - ios::app|ios::binary); + boost::shared_ptr > T, + boost::shared_ptr > markers, + const std::vector & examples) { + std::ofstream hashedIndexFile; + hashedIndexFile.open(_hashedIndexFilePath.c_str(), std::ios::out| + std::ios::app|std::ios::binary); + std::ofstream markersFile; + markersFile.open(_markersFilePath.c_str(), std::ios::out| + std::ios::app|std::ios::binary); BOOST_FOREACH(Example example, examples) { _addSingleExample(hashedIndexFile, markersFile, hashGenerator, @@ -75,16 +75,16 @@ void ConcordiaIndex::addAllExamples( } void ConcordiaIndex::_addSingleExample( - ofstream & hashedIndexFile, - ofstream & markersFile, - boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, - const Example & example) { - vector hash + std::ofstream & hashedIndexFile, + std::ofstream & markersFile, + boost::shared_ptr hashGenerator, + boost::shared_ptr > T, + boost::shared_ptr > markers, + const Example & example) { + std::vector hash = hashGenerator->generateHash(example.getSentence()); int offset = 0; - for (vector::iterator it = hash.begin(); + for (std::vector::iterator it = hash.begin(); it != hash.end(); ++it) { INDEX_CHARACTER_TYPE character = *it; Utils::writeIndexCharacter(hashedIndexFile, character); diff --git a/concordia/concordia_index.hpp b/concordia/concordia_index.hpp index d6bb412..dc15bd2 100644 --- a/concordia/concordia_index.hpp +++ b/concordia/concordia_index.hpp @@ -18,12 +18,10 @@ */ -using namespace std; - class ConcordiaIndex { public: - explicit ConcordiaIndex(const string & hashedIndexFilePath, - const string & markersFilePath) + explicit ConcordiaIndex(const std::string & hashedIndexFilePath, + const std::string & markersFilePath) throw(ConcordiaException); /*! Destructor. @@ -32,31 +30,31 @@ public: void addExample( boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, + boost::shared_ptr > T, + boost::shared_ptr > markers, const Example & example); void addAllExamples( boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, - const vector & examples); + boost::shared_ptr > T, + boost::shared_ptr > markers, + const std::vector & examples); - boost::shared_ptr > generateSuffixArray( - boost::shared_ptr > T); + boost::shared_ptr > generateSuffixArray( + boost::shared_ptr > T); private: // Add example to disk index and update RAM index. - void _addSingleExample(ofstream & hashedIndexFile, - ofstream & markersFile, - boost::shared_ptr hashGenerator, - boost::shared_ptr > T, - boost::shared_ptr > markers, - const Example & example); + void _addSingleExample(std::ofstream & hashedIndexFile, + std::ofstream & markersFile, + boost::shared_ptr hashGenerator, + boost::shared_ptr > T, + boost::shared_ptr > markers, + const Example & example); - string _hashedIndexFilePath; + std::string _hashedIndexFilePath; - string _markersFilePath; + std::string _markersFilePath; }; #endif diff --git a/concordia/example.cpp b/concordia/example.cpp index f080df4..535299f 100644 --- a/concordia/example.cpp +++ b/concordia/example.cpp @@ -1,8 +1,7 @@ #include "concordia/example.hpp" #include -#include -Example::Example(const string & sentence, const SUFFIX_MARKER_TYPE & id) +Example::Example(const std::string & sentence, const SUFFIX_MARKER_TYPE & id) throw(ConcordiaException): _sentence(sentence), _id(id) { diff --git a/concordia/example.hpp b/concordia/example.hpp index 73a1850..54d70ff 100644 --- a/concordia/example.hpp +++ b/concordia/example.hpp @@ -10,18 +10,17 @@ */ -using namespace std; - class Example { public: - explicit Example(const string & sentence, const SUFFIX_MARKER_TYPE & id) - throw(ConcordiaException); + explicit Example(const std::string & sentence, + const SUFFIX_MARKER_TYPE & id) + throw(ConcordiaException); /*! Destructor. */ virtual ~Example(); - string getSentence() const { + std::string getSentence() const { return _sentence; } @@ -30,7 +29,7 @@ public: } private: - string _sentence; + std::string _sentence; SUFFIX_MARKER_TYPE _id; }; diff --git a/concordia/hash_generator.cpp b/concordia/hash_generator.cpp index 9317e24..cdb33b1 100644 --- a/concordia/hash_generator.cpp +++ b/concordia/hash_generator.cpp @@ -15,7 +15,7 @@ HashGenerator::HashGenerator(boost::shared_ptr config) _sentenceAnonymizer(boost::shared_ptr( new SentenceAnonymizer(config))) { if (boost::filesystem::exists(_wordMapFilePath)) { - ifstream ifs(_wordMapFilePath.c_str(), std::ios::binary); + std::ifstream ifs(_wordMapFilePath.c_str(), std::ios::binary); boost::archive::binary_iarchive ia(ifs); boost::shared_ptr restoredWordMap(new WordMap); ia >> *_wordMap; @@ -25,16 +25,16 @@ HashGenerator::HashGenerator(boost::shared_ptr config) HashGenerator::~HashGenerator() { } -vector HashGenerator::generateHash( - const string & sentence) throw(ConcordiaException) { - vector result; - vector tokenTexts = generateTokenVector(sentence); +std::vector HashGenerator::generateHash( + const std::string & sentence) throw(ConcordiaException) { + std::vector result; + std::vector tokenTexts = generateTokenVector(sentence); if (tokenTexts.size() > Utils::maxSentenceSize) { throw ConcordiaException("Trying to add too long sentence."); } - for (vector::iterator it = tokenTexts.begin(); + for (std::vector::iterator it = tokenTexts.begin(); it != tokenTexts.end(); ++it) { - string token = *it; + std::string token = *it; INDEX_CHARACTER_TYPE code = _wordMap->getWordCode(token); result.push_back(code); } @@ -42,10 +42,11 @@ vector HashGenerator::generateHash( return result; } -vector HashGenerator::generateTokenVector(const string & sentence) { - string anonymizedSentence = _sentenceAnonymizer->anonymize(sentence); +std::vector HashGenerator::generateTokenVector( + const std::string & sentence) { + std::string anonymizedSentence = _sentenceAnonymizer->anonymize(sentence); boost::trim(anonymizedSentence); - vector tokenTexts; + std::vector tokenTexts; boost::split(tokenTexts, anonymizedSentence, boost::is_any_of(" \t\r\n"), boost::algorithm::token_compress_on); return tokenTexts; @@ -53,7 +54,7 @@ vector HashGenerator::generateTokenVector(const string & sentence) { void HashGenerator::serializeWordMap() { - ofstream ofs(_wordMapFilePath.c_str(), std::ios::binary); + std::ofstream ofs(_wordMapFilePath.c_str(), std::ios::binary); boost::archive::binary_oarchive oa(ofs); oa << *_wordMap; } diff --git a/concordia/hash_generator.hpp b/concordia/hash_generator.hpp index ad041c7..e1497ce 100644 --- a/concordia/hash_generator.hpp +++ b/concordia/hash_generator.hpp @@ -18,8 +18,6 @@ */ -using namespace std; - class HashGenerator { public: explicit HashGenerator(boost::shared_ptr config) @@ -29,10 +27,10 @@ public: */ virtual ~HashGenerator(); - vector generateHash(const string & sentence) + std::vector generateHash(const std::string & sentence) throw(ConcordiaException); - vector generateTokenVector(const string & sentence); + std::vector generateTokenVector(const std::string & sentence); void serializeWordMap(); @@ -41,7 +39,7 @@ private: boost::shared_ptr _sentenceAnonymizer; - string _wordMapFilePath; + std::string _wordMapFilePath; }; #endif diff --git a/concordia/index_searcher.cpp b/concordia/index_searcher.cpp index 685a876..f277a96 100644 --- a/concordia/index_searcher.cpp +++ b/concordia/index_searcher.cpp @@ -12,16 +12,17 @@ IndexSearcher::IndexSearcher() { IndexSearcher::~IndexSearcher() { } -vector IndexSearcher::simpleSearch( +std::vector IndexSearcher::simpleSearch( boost::shared_ptr hashGenerator, boost::shared_ptr > T, boost::shared_ptr > markers, boost::shared_ptr > SA, - const string & pattern) throw(ConcordiaException) { - vector result; + const std::string & pattern) throw(ConcordiaException) { + std::vector result; int left; - vector hash = hashGenerator->generateHash(pattern); + std::vector hash = + hashGenerator->generateHash(pattern); saidx_t patternLength = hash.size()*sizeof(INDEX_CHARACTER_TYPE); sauchar_t * patternArray = Utils::indexVectorToSaucharArray(hash); @@ -47,12 +48,13 @@ vector IndexSearcher::simpleSearch( return result; } -vector IndexSearcher::anubisSearch( +std::vector IndexSearcher::anubisSearch( boost::shared_ptr hashGenerator, boost::shared_ptr > T, boost::shared_ptr > markers, boost::shared_ptr > SA, - const string & pattern) throw(ConcordiaException) { - vector hash = hashGenerator->generateHash(pattern); + const std::string & pattern) throw(ConcordiaException) { + std::vector hash = + hashGenerator->generateHash(pattern); return _anubisSearcher->anubisSearch(T, markers, SA, hash); } diff --git a/concordia/index_searcher.hpp b/concordia/index_searcher.hpp index 4e1331d..5fdcbad 100644 --- a/concordia/index_searcher.hpp +++ b/concordia/index_searcher.hpp @@ -20,8 +20,6 @@ */ -using namespace std; - class IndexSearcher { public: explicit IndexSearcher(); @@ -30,19 +28,19 @@ public: */ virtual ~IndexSearcher(); - vector simpleSearch( + std::vector simpleSearch( boost::shared_ptr hashGenerator, boost::shared_ptr > T, boost::shared_ptr > markers, boost::shared_ptr > SA, - const string & pattern) throw(ConcordiaException); + const std::string & pattern) throw(ConcordiaException); - vector anubisSearch( + std::vector anubisSearch( boost::shared_ptr hashGenerator, boost::shared_ptr > T, boost::shared_ptr > markers, boost::shared_ptr > SA, - const string & pattern) throw(ConcordiaException); + const std::string & pattern) throw(ConcordiaException); private: boost::shared_ptr _anubisSearcher; }; diff --git a/concordia/interval.cpp b/concordia/interval.cpp index 9621169..d23e395 100644 --- a/concordia/interval.cpp +++ b/concordia/interval.cpp @@ -1,9 +1,10 @@ #include "concordia/interval.hpp" -Interval::Interval(const SUFFIX_MARKER_TYPE start, const SUFFIX_MARKER_TYPE end): - _start(start), - _end(end) { +Interval::Interval(const SUFFIX_MARKER_TYPE start, + const SUFFIX_MARKER_TYPE end): + _start(start), + _end(end) { } Interval::~Interval() { diff --git a/concordia/interval.hpp b/concordia/interval.hpp index e767022..704bf4f 100644 --- a/concordia/interval.hpp +++ b/concordia/interval.hpp @@ -8,11 +8,10 @@ */ -using namespace std; - class Interval { public: - explicit Interval(const SUFFIX_MARKER_TYPE start, const SUFFIX_MARKER_TYPE end); + explicit Interval(const SUFFIX_MARKER_TYPE start, + const SUFFIX_MARKER_TYPE end); /*! Destructor. */ diff --git a/concordia/regex_replacement.cpp b/concordia/regex_replacement.cpp index 1e37197..37f5914 100644 --- a/concordia/regex_replacement.cpp +++ b/concordia/regex_replacement.cpp @@ -3,7 +3,8 @@ #include #include -RegexReplacement::RegexReplacement(string patternString, string replacement, +RegexReplacement::RegexReplacement(std::string patternString, + std::string replacement, bool caseSensitive) throw(ConcordiaException): _replacement(replacement) { @@ -15,7 +16,7 @@ RegexReplacement::RegexReplacement(string patternString, string replacement, boost::regex::icase); } } catch(const std::exception & e) { - stringstream ss; + std::stringstream ss; ss << "Bad regex pattern: " << patternString << " Detailed info: " << e.what(); @@ -31,7 +32,7 @@ RegexReplacement::RegexReplacement(string patternString, string replacement, RegexReplacement::~RegexReplacement() { } -string RegexReplacement::apply(const string & text) { +std::string RegexReplacement::apply(const std::string & text) { try { return boost::u32regex_replace(text, _pattern, _replacement, boost::match_default | boost::format_all); diff --git a/concordia/regex_replacement.hpp b/concordia/regex_replacement.hpp index 773a543..21bc173 100644 --- a/concordia/regex_replacement.hpp +++ b/concordia/regex_replacement.hpp @@ -14,26 +14,24 @@ */ -using namespace std; - typedef boost::error_info my_tag_error_info; class RegexReplacement { public: - RegexReplacement(string patternString, string replacement, - bool caseSensitive = true) - throw(ConcordiaException); + RegexReplacement(std::string patternString, std::string replacement, + bool caseSensitive = true) + throw(ConcordiaException); /*! Destructor. */ virtual ~RegexReplacement(); - string apply(const string & text); + std::string apply(const std::string & text); private: boost::u32regex _pattern; - string _replacement; + std::string _replacement; }; #endif diff --git a/concordia/sentence_anonymizer.cpp b/concordia/sentence_anonymizer.cpp index f6d6067..f356d8b 100644 --- a/concordia/sentence_anonymizer.cpp +++ b/concordia/sentence_anonymizer.cpp @@ -23,8 +23,8 @@ SentenceAnonymizer::SentenceAnonymizer( SentenceAnonymizer::~SentenceAnonymizer() { } -string SentenceAnonymizer::anonymize(const string & sentence) { - string result = sentence; +std::string SentenceAnonymizer::anonymize(const std::string & sentence) { + std::string result = sentence; result = _htmlTags->apply(result); @@ -41,20 +41,20 @@ string SentenceAnonymizer::anonymize(const string & sentence) { return result; } -void SentenceAnonymizer::_createNeRules(string & namedEntitiesPath) { +void SentenceAnonymizer::_createNeRules(std::string & namedEntitiesPath) { if (boost::filesystem::exists(namedEntitiesPath)) { - string line; - ifstream neFile(namedEntitiesPath.c_str()); + std::string line; + std::ifstream neFile(namedEntitiesPath.c_str()); if (neFile.is_open()) { int lineCounter = 0; while (getline(neFile, line)) { lineCounter++; - boost::shared_ptr > - tokenTexts(new vector()); + boost::shared_ptr > + tokenTexts(new std::vector()); boost::split(*tokenTexts, line, boost::is_any_of(" "), boost::token_compress_on); if (tokenTexts->size() != 2) { - stringstream ss; + std::stringstream ss; ss << "Invalid line: " << lineCounter << " in NE file: " << namedEntitiesPath; throw ConcordiaException(ss.str()); @@ -72,11 +72,11 @@ void SentenceAnonymizer::_createNeRules(string & namedEntitiesPath) { } } -void SentenceAnonymizer::_createHtmlTagsRule(string & htmlTagsPath) { - string tagsExpression = "<\\/?("; +void SentenceAnonymizer::_createHtmlTagsRule(std::string & htmlTagsPath) { + std::string tagsExpression = "<\\/?("; if (boost::filesystem::exists(htmlTagsPath)) { - string line; - ifstream tagsFile(htmlTagsPath.c_str()); + std::string line; + std::ifstream tagsFile(htmlTagsPath.c_str()); if (tagsFile.is_open()) { while (getline(tagsFile, line)) { tagsExpression += "|"; @@ -95,12 +95,12 @@ void SentenceAnonymizer::_createHtmlTagsRule(string & htmlTagsPath) { } boost::shared_ptr - SentenceAnonymizer::_getMultipleReplacementRule( - string & filePath, string replacement, bool wholeWord) { - string expression = "("; + SentenceAnonymizer::_getMultipleReplacementRule( + std::string & filePath, std::string replacement, bool wholeWord) { + std::string expression = "("; if (boost::filesystem::exists(filePath)) { - string line; - ifstream ruleFile(filePath.c_str()); + std::string line; + std::ifstream ruleFile(filePath.c_str()); if (ruleFile.is_open()) { while (getline(ruleFile, line)) { if (wholeWord) { diff --git a/concordia/sentence_anonymizer.hpp b/concordia/sentence_anonymizer.hpp index edd1ef8..bfa3992 100644 --- a/concordia/sentence_anonymizer.hpp +++ b/concordia/sentence_anonymizer.hpp @@ -16,8 +16,6 @@ */ -using namespace std; - class SentenceAnonymizer { public: explicit SentenceAnonymizer(boost::shared_ptr config) @@ -27,19 +25,19 @@ public: */ virtual ~SentenceAnonymizer(); - string anonymize(const string & sentence); + std::string anonymize(const std::string & sentence); private: - void _createNeRules(string & namedEntitiesPath); + void _createNeRules(std::string & namedEntitiesPath); - void _createHtmlTagsRule(string & htmlTagsPath); + void _createHtmlTagsRule(std::string & htmlTagsPath); boost::shared_ptr _getMultipleReplacementRule( - string & filePath, - string replacement, - bool wholeWord = false); + std::string & filePath, + std::string replacement, + bool wholeWord = false); - vector _namedEntities; + std::vector _namedEntities; boost::shared_ptr _htmlTags; diff --git a/concordia/substring_occurence.cpp b/concordia/substring_occurence.cpp index 1ed0fb0..49ea211 100644 --- a/concordia/substring_occurence.cpp +++ b/concordia/substring_occurence.cpp @@ -7,10 +7,11 @@ SubstringOccurence::SubstringOccurence() { SubstringOccurence::SubstringOccurence(const SUFFIX_MARKER_TYPE & marker) { _id = Utils::getIdFromMarker(marker); _offset = Utils::getOffsetFromMarker(marker); - _exampleLength = Utils::getLengthFromMarker(marker); + _exampleLength = Utils::getLengthFromMarker(marker); } -void SubstringOccurence::enterDataFromMarker(const SUFFIX_MARKER_TYPE & marker) { +void SubstringOccurence::enterDataFromMarker( + const SUFFIX_MARKER_TYPE & marker) { _id = Utils::getIdFromMarker(marker); _offset = Utils::getOffsetFromMarker(marker); _exampleLength = Utils::getLengthFromMarker(marker); diff --git a/concordia/substring_occurence.hpp b/concordia/substring_occurence.hpp index e1711f7..09440fa 100644 --- a/concordia/substring_occurence.hpp +++ b/concordia/substring_occurence.hpp @@ -9,8 +9,6 @@ */ -using namespace std; - class SubstringOccurence { public: SubstringOccurence(); @@ -35,7 +33,7 @@ public: SUFFIX_MARKER_TYPE getExampleLength() const { return _exampleLength; } - + void enterDataFromMarker(const SUFFIX_MARKER_TYPE & marker); private: @@ -43,7 +41,7 @@ private: SUFFIX_MARKER_TYPE _offset; - // the example + // the example SUFFIX_MARKER_TYPE _exampleLength; }; diff --git a/concordia/t/test_anubis_searcher.cpp b/concordia/t/test_anubis_searcher.cpp index 14808d4..5910b4a 100644 --- a/concordia/t/test_anubis_searcher.cpp +++ b/concordia/t/test_anubis_searcher.cpp @@ -12,8 +12,6 @@ #include "concordia/common/logging.hpp" #include "tests/common/test_resources_manager.hpp" -using namespace std; - BOOST_AUTO_TEST_SUITE(anubis_searcher) BOOST_AUTO_TEST_CASE( LcpSearch1 ) @@ -187,7 +185,7 @@ BOOST_AUTO_TEST_CASE( LcpSearch1 ) pattern2.push_back(2); SUFFIX_MARKER_TYPE highResLength2; - vector result2 = searcher.lcpSearch(T, markers, SA, pattern2, highResLength2); + std::vector result2 = searcher.lcpSearch(T, markers, SA, pattern2, highResLength2); SUFFIX_MARKER_TYPE length2 = highResLength2 / sizeof(INDEX_CHARACTER_TYPE); /* Expecting to get one result from SA: @@ -230,7 +228,7 @@ BOOST_AUTO_TEST_CASE( LcpSearch1 ) pattern3.push_back(3); SUFFIX_MARKER_TYPE highResLength3; - vector result3 = searcher.lcpSearch(T, markers, SA, pattern3, highResLength3); + std::vector result3 = searcher.lcpSearch(T, markers, SA, pattern3, highResLength3); SUFFIX_MARKER_TYPE length3 = highResLength3 / sizeof(INDEX_CHARACTER_TYPE); /* Expecting to get one result from SA: @@ -267,7 +265,7 @@ BOOST_AUTO_TEST_CASE( LcpSearch1 ) pattern4.push_back(4); SUFFIX_MARKER_TYPE highResLength4; - vector result4 = searcher.lcpSearch(T, markers, SA, pattern4, highResLength4); + std::vector result4 = searcher.lcpSearch(T, markers, SA, pattern4, highResLength4); SUFFIX_MARKER_TYPE length4 = highResLength4 / sizeof(INDEX_CHARACTER_TYPE); /* Expecting to get 2 results from SA: @@ -298,7 +296,7 @@ BOOST_AUTO_TEST_CASE( LcpSearch1 ) pattern5.push_back(4); SUFFIX_MARKER_TYPE highResLength5; - vector result5 = searcher.lcpSearch(T, markers, SA, pattern5, highResLength5); + std::vector result5 = searcher.lcpSearch(T, markers, SA, pattern5, highResLength5); SUFFIX_MARKER_TYPE length5 = highResLength5 / sizeof(INDEX_CHARACTER_TYPE); /* Expecting to get 0 results from SA, lcp length = 0; @@ -322,7 +320,7 @@ BOOST_AUTO_TEST_CASE( LcpSearch1 ) pattern6.push_back(0); SUFFIX_MARKER_TYPE highResLength6; - vector result6 = searcher.lcpSearch(T, markers, SA, pattern5, highResLength6); + std::vector result6 = searcher.lcpSearch(T, markers, SA, pattern5, highResLength6); SUFFIX_MARKER_TYPE length6 = highResLength6 / sizeof(INDEX_CHARACTER_TYPE); /* Expecting to get 0 results from SA, lcp length = 0; @@ -393,38 +391,38 @@ BOOST_AUTO_TEST_CASE( TmMatchesTest ) // example 14 // example interval list: [(1,2)] - vector exampleIntervals14 = tmMatches14->getExampleIntervals(); + std::vector exampleIntervals14 = tmMatches14->getExampleIntervals(); BOOST_CHECK_EQUAL(exampleIntervals14.size(), 1); BOOST_CHECK_EQUAL(exampleIntervals14[0].getStart(), 1); BOOST_CHECK_EQUAL(exampleIntervals14[0].getEnd(), 2); // pattern interval list: [(1,2)] - vector patternIntervals14 = tmMatches14->getPatternIntervals(); + std::vector patternIntervals14 = tmMatches14->getPatternIntervals(); BOOST_CHECK_EQUAL(patternIntervals14.size(), 1); BOOST_CHECK_EQUAL(patternIntervals14[0].getStart(), 1); BOOST_CHECK_EQUAL(patternIntervals14[0].getEnd(), 2); // example 51 // example interval list: [(1,3)] - vector exampleIntervals51 = tmMatches51->getExampleIntervals(); + std::vector exampleIntervals51 = tmMatches51->getExampleIntervals(); BOOST_CHECK_EQUAL(exampleIntervals51.size(), 1); BOOST_CHECK_EQUAL(exampleIntervals51[0].getStart(), 1); BOOST_CHECK_EQUAL(exampleIntervals51[0].getEnd(), 3); // pattern interval list: [(1,3)] - vector patternIntervals51 = tmMatches51->getPatternIntervals(); + std::vector patternIntervals51 = tmMatches51->getPatternIntervals(); BOOST_CHECK_EQUAL(patternIntervals51.size(), 1); BOOST_CHECK_EQUAL(patternIntervals51[0].getStart(), 1); BOOST_CHECK_EQUAL(patternIntervals51[0].getEnd(), 3); // example 123 // example interval list: [(1,3), (0,1)] - vector exampleIntervals123 = tmMatches123->getExampleIntervals(); + std::vector exampleIntervals123 = tmMatches123->getExampleIntervals(); BOOST_CHECK_EQUAL(exampleIntervals123.size(), 2); BOOST_CHECK_EQUAL(exampleIntervals123[0].getStart(), 1); BOOST_CHECK_EQUAL(exampleIntervals123[0].getEnd(), 3); BOOST_CHECK_EQUAL(exampleIntervals123[1].getStart(), 0); BOOST_CHECK_EQUAL(exampleIntervals123[1].getEnd(), 1); // pattern interval list: [(1,3), (3,4)] - vector patternIntervals123 = tmMatches123->getPatternIntervals(); + std::vector patternIntervals123 = tmMatches123->getPatternIntervals(); BOOST_CHECK_EQUAL(patternIntervals123.size(), 2); BOOST_CHECK_EQUAL(patternIntervals123[0].getStart(), 1); BOOST_CHECK_EQUAL(patternIntervals123[0].getEnd(), 3); diff --git a/concordia/t/test_concordia.cpp b/concordia/t/test_concordia.cpp index 8c4b315..6e07757 100644 --- a/concordia/t/test_concordia.cpp +++ b/concordia/t/test_concordia.cpp @@ -9,14 +9,12 @@ #include -using namespace std; - BOOST_AUTO_TEST_SUITE(concordia_main) BOOST_AUTO_TEST_CASE( ConcordiaVersion ) { Concordia concordia = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); - string version = concordia.getVersion(); + std::string version = concordia.getVersion(); BOOST_CHECK_EQUAL( version , "0.1"); } @@ -51,8 +49,8 @@ BOOST_AUTO_TEST_CASE( ConcordiaSimpleSearch1 ) */ - vector searchResult1 = concordia.simpleSearch("posiada rysia"); - vector searchResult2 = concordia.simpleSearch("posiada kota Ala"); + std::vector searchResult1 = concordia.simpleSearch("posiada rysia"); + std::vector searchResult2 = concordia.simpleSearch("posiada kota Ala"); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_WORD_MAP)); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_MARKERS)); @@ -73,7 +71,7 @@ BOOST_AUTO_TEST_CASE( ConcordiaSimpleSearch2 ) { // modified stop words to avoid anonymization Concordia concordia = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); - vector testExamples; + std::vector testExamples; testExamples.push_back(Example("xto xjest okno",312)); testExamples.push_back(Example("czy xjest okno otwarte",202)); testExamples.push_back(Example("chyba xto xjest xtutaj",45)); @@ -106,8 +104,8 @@ BOOST_AUTO_TEST_CASE( ConcordiaSimpleSearch2 ) */ Concordia concordia2 = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); - vector searchResult1 = concordia2.simpleSearch("xto xjest"); - vector searchResult2 = concordia2.simpleSearch("xjest okno"); + std::vector searchResult1 = concordia2.simpleSearch("xto xjest"); + std::vector searchResult2 = concordia2.simpleSearch("xjest okno"); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_WORD_MAP)); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_MARKERS)); @@ -131,13 +129,13 @@ BOOST_AUTO_TEST_CASE( ConcordiaSimpleSearch2 ) BOOST_AUTO_TEST_CASE( ConcordiaSimpleSearch3 ) { Concordia concordia = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); - vector testExamples; + std::vector testExamples; testExamples.push_back(Example("2. Ma on w szczególności prawo do podjęcia zatrudnienia dostępnego na terytorium innego Państwa Członkowskiego z takim samym pierwszeństwem, z jakiego korzystają obywatele tego państwa.",312)); testExamples.push_back(Example("czy xjest żółte otwarte",202)); concordia.addAllExamples(testExamples); Concordia concordia2 = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); - vector searchResult1 = concordia2.simpleSearch("on w szczególności prawo do podjęcia"); + std::vector searchResult1 = concordia2.simpleSearch("on w szczególności prawo do podjęcia"); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_WORD_MAP)); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_MARKERS)); @@ -176,8 +174,8 @@ BOOST_AUTO_TEST_CASE( ConcordiaAnubisSearch1 ) n: 0 1 2 3 4 5 6 7 8 9 10 11 SA[n]: 0 4 1 9 5 2 10 6 8 11 3 7 - vector searchResult1 = concordia.anubisSearch("posiada rysia chyba"); - vector searchResult2 = concordia.anubisSearch("posiada kota Ala"); + std::vector searchResult1 = concordia.anubisSearch("posiada rysia chyba"); + std::vector searchResult2 = concordia.anubisSearch("posiada kota Ala"); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_WORD_MAP)); boost::filesystem::remove(TestResourcesManager::getTestFilePath("temp",TEMP_MARKERS)); diff --git a/concordia/t/test_concordia_config.cpp b/concordia/t/test_concordia_config.cpp index b4b11f5..fe4fb0d 100644 --- a/concordia/t/test_concordia_config.cpp +++ b/concordia/t/test_concordia_config.cpp @@ -7,8 +7,6 @@ #include #include -using namespace std; - BOOST_AUTO_TEST_SUITE(concordia_config) BOOST_AUTO_TEST_CASE( ConfigParameters ) @@ -29,7 +27,7 @@ BOOST_AUTO_TEST_CASE( ConfigParameters ) BOOST_AUTO_TEST_CASE( NonexistentConfigTest ) { bool exceptionThrown = false; - string message = ""; + std::string message = ""; try { ConcordiaConfig config(TestResourcesManager::getTestConcordiaConfigFilePath("foo.cfg")); } catch (ConcordiaException & e) { @@ -44,7 +42,7 @@ BOOST_AUTO_TEST_CASE( NonexistentConfigTest ) BOOST_AUTO_TEST_CASE( InvalidConfigTest ) { bool exceptionThrown = false; - string message = ""; + std::string message = ""; try { ConcordiaConfig config(TestResourcesManager::getTestConcordiaConfigFilePath("invalid.cfg")); } catch (ConcordiaException & e) { diff --git a/concordia/t/test_concordia_index.cpp b/concordia/t/test_concordia_index.cpp index 5f5abea..bcbcc35 100644 --- a/concordia/t/test_concordia_index.cpp +++ b/concordia/t/test_concordia_index.cpp @@ -7,8 +7,6 @@ #include #include -using namespace std; - BOOST_AUTO_TEST_SUITE(concordia_index) @@ -16,7 +14,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest ) { ConcordiaIndex index(TestResourcesManager::getTestFilePath("temp","test_hash_index.bin"), TestResourcesManager::getTestFilePath("temp","test_markers.bin")); - boost::shared_ptr > T = boost::shared_ptr >(new vector()); + boost::shared_ptr > T = boost::shared_ptr >(new std::vector()); // Test hashed index: // n: 0 1 2 3 4 5 6 7 8 // T[n]: 0 1 2 0 1 3 4 1 3 @@ -36,7 +34,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest ) boost::shared_ptr > SA = index.generateSuffixArray(T); - boost::shared_ptr > expectedSA = boost::shared_ptr >(new vector()); + boost::shared_ptr > expectedSA = boost::shared_ptr >(new std::vector()); expectedSA->push_back(0); expectedSA->push_back(3); expectedSA->push_back(1); @@ -53,7 +51,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest2 ) { ConcordiaIndex index(TestResourcesManager::getTestFilePath("temp","test_hash_index.bin"), TestResourcesManager::getTestFilePath("temp","test_markers.bin")); - boost::shared_ptr > T = boost::shared_ptr >(new vector()); + boost::shared_ptr > T = boost::shared_ptr >(new std::vector()); //Test hashed index: // n: 0 1 2 3 4 5 6 7 8 9 10 11 @@ -77,7 +75,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest2 ) boost::shared_ptr > SA = index.generateSuffixArray(T); - boost::shared_ptr > expectedSA = boost::shared_ptr >(new vector()); + boost::shared_ptr > expectedSA = boost::shared_ptr >(new std::vector()); expectedSA->push_back(0); expectedSA->push_back(4); expectedSA->push_back(1); @@ -97,7 +95,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest3 ) { ConcordiaIndex index(TestResourcesManager::getTestFilePath("temp","test_hash_index.bin"), TestResourcesManager::getTestFilePath("temp","test_markers.bin")); - boost::shared_ptr > T = boost::shared_ptr >(new vector()); + boost::shared_ptr > T = boost::shared_ptr >(new std::vector()); //Test hashed index: // n: 0 1 2 3 4 5 @@ -115,7 +113,7 @@ BOOST_AUTO_TEST_CASE( SuffixArrayGenerationTest3 ) boost::shared_ptr > SA = index.generateSuffixArray(T); - boost::shared_ptr > expectedSA = boost::shared_ptr >(new vector()); + boost::shared_ptr > expectedSA = boost::shared_ptr >(new std::vector()); expectedSA->push_back(0); expectedSA->push_back(5); expectedSA->push_back(3); diff --git a/concordia/t/test_example.cpp b/concordia/t/test_example.cpp index db43221..b72f766 100644 --- a/concordia/t/test_example.cpp +++ b/concordia/t/test_example.cpp @@ -5,8 +5,6 @@ #include "concordia/example.hpp" -using namespace std; - BOOST_AUTO_TEST_SUITE(exampleTest) BOOST_AUTO_TEST_CASE( ExceedingId ) @@ -15,7 +13,7 @@ BOOST_AUTO_TEST_CASE( ExceedingId ) Example example1("Test", maxId); bool exceptionThrown = false; - string message = ""; + std::string message = ""; try { Example example2("Test", maxId+1); } catch (ConcordiaException & e) { diff --git a/concordia/t/test_hash_generator.cpp b/concordia/t/test_hash_generator.cpp index 5f0f29e..fdc38b0 100644 --- a/concordia/t/test_hash_generator.cpp +++ b/concordia/t/test_hash_generator.cpp @@ -8,9 +8,6 @@ #include "concordia/hash_generator.hpp" #include "tests/common/test_resources_manager.hpp" - -using namespace std; - BOOST_AUTO_TEST_SUITE(hash_generator) BOOST_AUTO_TEST_CASE( SimpleHashTest ) @@ -23,8 +20,8 @@ BOOST_AUTO_TEST_CASE( SimpleHashTest ) HashGenerator hashGenerator = HashGenerator(config); - vector hash = hashGenerator.generateHash("Ala posiada kota"); - vector expected; + std::vector hash = hashGenerator.generateHash("Ala posiada kota"); + std::vector expected; expected.push_back(0); expected.push_back(1); expected.push_back(2); @@ -44,17 +41,17 @@ BOOST_AUTO_TEST_CASE( TooLongHashTest ) HashGenerator hashGenerator = HashGenerator(config); - stringstream ss; + std::stringstream ss; for (int i=0;i<65537;i++) { ss << "xx" << i << " "; } - string longSentence = ss.str(); + std::string longSentence = ss.str(); bool exceptionThrown = false; - string message = ""; + std::string message = ""; try { - boost::shared_ptr > hash = hashGenerator.generateHash(longSentence); + boost::shared_ptr > hash = hashGenerator.generateHash(longSentence); } catch (ConcordiaException & e) { exceptionThrown = true; message = e.what(); @@ -76,8 +73,8 @@ BOOST_AUTO_TEST_CASE( HashSerializationTest ) HashGenerator hashGenerator1 = HashGenerator(config); - vector hash1 = hashGenerator1.generateHash("Ala posiada kota"); - vector expected1; + std::vector hash1 = hashGenerator1.generateHash("Ala posiada kota"); + std::vector expected1; expected1.push_back(0); expected1.push_back(1); expected1.push_back(2); @@ -86,8 +83,8 @@ BOOST_AUTO_TEST_CASE( HashSerializationTest ) hashGenerator1.serializeWordMap(); HashGenerator hashGenerator2 = HashGenerator(config); - vector hash2 = hashGenerator2.generateHash("Ala posiada psa"); - vector expected2; + std::vector hash2 = hashGenerator2.generateHash("Ala posiada psa"); + std::vector expected2; expected2.push_back(0); expected2.push_back(1); expected2.push_back(3); @@ -106,8 +103,8 @@ BOOST_AUTO_TEST_CASE( TokenVectorTest ) HashGenerator hashGenerator = HashGenerator(config); - vector tokenVector = hashGenerator.generateTokenVector("12.02.2014 o godzinie 17:40 doszło do kolizji na ulicy Grobla; policjanci ustalili, że kierowca zaparkował samochód."); - vector expected; + std::vector tokenVector = hashGenerator.generateTokenVector("12.02.2014 o godzinie 17:40 doszło do kolizji na ulicy Grobla; policjanci ustalili, że kierowca zaparkował samochód."); + std::vector expected; expected.push_back("ne_date"); expected.push_back("godzinie"); expected.push_back("ne_number"); diff --git a/concordia/t/test_interval.cpp b/concordia/t/test_interval.cpp index 3891882..dd9f7b6 100644 --- a/concordia/t/test_interval.cpp +++ b/concordia/t/test_interval.cpp @@ -2,8 +2,6 @@ #include "concordia/interval.hpp" #include "concordia/common/config.hpp" -using namespace std; - BOOST_AUTO_TEST_SUITE(interval) BOOST_AUTO_TEST_CASE( IntervalIntersects1 ) diff --git a/concordia/t/test_logging.cpp b/concordia/t/test_logging.cpp index 448866f..b37ba81 100644 --- a/concordia/t/test_logging.cpp +++ b/concordia/t/test_logging.cpp @@ -6,8 +6,6 @@ #define TMP_LOG_FILE "/tmp/concordia.log" -using namespace std; - BOOST_AUTO_TEST_SUITE(logging) BOOST_AUTO_TEST_CASE( LoggingTest ) diff --git a/concordia/t/test_regex_replacement.cpp b/concordia/t/test_regex_replacement.cpp index 23c613a..7311e10 100644 --- a/concordia/t/test_regex_replacement.cpp +++ b/concordia/t/test_regex_replacement.cpp @@ -5,8 +5,6 @@ #include #include -using namespace std; - BOOST_AUTO_TEST_SUITE(regex_replacement) BOOST_AUTO_TEST_CASE( SimpleReplacement ) @@ -18,7 +16,7 @@ BOOST_AUTO_TEST_CASE( SimpleReplacement ) BOOST_AUTO_TEST_CASE( BadRegex ) { bool exceptionThrown = false; - string message = ""; + std::string message = ""; try { RegexReplacement rr("+a","b"); } catch (ConcordiaException & e) { diff --git a/concordia/t/test_sentence_anonymizer.cpp b/concordia/t/test_sentence_anonymizer.cpp index 6447a54..72d995d 100644 --- a/concordia/t/test_sentence_anonymizer.cpp +++ b/concordia/t/test_sentence_anonymizer.cpp @@ -8,9 +8,6 @@ #include "concordia/sentence_anonymizer.hpp" #include "tests/common/test_resources_manager.hpp" - -using namespace std; - BOOST_AUTO_TEST_SUITE(sentence_anonymizer) BOOST_AUTO_TEST_CASE( NETest ) @@ -19,7 +16,7 @@ BOOST_AUTO_TEST_CASE( NETest ) SentenceAnonymizer anonymizer(config); - string sentence = "Date: 12.04.2012, mail: test@example.com, number: 5.34"; + std::string sentence = "Date: 12.04.2012, mail: test@example.com, number: 5.34"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence),"date ne_date mail ne_email number ne_number"); } @@ -29,7 +26,7 @@ BOOST_AUTO_TEST_CASE( HtmlTagsTest ) SentenceAnonymizer anonymizer(config); - string sentence = "link and bold and newline
"; + std::string sentence = "link and bold and newline
"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence),"link and bold and newline "); } @@ -40,7 +37,7 @@ BOOST_AUTO_TEST_CASE( StopWordsTest ) SentenceAnonymizer anonymizer(config); - string sentence = "Aczkolwiek nie wiem, czy to konieczne"; + std::string sentence = "Aczkolwiek nie wiem, czy to konieczne"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence)," wiem konieczne"); } @@ -51,7 +48,7 @@ BOOST_AUTO_TEST_CASE( StopSymbolsTest ) SentenceAnonymizer anonymizer(config); - string sentence = "xxx, . xxx # xx $xx@ xx"; + std::string sentence = "xxx, . xxx # xx $xx@ xx"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence),"xxx xxx xx xx xx"); } @@ -62,7 +59,7 @@ BOOST_AUTO_TEST_CASE( SpaceSymbolsTest ) SentenceAnonymizer anonymizer(config); - string sentence = "xxx-xxx xx|xx"; + std::string sentence = "xxx-xxx xx|xx"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence),"xxx xxx xx xx"); } @@ -72,7 +69,7 @@ BOOST_AUTO_TEST_CASE( WeirdSentenceTest ) boost::shared_ptr config(new ConcordiaConfig(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg"))); SentenceAnonymizer anonymizer(config); - string sentence = "Sony | DXC-M7PKDXC-M7PDXC-M7PHDXC-M7PK/1DXC-M7P/1DXC-M7PH/1DXC-327PKDXC-327PLDXC-327PHDXC-327APKDXC-327APLDXC-327AHDXC-537PKDXC-537PLDXC-537PHDXC-537APKDXC-537APLDXC-537APHEVW-537PKEVW-327PKDXC-637PDXC-637PKDXC-637PLDXC-637PHPVW-637PKPVW-637PLDXC-D30PFDXC-D30PKDXC-D30PLDXC-D30PHDSR-130PFDSR-130PKDSR-130PLPVW-D30PFPVW-D30PKPVW-D30PLDXC-327BPFDXC-327BPKDXC-327BPLDXC-327BPHDXC-D30WSPDXC-D35PHDXC-D35PLDXC-D35PKDXC-D35WSPLDSR-135PL | DXF-3000CEDXF-325CEDXF-501CEDXF-M3CEDXF-M7CEDXF-40CEDXF-40ACEDXF-50CEDXF-601CEDXF-40BCEDXF-50BCEDXF-701CEDXF-WSCEDXF-801CEHDVF-C30W | CCU-M3PCCU-M5PCCU-M7PCUU-M5AP | RM-M7GRM-M7E | — | CA-325PCA-325APCA-325BCA-327PCA-537PCA-511CA-512PCA-513VCT-U14 |"; + std::string sentence = "Sony | DXC-M7PKDXC-M7PDXC-M7PHDXC-M7PK/1DXC-M7P/1DXC-M7PH/1DXC-327PKDXC-327PLDXC-327PHDXC-327APKDXC-327APLDXC-327AHDXC-537PKDXC-537PLDXC-537PHDXC-537APKDXC-537APLDXC-537APHEVW-537PKEVW-327PKDXC-637PDXC-637PKDXC-637PLDXC-637PHPVW-637PKPVW-637PLDXC-D30PFDXC-D30PKDXC-D30PLDXC-D30PHDSR-130PFDSR-130PKDSR-130PLPVW-D30PFPVW-D30PKPVW-D30PLDXC-327BPFDXC-327BPKDXC-327BPLDXC-327BPHDXC-D30WSPDXC-D35PHDXC-D35PLDXC-D35PKDXC-D35WSPLDSR-135PL | DXF-3000CEDXF-325CEDXF-501CEDXF-M3CEDXF-M7CEDXF-40CEDXF-40ACEDXF-50CEDXF-601CEDXF-40BCEDXF-50BCEDXF-701CEDXF-WSCEDXF-801CEHDVF-C30W | CCU-M3PCCU-M5PCCU-M7PCUU-M5AP | RM-M7GRM-M7E | — | CA-325PCA-325APCA-325BCA-327PCA-537PCA-511CA-512PCA-513VCT-U14 |"; BOOST_CHECK_EQUAL(anonymizer.anonymize(sentence),"sony dxc mne_numberpkdxc mne_numberpdxc mne_numberphdxc mne_numberpk ne_numberdxc mne_numberp ne_numberdxc mne_numberph ne_numberdxc ne_numberpkdxc ne_numberpldxc ne_numberphdxc ne_numberapkdxc ne_numberapldxc ne_numberahdxc ne_numberpkdxc ne_numberpldxc ne_numberphdxc ne_numberapkdxc ne_numberapldxc ne_numberaphevw ne_numberpkevw ne_numberpkdxc ne_numberpdxc ne_numberpkdxc ne_numberpldxc ne_numberphpvw ne_numberpkpvw ne_numberpldxc dne_numberpfdxc dne_numberpkdxc dne_numberpldxc dne_numberphdsr ne_numberpfdsr ne_numberpkdsr ne_numberplpvw dne_numberpfpvw dne_numberpkpvw dne_numberpldxc ne_numberbpfdxc ne_numberbpkdxc ne_numberbpldxc ne_numberbphdxc dne_numberwspdxc dne_numberphdxc dne_numberpldxc dne_numberpkdxc dne_numberwspldsr ne_numberpl dxf ne_numbercedxf ne_numbercedxf ne_numbercedxf mne_numbercedxf mne_numbercedxf ne_numbercedxf ne_numberacedxf ne_numbercedxf ne_numbercedxf ne_numberbcedxf ne_numberbcedxf ne_numbercedxf wscedxf ne_numbercehdvf cne_numberw ccu mne_numberpccu mne_numberpccu mne_numberpcuu mne_numberap rm mne_numbergrm mne_numbere — ca ne_numberpca ne_numberapca ne_numberbca ne_numberpca ne_numberpca ne_numberca ne_numberpca ne_numbervct une_number "); } diff --git a/concordia/t/test_text_utils.cpp b/concordia/t/test_text_utils.cpp index fa62d9b..25b3b31 100644 --- a/concordia/t/test_text_utils.cpp +++ b/concordia/t/test_text_utils.cpp @@ -2,19 +2,17 @@ #include "concordia/common/config.hpp" #include "concordia/common/text_utils.hpp" -using namespace std; - BOOST_AUTO_TEST_SUITE(text_utils) BOOST_AUTO_TEST_CASE( ToLower ) { - string str = "ZAŻÓŁĆ GĘŚLĄ JAŹŃ"; + std::string str = "ZAŻÓŁĆ GĘŚLĄ JAŹŃ"; BOOST_CHECK_EQUAL(TextUtils::getInstance().toLowerCase(str),"zażółć gęślą jaźń"); } BOOST_AUTO_TEST_CASE( ToUpper ) { - string str = "zażółć gęślą jaźń"; + std::string str = "zażółć gęślą jaźń"; BOOST_CHECK_EQUAL(TextUtils::getInstance().toUpperCase(str),"ZAŻÓŁĆ GĘŚLĄ JAŹŃ"); } diff --git a/concordia/t/test_tm_matches.cpp b/concordia/t/test_tm_matches.cpp index 484bfcc..4bc608e 100644 --- a/concordia/t/test_tm_matches.cpp +++ b/concordia/t/test_tm_matches.cpp @@ -3,8 +3,6 @@ #include "concordia/tm_matches.hpp" #include "concordia/common/config.hpp" -using namespace std; - BOOST_AUTO_TEST_SUITE(tm_matches) BOOST_AUTO_TEST_CASE( TmMatchesSimpleScore1 ) diff --git a/concordia/t/test_utils.cpp b/concordia/t/test_utils.cpp index 7ca2fb0..36c88e7 100644 --- a/concordia/t/test_utils.cpp +++ b/concordia/t/test_utils.cpp @@ -5,23 +5,20 @@ #include #include "divsufsort.h" -#include - -using namespace std; BOOST_AUTO_TEST_SUITE(utils) BOOST_AUTO_TEST_CASE( WriteReadSingleCharacter ) { - ofstream testFileOutput; + std::ofstream testFileOutput; testFileOutput.open(TestResourcesManager::getTestFilePath("temp","temp_file.bin").c_str(), - ios::out|ios::binary); + std::ios::out|std::ios::binary); INDEX_CHARACTER_TYPE testCharacter = 123456789; //in hex: 75BCD15 Utils::writeIndexCharacter(testFileOutput,testCharacter); testFileOutput.close(); - ifstream testFileInput; - testFileInput.open(TestResourcesManager::getTestFilePath("temp","temp_file.bin").c_str(),ios::in|ios::binary); + std::ifstream testFileInput; + testFileInput.open(TestResourcesManager::getTestFilePath("temp","temp_file.bin").c_str(),std::ios::in|std::ios::binary); INDEX_CHARACTER_TYPE retrievedCharacter = Utils::readIndexCharacter(testFileInput); BOOST_CHECK_EQUAL(retrievedCharacter, testCharacter); testFileInput.close(); @@ -31,7 +28,7 @@ BOOST_AUTO_TEST_CASE( WriteReadSingleCharacter ) BOOST_AUTO_TEST_CASE( IndexVectorToSaucharArray ) { - vector hash; + std::vector hash; hash.push_back(123456789); // in hex: 75BCD15 // in memory: 15 cd 5b 07 // in memory DEC: 21 205 91 7 @@ -41,13 +38,13 @@ BOOST_AUTO_TEST_CASE( IndexVectorToSaucharArray ) // in memory DEC: 177 104 222 58 sauchar_t * dataArray = Utils::indexVectorToSaucharArray(hash); - vector result; + std::vector result; for (int i=0;i<8;i++) { INDEX_CHARACTER_TYPE a = dataArray[i]; result.push_back(a); } - vector expected; + std::vector expected; expected.push_back(21); expected.push_back(205); expected.push_back(91); @@ -62,7 +59,7 @@ BOOST_AUTO_TEST_CASE( IndexVectorToSaucharArray ) BOOST_AUTO_TEST_CASE( IndexVectorToSaucharVector ) { - vector hash; + std::vector hash; hash.push_back(123456789); // in hex: 75BCD15 // in memory: 15 cd 5b 07 // in memory DEC: 21 205 91 7 @@ -70,9 +67,9 @@ BOOST_AUTO_TEST_CASE( IndexVectorToSaucharVector ) hash.push_back(987654321); // in hex: 3ADE68B1 // in memory: b1 68 de 3a // in memory DEC: 177 104 222 58 - vector result = Utils::indexVectorToSaucharVector(hash); + std::vector result = Utils::indexVectorToSaucharVector(hash); - vector expected; + std::vector expected; expected.push_back(21); expected.push_back(205); expected.push_back(91); diff --git a/concordia/t/test_word_map.cpp b/concordia/t/test_word_map.cpp index 111d7ea..f3d0d40 100644 --- a/concordia/t/test_word_map.cpp +++ b/concordia/t/test_word_map.cpp @@ -1,10 +1,6 @@ #include "tests/unit-tests/unit_tests_globals.hpp" #include "concordia/word_map.hpp" -#include - -using namespace std; - BOOST_AUTO_TEST_SUITE(word_map) BOOST_AUTO_TEST_CASE( WordCodeTest ) diff --git a/concordia/tm_matches.cpp b/concordia/tm_matches.cpp index 0e0465b..d2d11cb 100644 --- a/concordia/tm_matches.cpp +++ b/concordia/tm_matches.cpp @@ -54,7 +54,7 @@ void TmMatches::addPatternInterval(int start, int end) { } bool TmMatches::_alreadyIntersects( - const vector & intervalList, + const std::vector & intervalList, int start, int end) { Interval tempInterval(start, end); BOOST_FOREACH(Interval oldInterval, intervalList) { @@ -66,7 +66,7 @@ bool TmMatches::_alreadyIntersects( } double TmMatches::_getLogarithmicOverlay( - const vector & intervalList, + const std::vector & intervalList, SUFFIX_MARKER_TYPE sentenceSize, double k) { double overlayScore = 0; diff --git a/concordia/tm_matches.hpp b/concordia/tm_matches.hpp index 116d321..f9f0a8c 100644 --- a/concordia/tm_matches.hpp +++ b/concordia/tm_matches.hpp @@ -14,12 +14,10 @@ */ -using namespace std; - class TmMatches { public: TmMatches(); - + TmMatches(const SUFFIX_MARKER_TYPE exampleId, const SUFFIX_MARKER_TYPE exampleSize, const SUFFIX_MARKER_TYPE patternSize); @@ -32,11 +30,11 @@ public: return _score; } - vector getExampleIntervals() const { + std::vector getExampleIntervals() const { return _exampleMatchedRegions; } - vector getPatternIntervals() const { + std::vector getPatternIntervals() const { return _patternMatchedRegions; } @@ -53,18 +51,18 @@ public: void addPatternInterval(int start, int end); private: - bool _alreadyIntersects(const vector & intervalList, + bool _alreadyIntersects(const std::vector & intervalList, int start, int end); - double _getLogarithmicOverlay(const vector & intervalList, + double _getLogarithmicOverlay(const std::vector & intervalList, SUFFIX_MARKER_TYPE sentenceSize, double k); SUFFIX_MARKER_TYPE _exampleId; - vector _exampleMatchedRegions; + std::vector _exampleMatchedRegions; - vector _patternMatchedRegions; + std::vector _patternMatchedRegions; SUFFIX_MARKER_TYPE _patternSize; diff --git a/concordia/word_map.cpp b/concordia/word_map.cpp index 4836935..f4afd59 100644 --- a/concordia/word_map.cpp +++ b/concordia/word_map.cpp @@ -9,7 +9,7 @@ WordMap::WordMap() throw(ConcordiaException) { WordMap::~WordMap() { } -INDEX_CHARACTER_TYPE WordMap::getWordCode(const string & word) +INDEX_CHARACTER_TYPE WordMap::getWordCode(const std::string & word) throw(ConcordiaException) { if (_map.find(word) == _map.end()) { if (_nextFree == INDEX_CHARACTER_TYPE_MAX_VALUE) { diff --git a/concordia/word_map.hpp b/concordia/word_map.hpp index f395b49..61ab420 100644 --- a/concordia/word_map.hpp +++ b/concordia/word_map.hpp @@ -14,8 +14,6 @@ */ -using namespace std; - class WordMap { public: explicit WordMap() throw(ConcordiaException); @@ -24,8 +22,8 @@ public: */ virtual ~WordMap(); - INDEX_CHARACTER_TYPE getWordCode(const string & word) - throw(ConcordiaException); + INDEX_CHARACTER_TYPE getWordCode(const std::string & word) + throw(ConcordiaException); private: friend class boost::serialization::access; @@ -37,7 +35,7 @@ private: ar & _nextFree; } - map _map; + std::map _map; INDEX_CHARACTER_TYPE _nextFree; }; diff --git a/tests/common/test_resources_manager.cpp b/tests/common/test_resources_manager.cpp index 7f1501d..ffd52f9 100644 --- a/tests/common/test_resources_manager.cpp +++ b/tests/common/test_resources_manager.cpp @@ -4,24 +4,24 @@ #define CONCORDIA_TAGSET_DIRECTORY "concordia-tagset" #define CONCORDIA_CONFIG_DIRECTORY "concordia-config" -string TestResourcesManager::getPuddleFilePath(const string & filename) { - string result = string(TEST_RESOURCES_DIRECTORY); +std::string TestResourcesManager::getPuddleFilePath(const std::string & filename) { + std::string result = std::string(TEST_RESOURCES_DIRECTORY); return result + "/" + PUDDLE_TEST_DIRECTORY + "/" + filename; } -string TestResourcesManager::getTestConcordiaConfigFilePath(const string & filename) { - string result = string(TEST_RESOURCES_DIRECTORY); +std::string TestResourcesManager::getTestConcordiaConfigFilePath(const std::string & filename) { + std::string result = std::string(TEST_RESOURCES_DIRECTORY); return result + "/" + CONCORDIA_CONFIG_DIRECTORY + "/" + filename; } -string TestResourcesManager::getProdConcordiaConfigFilePath(const string & filename) { - string result = string(PROD_RESOURCES_DIRECTORY); +std::string TestResourcesManager::getProdConcordiaConfigFilePath(const std::string & filename) { + std::string result = std::string(PROD_RESOURCES_DIRECTORY); return result + "/" + CONCORDIA_CONFIG_DIRECTORY + "/" + filename; } -string TestResourcesManager::getTestFilePath(const string & module, const string & filename) { - string result = string(TEST_RESOURCES_DIRECTORY); +std::string TestResourcesManager::getTestFilePath(const std::string & module, const std::string & filename) { + std::string result = std::string(TEST_RESOURCES_DIRECTORY); return result + "/" + module + "/" + filename; } diff --git a/tests/common/test_resources_manager.hpp b/tests/common/test_resources_manager.hpp index ac4e523..029e253 100644 --- a/tests/common/test_resources_manager.hpp +++ b/tests/common/test_resources_manager.hpp @@ -6,17 +6,15 @@ #include "concordia/common/config.hpp" -using namespace std; - class TestResourcesManager { public: - static string getPuddleFilePath(const string & filename); + static std::string getPuddleFilePath(const std::string & filename); - static string getTestConcordiaConfigFilePath(const string & filename); + static std::string getTestConcordiaConfigFilePath(const std::string & filename); - static string getProdConcordiaConfigFilePath(const string & filename); + static std::string getProdConcordiaConfigFilePath(const std::string & filename); - static string getTestFilePath(const string & module, const string & filename); + static std::string getTestFilePath(const std::string & module, const std::string & filename); };