-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[basicdataset] Fixed out of bound limit #1599
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1599 +/- ##
============================================
- Coverage 72.08% 70.88% -1.21%
- Complexity 5126 5406 +280
============================================
Files 473 504 +31
Lines 21970 23619 +1649
Branches 2351 2570 +219
============================================
+ Hits 15838 16743 +905
- Misses 4925 5594 +669
- Partials 1207 1282 +75
Continue to review full report at Codecov.
|
: questionInfo.answerIndexList.get(questionInfo.answerIndexList.size() - 1); | ||
textData.preprocess( | ||
manager, newTextData.subList(0, Math.min(lastIndex + 1, newTextData.size()))); | ||
int limit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments:
- avoid use
limit
as local variable, it's confusing because it's clash withthis.limit
- to avoid ArrayOutOfBoundException, the following should just work:
int index = Math.min(Math.toIntExact(limit), questionInfoList.size()) -1;
QuestionInfo questionInfo = questionInfoList.get(index);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll modify this.
basicdataset/src/main/java/ai/djl/basicdataset/nlp/StanfordQuestionAnsweringDataset.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Zach Kimberg <zachary@kimberg.com>
Description
In Stanford Question Answering Dataset the limit is specially handled, and there exists a severe bug that if the limit is too large (or the limit is set as default) it will cause an
IndexOutOfBoundException
.This PR fixed this bug and changed the test cases into a more strict one so that this bug will be detected.