libcudf  23.12.00
tokenize.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <cudf/column/column.hpp>
19 #include <cudf/scalar/scalar.hpp>
21 
22 namespace nvtext {
59 std::unique_ptr<cudf::column> tokenize(
60  cudf::strings_column_view const& input,
61  cudf::string_scalar const& delimiter = cudf::string_scalar{""},
64 
95 std::unique_ptr<cudf::column> tokenize(
96  cudf::strings_column_view const& input,
97  cudf::strings_column_view const& delimiters,
100 
126 std::unique_ptr<cudf::column> count_tokens(
127  cudf::strings_column_view const& input,
128  cudf::string_scalar const& delimiter = cudf::string_scalar{""},
131 
158 std::unique_ptr<cudf::column> count_tokens(
159  cudf::strings_column_view const& input,
160  cudf::strings_column_view const& delimiters,
163 
184 std::unique_ptr<cudf::column> character_tokenize(
185  cudf::strings_column_view const& input,
188 
223 std::unique_ptr<cudf::column> detokenize(
224  cudf::strings_column_view const& input,
225  cudf::column_view const& row_indices,
226  cudf::string_scalar const& separator = cudf::string_scalar(" "),
229 
252 
253  struct tokenize_vocabulary_impl;
254  tokenize_vocabulary_impl* _impl{};
255 };
256 
270 std::unique_ptr<tokenize_vocabulary> load_vocabulary(
271  cudf::strings_column_view const& input,
274 
300 std::unique_ptr<cudf::column> tokenize_with_vocabulary(
301  cudf::strings_column_view const& input,
302  tokenize_vocabulary const& vocabulary,
303  cudf::string_scalar const& delimiter,
304  cudf::size_type default_id = -1,
307  // end of tokenize group
309 } // namespace nvtext
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
An owning class to represent a string in device memory.
Definition: scalar.hpp:429
Given a column-view of strings type, an instance of this class provides a wrapper on this compound co...
Class definition for cudf::column.
device_memory_resource * get_current_device_resource()
std::unique_ptr< cudf::column > tokenize_with_vocabulary(cudf::strings_column_view const &input, tokenize_vocabulary const &vocabulary, cudf::string_scalar const &delimiter, cudf::size_type default_id=-1, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Returns the token ids for the input string by looking up each delimited token in the given vocabulary...
std::unique_ptr< cudf::column > detokenize(cudf::strings_column_view const &input, cudf::column_view const &row_indices, cudf::string_scalar const &separator=cudf::string_scalar(" "), rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Creates a strings column from a strings column of tokens and an associated column of row ids.
std::unique_ptr< cudf::column > count_tokens(cudf::strings_column_view const &input, cudf::string_scalar const &delimiter=cudf::string_scalar{""}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Returns the number of tokens in each string of a strings column.
std::unique_ptr< tokenize_vocabulary > load_vocabulary(cudf::strings_column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Create a tokenize_vocabulary object from a strings column.
std::unique_ptr< cudf::column > character_tokenize(cudf::strings_column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Returns a single column of strings by converting each character to a string.
std::unique_ptr< cudf::column > tokenize(cudf::strings_column_view const &input, cudf::string_scalar const &delimiter=cudf::string_scalar{""}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Returns a single column of strings by tokenizing the input strings column using the provided characte...
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
NVText APIs.
Class definitions for cudf::scalar.
Class definition for cudf::strings_column_view.
Vocabulary object to be used with nvtext::tokenize_with_vocabulary.
Definition: tokenize.hpp:235
tokenize_vocabulary(cudf::strings_column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Vocabulary object constructor.