Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix: refactor getOrDefault call for API < 24
Browse files Browse the repository at this point in the history
  • Loading branch information
space-pope committed May 28, 2021
1 parent 62a6ba8 commit ddc0ba7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ private void loadVocab(String fileName) {
@Override
public int encodeSingle(String token) {
ensureReady();
return this.vocabulary.getOrDefault(token,
this.vocabulary.get(UNKNOWN));
Integer tokenId = this.vocabulary.get(token);
if (tokenId == null) {
tokenId = this.vocabulary.get(UNKNOWN);
}
return tokenId;
}

@Override
Expand Down

0 comments on commit ddc0ba7

Please sign in to comment.