Public Member Functions | List of all members
nvtext::unicode_normalizer Struct Reference

Normalizer object for Unicode TR15 normalization. More...

#include <nvtext/unicode_normalize.hpp>

Public Member Functions

 unicode_normalizer (cudf::table_view const &unicode_data, unicode_normalization_form form, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 Construct a unicode_normalizer from UnicodeData.txt columns. More...
 

Detailed Description

Normalizer object for Unicode TR15 normalization.

The normalizer is constructed from the contents of the Unicode Character Database UnicodeData.txt file, loaded by the caller as a cudf table (e.g. via cudf::io::read_csv).

The file is published by the Unicode Consortium and can be downloaded from: https://unicode.org/Public/15.1.0/ucd/UnicodeData.txt It is a semicolon-delimited file with 15 fields per row. The three fields required by this API are field 0 (code point hex), field 3 (CCC), and field 5 (decomposition mapping).

The unicode_data table must contain exactly three columns in the following order, corresponding to the fields above:

// typical workflow
.delimiter(';').header(-1)
.use_cols_indexes({0, 3, 5})
auto const ud = cudf::io::read_csv(in_opts);
auto normalizer = nvtext::create_unicode_normalizer(ud.tbl->view(), NFKC);
// the following can be called repeatedly on different strings columns with the same normalizer
auto result = nvtext::normalize_unicode(input_strings, *normalizer);
Indicator for the logical data type of an element in a column.
Definition: types.hpp:279
csv_reader_options_builder & delimiter(char delim)
Sets field delimiter.
Definition: csv.hpp:1037
csv_reader_options_builder & use_cols_indexes(std::vector< int > col_indices)
Sets indexes of columns to read.
Definition: csv.hpp:965
csv_reader_options_builder & header(size_type hdr)
Sets header row index.
Definition: csv.hpp:1013
Settings to use for read_csv().
Definition: csv.hpp:44
static csv_reader_options_builder builder(source_info src)
Creates a csv_reader_options_builder which will build csv_reader_options.
table_with_metadata read_csv(csv_reader_options options, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Reads a CSV dataset into a set of columns.
std::unique_ptr< cudf::column > normalize_unicode(cudf::strings_column_view const &input, unicode_normalizer const &normalizer, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Normalize a strings column using Unicode TR15 normalization.
std::unique_ptr< unicode_normalizer > create_unicode_normalizer(cudf::table_view const &unicode_data, unicode_normalization_form form, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a unicode_normalizer object.
@ STRING
String elements.
@ INT32
4 byte signed integer
Source information for read interfaces.
Definition: types.hpp:306

Decomposition of Hangul syllables (U+AC00..U+D7A3) is performed algorithmically per the Unicode standard and does not require entries in the provided table.

Composition exclusions (singletons, non-starter decompositions, and the ~70 Unicode-specified explicit exclusions) are computed internally.

Definition at line 76 of file unicode_normalize.hpp.

Constructor & Destructor Documentation

◆ unicode_normalizer()

nvtext::unicode_normalizer::unicode_normalizer ( cudf::table_view const &  unicode_data,
unicode_normalization_form  form,
cuda::stream_ref  stream = cudf::get_default_stream(),
rmm::device_async_resource_ref  mr = cudf::get_current_device_resource_ref() 
)

Construct a unicode_normalizer from UnicodeData.txt columns.

Parameters
unicode_dataTable with three columns as described above
formNormalization form to apply
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate internal tables

The documentation for this struct was generated from the following file: