Closed PLNech closed 6 years ago
@xVir, let me know if this looks good to you 🙂
@xVir any update/feedback on this?
Hi @PLNech Thank you for the pull request!
But what do you think about use Arrays.sort for sorting? https://stackoverflow.com/questions/13201573/sorting-an-array-using-comparator
Hi @xVir, thanks for your reply!
Good feedback, but what would you put in compare(String o1, String o2)
to have a pairwise comparison based on the rates?
I could write:
@Override public int compare(String o1, String o2) {
return rates[recognitionResults.indexOf(o2)] - rates[recognitionResults.indexOf(o1)];
}
But doing an index lookup for each comparison does not sound very efficient.
Ok, Thanks for your answer! Could you please add this unit test to the source code?
Thanks!
Hi @xVir, thanks for your answer.
I meant to add the test as-is, but as the tests don't have the same package name I can't test a protected
method from ai.api.test.XXXTest
. I'm left with a few options:
sortResultsByRate
to a SortHelper
class and write an SortHelperTest
sortResultsByRate
as a public
methodsortResultsByRate
as a private method Considering 1 and 2 would increase bloat in the project, I considered using reflection in one test case is an acceptable tradeoff (in my testing it still ran in an acceptable time, 0.024s
). Let me know if you have a better alternative!
Closing and reopening as #77 as since the project renaming I can't add new commits to this PR.
Sorts the
recognitionResults
in place, using an Optimized Bubble Sort.I wrote a test, but not being sure if you want to test
ai.api.services
I didn't create a new TestCase. Let me know if you want one wrapping the test code: