Remove empty elements from exploded character-ngrams output #15371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes
character_ngrams
function to not include empty entries whenas_list=False
. That is, the exploded view (non-list result) should not contain empty or NA elements.This PR changes the
nvtext::generate_character_ngrams()
API to return a lists column instead of a flat strings column. The python code had been converting the return object into lists column and then exploding it ifas_list=False
. Returning as a list column simplifies the logic and prevents the double conversion. There is almost no impact to the nvtext code since the offsets for the output lists column were already being generated.All tests were updated to expect the new result. Also changed some exception types from
cudf::logic_error
tostd::invalid_argument
as appropriate.Continues work of abandoned PR #14685
Checklist