Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test methods that may not always give correct answer

Tags:

unit-testing

Imagine that you have an internally controlled list of vendors. Now imagine that you want to match unstructured strings against that list. Most will be easy to match, but some may be reasonably impossible. The algorithm will assign a confidence to each match, but a human needs to confirm all matches produced.

How could this algorithm be unit tested? The only idea I have had so far is to take a sample of pairs matched by humans and make sure the algorithm is able to successfully match those, omitting strings that I couldn't reasonably expect our algorithm to handle. Is there a better way?

like image 314
Samantha Branham Avatar asked Jan 23 '26 21:01

Samantha Branham


1 Answers

i'd try some 'canonical' pairs, both "should match" and "shouldn't match" pairs, and test only if the confidence is above (or below) a given threshold.

maybe you can also do some ordering checks, such as "no pair should have greater confidence than the one from the exact match pair", or "the pair that matches all consonants should be >= the only vowels one".

like image 112
Javier Avatar answered Jan 27 '26 00:01

Javier