fuzzywuzzy
fuzzywuzzy copied to clipboard
Unit test and fixed bug
This pull request contains the following updates:
Unit Test
- Implemented unit test using Catch2 [1] and ported suitable tests from the original Python repository [2]. The unit test files locate in the
testfolder as before. - Updated
CMakeLists.txtandREADME.mdto provide instruction of building and running unit test.
Fixed Bugs
- [v] The example from Readme gave the wrong result. The cause is that the
full_processis default on and will strip the tailing exclamation mark. It was fixed by altering the default value offull_processtofalse.
ReadmeExample
FAILED:
REQUIRE( 97 == fuzz::ratio("this is a test", "this is a test!") );
EXPANSION:
97 == 100
- [v] Comparison of two empty strings should give 100% similarity as in the original Python implementation. Fixed by adding additional logic in
ratio()andpartial_ratio().
RatioTest
testEmptyStringsScore100
FAILED:
REQUIRE( 100 == fuzz::ratio("", "") )
EXPANSION:
100 == 0
- [v] The
partial_ratio()of two identical string is 0% similarity which should be 100% undoubtedly. The detailed description is in thefuzzywuzzy.cpp. This was fixed by a temporary solution to compare if two strings is identical or not.
RatioTest
testPartialRatio
FAILED:
REQUIRE( 100 == fuzz::partial_ratio("new york mets", "new york mets") )
EXPANSION:
100 == 0
Thanks for taking the time to port unit tests over! I'll see about going over the commits the coming week.
Just let me know if there is anything goes wrong or needs to be updated. ^_^
I'm not partial to adding a ~17kloc library header. Could you source
catch.hppfrom a submodule instead?
Okay, I think make it as an installed package or something likewise is more proper. Will be added in the next commit.
@tmplt
I had updated the required change. Please review the code changes in this new commit.