Skip to content

Commit

Permalink
[ML] fixing minor text categorization aggregation bug (#78629)
Browse files Browse the repository at this point in the history
  • Loading branch information
benwtrent authored Oct 4, 2021
1 parent f6fbeb8 commit 81aa483
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void collapseTinyChildren() {
return;
}
Optional<TreeNode> maybeWildChild = getChild(WILD_CARD_ID).or(() -> {
if ((double) smallestChild.peek().count / this.getCount() <= 1.0 / maxChildren) {
if (smallestChild.size() > 0 && (double) smallestChild.peek().count / this.getCount() <= 1.0 / maxChildren) {
TreeNode tinyChild = children.remove(smallestChild.poll().tokenId);
return Optional.of(addChild(WILD_CARD_ID, tinyChild));
}
Expand All @@ -267,7 +267,7 @@ void collapseTinyChildren() {
smallestChild.add(tinyNode);
break;
} else {
wildChild.mergeWith(children.remove(tinyNode.count));
wildChild.mergeWith(children.remove(tinyNode.tokenId));
}
}
}
Expand Down

0 comments on commit 81aa483

Please sign in to comment.