OpenMS
|
Fuzzy comparison of strings, tolerates numeric differences. More...
#include <OpenMS/CONCEPT/FuzzyStringComparator.h>
Classes | |
struct | AbortComparison |
Internal exception class. More... | |
struct | InputLine |
Stores information about the current input line (i.e., stream for the line and the current position in the stream) More... | |
struct | PrefixInfo_ |
Wrapper for the prefix information computed for the failure report. More... | |
struct | StreamElement_ |
Stores information about characters, numbers, and white spaces loaded from the InputStream. More... | |
Friends | |
void | Internal::ClassTest::testStringSimilar (const char *file, int line, const std::string &string_1, const char *string_1_stringified, const std::string &string_2, const char *string_2_stringified) |
bool | Internal::ClassTest::isFileSimilar (const std::string &, const std::string &) |
the fabulous four | |
std::ostream * | log_dest_ |
Log and results output goes here. More... | |
std::string | input_1_name_ |
Name of first input e.g., filename. More... | |
std::string | input_2_name_ |
Name of second input e.g., filename. More... | |
InputLine | input_line_1_ |
InputLine | input_line_2_ |
int | line_num_1_ |
int | line_num_2_ |
int | line_num_1_max_ |
int | line_num_2_max_ |
std::string | line_str_1_max_ |
std::string | line_str_2_max_ |
double | ratio_max_allowed_ |
Maximum ratio of numbers allowed, see ratio_max_. More... | |
double | ratio_max_ |
Maximum ratio of numbers observed so far, see ratio_max_allowed_. More... | |
double | absdiff_max_allowed_ |
Maximum absolute difference of numbers allowed, see absdiff_max_. More... | |
double | absdiff_max_ |
Maximum difference of numbers observed so far, see absdiff_max_allowed_. More... | |
StreamElement_ | element_1_ |
Stores information about characters, numbers, and white spaces loaded from the first input stream. More... | |
StreamElement_ | element_2_ |
Stores information about characters, numbers, and white spaces loaded from the second input stream. More... | |
bool | is_absdiff_small_ |
int | verbose_level_ |
int | tab_width_ |
int | first_column_ |
bool | is_status_success_ |
Has comparison been successful so far? Note: this flag is changed in reportFailure_();. More... | |
bool | use_prefix_ |
use a prefix when reporting More... | |
StringList | whitelist_ |
Whitelist. More... | |
std::map< String, UInt > | whitelist_cases_ |
Occurrences of whitelist entries. More... | |
std::vector< std::pair< std::string, std::string > > | matched_whitelist_ |
Alternative Whitelist. More... | |
FuzzyStringComparator () | |
Constructor. More... | |
virtual | ~FuzzyStringComparator () |
Destructor. More... | |
FuzzyStringComparator (const FuzzyStringComparator &rhs) | |
Copy constructor intentionally not implemented. More... | |
FuzzyStringComparator & | operator= (const FuzzyStringComparator &rhs) |
Assignment operator intentionally not implemented. More... | |
const double & | getAcceptableRelative () const |
Acceptable relative error (a number >= 1.0) More... | |
void | setAcceptableRelative (const double rhs) |
Acceptable relative error (a number >= 1.0) More... | |
const double & | getAcceptableAbsolute () const |
Acceptable absolute difference (a number >= 0.0) More... | |
void | setAcceptableAbsolute (const double rhs) |
Acceptable absolute difference (a number >= 0.0) More... | |
const StringList & | getWhitelist () const |
White list. If both lines contain the same element from this list, they are skipped over. More... | |
StringList & | getWhitelist () |
White list. If both lines contain the same element from this list, they are skipped over. More... | |
void | setWhitelist (const StringList &rhs) |
White list. If both lines contain the same element from this list, they are skipped over. More... | |
void | setMatchedWhitelist (const std::vector< std::pair< std::string, std::string > > &rhs) |
Matched white list. If file 1 contains element 1 and file 2 contains element 2, they are skipped over. More... | |
const std::vector< std::pair< std::string, std::string > > & | getMatchedWhitelist () const |
Matched white list. If file 1 contains element 1 and file 2 contains element 2, they are skipped over. More... | |
const int & | getVerboseLevel () const |
verbose level More... | |
void | setVerboseLevel (const int rhs) |
verbose level More... | |
const int & | getTabWidth () const |
get tab width (for column numbers) More... | |
void | setTabWidth (const int rhs) |
set tab width (for column numbers) More... | |
const int & | getFirstColumn () const |
get first column (for column numbers) More... | |
void | setFirstColumn (const int rhs) |
set first column (for column numbers) More... | |
std::ostream & | getLogDestination () const |
Log output is written to this destination. More... | |
void | setLogDestination (std::ostream &rhs) |
Log output is written to this destination. More... | |
bool | compareStrings (std::string const &lhs, std::string const &rhs) |
Compare two strings. More... | |
bool | compareStreams (std::istream &input_1, std::istream &input_2) |
Compare two streams of input. More... | |
bool | compareFiles (const std::string &filename_1, const std::string &filename_2) |
Simple diff-like application to compare two input files. Numeric differences are tolerated up to a certain ratio or absolute difference. More... | |
bool | compareLines_ (std::string const &line_str_1, std::string const &line_str_2) |
Compare two lines of input. More... | |
void | reportSuccess_ () const |
Report good news. More... | |
void | reportFailure_ (char const *const message) const |
void | writeWhitelistCases_ (const std::string &prefix) const |
Write info about hits in the whitelist. More... | |
void | readNextLine_ (std::istream &input_stream, std::string &line_string, int &line_number) const |
bool | openInputFileStream_ (const std::string &filename, std::ifstream &input_stream) const |
opens and checks an input file stream std::ifstream More... | |
Fuzzy comparison of strings, tolerates numeric differences.
struct OpenMS::FuzzyStringComparator::AbortComparison |
Internal exception class.
Constructor.
|
virtual |
Destructor.
FuzzyStringComparator | ( | const FuzzyStringComparator & | rhs | ) |
Copy constructor intentionally not implemented.
bool compareFiles | ( | const std::string & | filename_1, |
const std::string & | filename_2 | ||
) |
Simple diff-like application to compare two input files. Numeric differences are tolerated up to a certain ratio or absolute difference.
where
filename_1 | first input file |
filename_2 | second input file |
|
protected |
Compare two lines of input.
This implements the core functionality. Intended to be used for a single line of input.
bool compareStreams | ( | std::istream & | input_1, |
std::istream & | input_2 | ||
) |
Compare two streams of input.
This compares all lines of the input. Intended to be used for file streams.
bool compareStrings | ( | std::string const & | lhs, |
std::string const & | rhs | ||
) |
Compare two strings.
This compares all lines of the input.
const double& getAcceptableAbsolute | ( | ) | const |
Acceptable absolute difference (a number >= 0.0)
const double& getAcceptableRelative | ( | ) | const |
Acceptable relative error (a number >= 1.0)
const int& getFirstColumn | ( | ) | const |
get first column (for column numbers)
std::ostream& getLogDestination | ( | ) | const |
Log output is written to this destination.
The default is std::cout. Use std::ostringstream etc. to save the output in a string.
const std::vector< std::pair<std::string, std::string> >& getMatchedWhitelist | ( | ) | const |
Matched white list. If file 1 contains element 1 and file 2 contains element 2, they are skipped over.
const int& getTabWidth | ( | ) | const |
get tab width (for column numbers)
const int& getVerboseLevel | ( | ) | const |
verbose level
StringList& getWhitelist | ( | ) |
White list. If both lines contain the same element from this list, they are skipped over.
const StringList& getWhitelist | ( | ) | const |
White list. If both lines contain the same element from this list, they are skipped over.
|
protected |
opens and checks an input file stream std::ifstream
FuzzyStringComparator& operator= | ( | const FuzzyStringComparator & | rhs | ) |
Assignment operator intentionally not implemented.
|
protected |
read the next line in input stream, skipping over empty lines and lines consisting of whitespace only
|
protected |
Report bad news.
AbortComparison |
|
protected |
Report good news.
void setAcceptableAbsolute | ( | const double | rhs | ) |
Acceptable absolute difference (a number >= 0.0)
void setAcceptableRelative | ( | const double | rhs | ) |
Acceptable relative error (a number >= 1.0)
void setFirstColumn | ( | const int | rhs | ) |
set first column (for column numbers)
void setLogDestination | ( | std::ostream & | rhs | ) |
Log output is written to this destination.
The default is std::cout. Use std::ostringstream etc. to save the output in a string.
There seems to be an issue with this under Windows, see comment in FuzzyStringComparator_test.cpp
void setMatchedWhitelist | ( | const std::vector< std::pair< std::string, std::string > > & | rhs | ) |
Matched white list. If file 1 contains element 1 and file 2 contains element 2, they are skipped over.
void setTabWidth | ( | const int | rhs | ) |
set tab width (for column numbers)
void setVerboseLevel | ( | const int | rhs | ) |
verbose level
void setWhitelist | ( | const StringList & | rhs | ) |
White list. If both lines contain the same element from this list, they are skipped over.
|
protected |
Write info about hits in the whitelist.
|
friend |
|
friend |
|
protected |
Maximum difference of numbers observed so far, see absdiff_max_allowed_.
|
protected |
Maximum absolute difference of numbers allowed, see absdiff_max_.
|
protected |
Stores information about characters, numbers, and white spaces loaded from the first input stream.
|
protected |
Stores information about characters, numbers, and white spaces loaded from the second input stream.
|
protected |
|
protected |
Name of first input e.g., filename.
|
protected |
Name of second input e.g., filename.
|
protected |
|
protected |
|
protected |
|
protected |
Has comparison been successful so far? Note: this flag is changed in reportFailure_();.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Log and results output goes here.
|
protected |
Alternative Whitelist.
|
protected |
Maximum ratio of numbers observed so far, see ratio_max_allowed_.
|
protected |
Maximum ratio of numbers allowed, see ratio_max_.
|
protected |
|
protected |
use a prefix when reporting
|
protected |
|
protected |
Whitelist.