-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose stream parameter in public nvtext ngram APIs (#14061)
Add stream parameter to public APIs: - `nvtext::generate_ngrams()` - `nvtext::generate_character_ngrams()` - `nvtext::hash_character_ngrams()` - `nvtext::ngrams_tokenize()` Also cleaned up some of the doxygen comments. And also fixed a spelling mistake in the jaccard.cu source that was bothering me. Reference #13744 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Yunsong Wang (https://github.com/PointKernel) - Vyas Ramasubramani (https://github.com/vyasr) URL: #14061
- Loading branch information
1 parent
98b1bc6
commit f865c87
Showing
11 changed files
with
135 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <nvtext/generate_ngrams.hpp> | ||
#include <nvtext/ngrams_tokenize.hpp> | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/default_stream.hpp> | ||
|
||
class TextNGramsTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(TextNGramsTest, GenerateNgrams) | ||
{ | ||
auto const input = | ||
cudf::test::strings_column_wrapper({"the", "fox", "jumped", "over", "thé", "dog"}); | ||
auto const separator = cudf::string_scalar{"_", true, cudf::test::get_default_stream()}; | ||
nvtext::generate_ngrams( | ||
cudf::strings_column_view(input), 3, separator, cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(TextNGramsTest, GenerateCharacterNgrams) | ||
{ | ||
auto const input = | ||
cudf::test::strings_column_wrapper({"the", "fox", "jumped", "over", "thé", "dog"}); | ||
nvtext::generate_character_ngrams( | ||
cudf::strings_column_view(input), 3, cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(TextNGramsTest, HashCharacterNgrams) | ||
{ | ||
auto input = | ||
cudf::test::strings_column_wrapper({"the quick brown fox", "jumped over the lazy dog."}); | ||
nvtext::hash_character_ngrams( | ||
cudf::strings_column_view(input), 5, cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(TextNGramsTest, NgramsTokenize) | ||
{ | ||
auto input = | ||
cudf::test::strings_column_wrapper({"the quick brown fox", "jumped over the lazy dog."}); | ||
auto const delimiter = cudf::string_scalar{" ", true, cudf::test::get_default_stream()}; | ||
auto const separator = cudf::string_scalar{"_", true, cudf::test::get_default_stream()}; | ||
nvtext::ngrams_tokenize( | ||
cudf::strings_column_view(input), 2, delimiter, separator, cudf::test::get_default_stream()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters