diff --git a/src/storm/utility/string.cpp b/src/storm/utility/string.cpp index 4d22f434f..46010525f 100644 --- a/src/storm/utility/string.cpp +++ b/src/storm/utility/string.cpp @@ -9,9 +9,13 @@ namespace storm { // intentionally left empty. } - bool SimilarStrings::add(std::string const& string) { + bool SimilarStrings::isSimilar(std::string const& string) const { double distance = levenshteinDistance(reference, string, caseSensitive); - if (distance <= static_cast(std::max(reference.size(), string.size())) * (1.0 - similarityFactor)) { + return distance <= static_cast(std::max(reference.size(), string.size())) * (1.0 - similarityFactor); + } + + bool SimilarStrings::add(std::string const& string) { + if (isSimilar(string)) { distances.emplace(storm::utility::string::levenshteinDistance(reference, string, caseSensitive), string); return true; } diff --git a/src/storm/utility/string.h b/src/storm/utility/string.h index 332113341..bf2b501d0 100644 --- a/src/storm/utility/string.h +++ b/src/storm/utility/string.h @@ -18,6 +18,11 @@ namespace storm { */ SimilarStrings(std::string reference, double similarityFactor = 0.6, bool caseSensitive = true); + /*! + * @return true, if the given string is considered similar. + */ + bool isSimilar(std::string const& string) const; + /*! * Adds the given string to the set of similar strings (if it is similar) * @return true, if the given string is considered similar. @@ -26,7 +31,6 @@ namespace storm { /*! * Gets a list of all added strings that are similar to the reference string. - * Erases all strings gathered so far. */ std::vector toList() const;