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 whitesspaces loaded from the InputStream. More... | |
Public Member Functions | |
| const double & | getAcceptableRelative () const |
| Acceptable relative error (a number >= 1.0). | |
| void | setAcceptableRelative (const double rhs) |
| Acceptable relative error (a number >= 1.0). | |
| const double & | getAcceptableAbsolute () const |
| Acceptable absolute difference (a number >= 0.0). | |
| void | setAcceptableAbsolute (const double rhs) |
| Acceptable absolute difference (a number >= 0.0). | |
| const StringList & | getWhitelist () const |
| White list. If both lines contain the same element from this list, they are skipped over. | |
| StringList & | getWhitelist () |
| White list. If both lines contain the same element from this list, they are skipped over. | |
| void | setWhitelist (const StringList &rhs) |
| White list. If both lines contain the same element from this list, they are skipped over. | |
| const int & | getVerboseLevel () const |
| verbose level | |
| void | setVerboseLevel (const int rhs) |
| verbose level | |
| const int & | getTabWidth () const |
| get tab width (for column numbers) | |
| void | setTabWidth (const int rhs) |
| set tab width (for column numbers) | |
| const int & | getFirstColumn () const |
| get first column (for column numbers) | |
| void | setFirstColumn (const int rhs) |
| set first column (for column numbers) | |
| std::ostream & | getLogDestination () const |
| Log output is written to this destination. | |
| void | setLogDestination (std::ostream &rhs) |
| Log output is written to this destination. | |
| bool | compareStrings (std::string const &lhs, std::string const &rhs) |
| Compare two strings. | |
| bool | compareStreams (std::istream &input_1, std::istream &input_2) |
| Compare two streams of input. | |
| 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. | |
the fabulous four | |
| FuzzyStringComparator () | |
| Constructor. | |
| virtual | ~FuzzyStringComparator () |
| Destructor. | |
| FuzzyStringComparator (const FuzzyStringComparator &rhs) | |
| Copy constructor intentionally not implemented. | |
| FuzzyStringComparator & | operator= (const FuzzyStringComparator &rhs) |
| Assignment operator intentionally not implemented. | |
Protected Member Functions | |
| bool | compareLines_ (std::string const &line_str_1, std::string const &line_str_2) |
| Compare two lines of input. | |
| void | reportSuccess_ () const |
| Report good news. | |
| void | reportFailure_ (char const *const message) const |
| void | writeWhitelistCases_ (const std::string &prefix) const |
| Write info about hits in the whitelist. | |
| 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 | |
Protected Attributes | |
| std::ostream * | log_dest_ |
| Log and results output goes here. | |
| std::string | input_1_name_ |
| Name of first input e.g., filename. | |
| std::string | input_2_name_ |
| Name of second input e.g., filename. | |
| 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_. | |
| double | ratio_max_ |
| Maximum ratio of numbers observed so far, see ratio_max_allowed_. | |
| double | absdiff_max_allowed_ |
| Maximum absolute difference of numbers allowed, see absdiff_max_. | |
| double | absdiff_max_ |
| Maximum difference of numbers observed so far, see absdiff_max_allowed_. | |
| StreamElement_ | element_1_ |
| Stores information about characters, numbers, and whitesspaces loaded from the first input stream. | |
| StreamElement_ | element_2_ |
| Stores information about characters, numbers, and whitesspaces loaded from the second input stream. | |
| bool | is_absdiff_small_ |
| int | verbose_level_ |
| int | tab_width_ |
| int | first_column_ |
| bool | is_status_success_ |
| Has comparison been sucessful so far? Note: this flag is changed in reportFailure_();. | |
| bool | use_prefix_ |
| use a prefix when reporting | |
| StringList | whitelist_ |
| std::map< String, UInt > | whitelist_cases_ |
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 &) |
Fuzzy comparison of strings, tolerates numeric differences.
Constructor.
| virtual ~FuzzyStringComparator | ( | ) | [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 |
| bool compareLines_ | ( | std::string const & | line_str_1, | |
| std::string const & | line_str_2 | |||
| ) | [protected] |
Compare two lines of input.
This implements the core functionality. Intended to be used for a single line of input.
returns true (non-zero) in case of success
| 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.
returns true in case of no differences found
| bool compareStrings | ( | std::string const & | lhs, | |
| std::string const & | rhs | |||
| ) |
Compare two strings.
This compares all lines of the input.
returns true in case of no differences found
| const double& getAcceptableAbsolute | ( | ) | const [inline] |
Acceptable absolute difference (a number >= 0.0).
| const double& getAcceptableRelative | ( | ) | const [inline] |
Acceptable relative error (a number >= 1.0).
| const int& getFirstColumn | ( | ) | const [inline] |
get first column (for column numbers)
| std::ostream& getLogDestination | ( | ) | const [inline] |
Log output is written to this destination.
The default is std::cout. Use std::ostringstream etc. to save the output in a string.
| const int& getTabWidth | ( | ) | const [inline] |
get tab width (for column numbers)
| const int& getVerboseLevel | ( | ) | const [inline] |
verbose level
| const StringList& getWhitelist | ( | ) | const [inline] |
White list. If both lines contain the same element from this list, they are skipped over.
| StringList& getWhitelist | ( | ) | [inline] |
White list. If both lines contain the same element from this list, they are skipped over.
| bool openInputFileStream_ | ( | const std::string & | filename, | |
| std::ifstream & | input_stream | |||
| ) | const [protected] |
opens and checks an input file stream std::ifstream
| FuzzyStringComparator& operator= | ( | const FuzzyStringComparator & | rhs | ) |
Assignment operator intentionally not implemented.
| void readNextLine_ | ( | std::istream & | input_stream, | |
| std::string & | line_string, | |||
| int & | line_number | |||
| ) | const [protected] |
read the next line in input stream, skipping over empty lines and lines consisting of whitespace only
| void reportFailure_ | ( | char const *const | message | ) | const [protected] |
Report bad news.
| AbortComparison |
| void reportSuccess_ | ( | ) | const [protected] |
Report good news.
| void setAcceptableAbsolute | ( | const double | rhs | ) | [inline] |
Acceptable absolute difference (a number >= 0.0).
| void setAcceptableRelative | ( | const double | rhs | ) | [inline] |
Acceptable relative error (a number >= 1.0).
| void setFirstColumn | ( | const int | rhs | ) | [inline] |
set first column (for column numbers)
| void setLogDestination | ( | std::ostream & | rhs | ) | [inline] |
Log output is written to this destination.
The default is std::cout. Use std::ostringstream etc. to save the output in a string.
For internal use only.
There seems to be an issue with this under Windows, see comment in FuzzyStringComparator_test.C
| void setTabWidth | ( | const int | rhs | ) | [inline] |
set tab width (for column numbers)
| void setVerboseLevel | ( | const int | rhs | ) | [inline] |
verbose level
| void setWhitelist | ( | const StringList & | rhs | ) | [inline] |
White list. If both lines contain the same element from this list, they are skipped over.
| void writeWhitelistCases_ | ( | const std::string & | prefix | ) | const [protected] |
Write info about hits in the whitelist.
| bool Internal::ClassTest::isFileSimilar | ( | const std::string & | , | |
| const std::string & | ||||
| ) | [friend] |
| 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 | |||
| ) | [friend] |
double absdiff_max_ [protected] |
Maximum difference of numbers observed so far, see absdiff_max_allowed_.
double absdiff_max_allowed_ [protected] |
Maximum absolute difference of numbers allowed, see absdiff_max_.
StreamElement_ element_1_ [protected] |
Stores information about characters, numbers, and whitesspaces loaded from the first input stream.
StreamElement_ element_2_ [protected] |
Stores information about characters, numbers, and whitesspaces loaded from the second input stream.
int first_column_ [protected] |
std::string input_1_name_ [protected] |
Name of first input e.g., filename.
std::string input_2_name_ [protected] |
Name of second input e.g., filename.
InputLine input_line_1_ [protected] |
InputLine input_line_2_ [protected] |
bool is_absdiff_small_ [protected] |
bool is_status_success_ [protected] |
Has comparison been sucessful so far? Note: this flag is changed in reportFailure_();.
int line_num_1_ [protected] |
int line_num_1_max_ [protected] |
int line_num_2_ [protected] |
int line_num_2_max_ [protected] |
std::string line_str_1_max_ [protected] |
std::string line_str_2_max_ [protected] |
std::ostream* log_dest_ [protected] |
Log and results output goes here.
double ratio_max_ [protected] |
Maximum ratio of numbers observed so far, see ratio_max_allowed_.
double ratio_max_allowed_ [protected] |
Maximum ratio of numbers allowed, see ratio_max_.
int tab_width_ [protected] |
bool use_prefix_ [protected] |
use a prefix when reporting
int verbose_level_ [protected] |
StringList whitelist_ [protected] |
std::map<String, UInt> whitelist_cases_ [protected] |
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:51 using doxygen 1.7.1 |