From bb554e9c0beb14833c89aa8af321c96e8f4544e6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 1 Aug 2024 09:18:43 -0700 Subject: [PATCH 1/4] add docs for capitalize --- .../_lib/pylibcudf/strings/capitalize.pyx | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx b/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx index d3f79088018..c179446c6b9 100644 --- a/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx +++ b/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx @@ -22,7 +22,22 @@ cpdef Column capitalize( # TODO: default scalar values # https://github.com/rapidsai/cudf/issues/15505 ): - + """Returns a column of capitalized strings. + + For details, see :cpp:func:`cudf::strings::capitalize`. + + Parameters + ---------- + input : Column + String column + delimiters : Scalar, default None + Characters for identifying words to capitalize + + Returns + ------- + pylibcudf.Column + Column of strings capitalized from the input column + """ cdef unique_ptr[column] c_result if delimiters is None: @@ -47,6 +62,23 @@ cpdef Column title( Column input, string_character_types sequence_type=string_character_types.ALPHA ): + """Modifies first character of each word to upper-case and lower-cases + the rest. + + For details, see :cpp:func:`cudf::strings::title`. + + Parameters + ---------- + input : Column + String column + sequence_type : string_character_types, default string_character_types.ALPHA + The character type that is used when identifying words + + Returns + ------- + pylibcudf.Column + Column of titled strings + """ cdef unique_ptr[column] c_result with nogil: c_result = cpp_capitalize.title(input.view(), sequence_type) @@ -55,6 +87,20 @@ cpdef Column title( cpdef Column is_title(Column input): + """Checks if the strings in the input column are title formatted. + + For details, see :cpp:func:`cudf::strings::is_title`. + + Parameters + ---------- + input : Column + String column + + Returns + ------- + pylibcudf.Column + Column of type BOOL8 + """" cdef unique_ptr[column] c_result with nogil: c_result = cpp_capitalize.is_title(input.view()) From 86bf0256c105c8ddabb52f6fbae7a669b265c374 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 1 Aug 2024 12:23:12 -0700 Subject: [PATCH 2/4] add docs --- .../user_guide/api_docs/pylibcudf/strings/capitalize.rst | 6 ++++++ .../user_guide/api_docs/pylibcudf/strings/char_types.rst | 6 ++++++ .../source/user_guide/api_docs/pylibcudf/strings/find.rst | 6 ++++++ .../source/user_guide/api_docs/pylibcudf/strings/index.rst | 5 +++++ .../user_guide/api_docs/pylibcudf/strings/regex_flags.rst | 6 ++++++ .../user_guide/api_docs/pylibcudf/strings/regex_program.rst | 6 ++++++ 6 files changed, 35 insertions(+) create mode 100644 docs/cudf/source/user_guide/api_docs/pylibcudf/strings/capitalize.rst create mode 100644 docs/cudf/source/user_guide/api_docs/pylibcudf/strings/char_types.rst create mode 100644 docs/cudf/source/user_guide/api_docs/pylibcudf/strings/find.rst create mode 100644 docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_flags.rst create mode 100644 docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_program.rst diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/capitalize.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/capitalize.rst new file mode 100644 index 00000000000..578b2b75e37 --- /dev/null +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/capitalize.rst @@ -0,0 +1,6 @@ +========== +capitalize +========== + +.. automodule:: cudf._lib.pylibcudf.strings.capitalize + :members: diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/char_types.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/char_types.rst new file mode 100644 index 00000000000..577ec34915b --- /dev/null +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/char_types.rst @@ -0,0 +1,6 @@ +========== +char_types +========== + +.. automodule:: cudf._lib.pylibcudf.strings.char_types + :members: diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/find.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/find.rst new file mode 100644 index 00000000000..61d4079e9a3 --- /dev/null +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/find.rst @@ -0,0 +1,6 @@ +==== +find +==== + +.. automodule:: cudf._lib.pylibcudf.strings.find + :members: diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/index.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/index.rst index cecf1ccc9bb..462a756a092 100644 --- a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/index.rst +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/index.rst @@ -4,6 +4,11 @@ strings .. toctree:: :maxdepth: 1 + capitalize + char_types contains + find + regex_flags + regex_program replace slice diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_flags.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_flags.rst new file mode 100644 index 00000000000..0126b6a3706 --- /dev/null +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_flags.rst @@ -0,0 +1,6 @@ +=========== +regex_flags +=========== + +.. automodule:: cudf._lib.pylibcudf.strings.regex_flags + :members: diff --git a/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_program.rst b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_program.rst new file mode 100644 index 00000000000..2f398186d51 --- /dev/null +++ b/docs/cudf/source/user_guide/api_docs/pylibcudf/strings/regex_program.rst @@ -0,0 +1,6 @@ +============= +regex_program +============= + +.. automodule:: cudf._lib.pylibcudf.strings.regex_program + :members: From 1bbd0e0536acc100206fbcf4f9c09c6db8c7eab6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 1 Aug 2024 14:12:09 -0700 Subject: [PATCH 3/4] fixes --- .../_lib/pylibcudf/strings/regex_program.pyx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx b/python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx index d605b0aba02..5f0b8868452 100644 --- a/python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx +++ b/python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx @@ -13,12 +13,31 @@ from cudf._lib.pylibcudf.strings.regex_flags cimport regex_flags cdef class RegexProgram: + """Regex program class. + This is the Cython representation of + :cpp:class:`cudf::strings::regex_program`. + + Do not instantiate this class directly, use the `create` method. + + """ def __init__(self, *args, **kwargs): raise ValueError("Do not instantiate RegexProgram directly, use create") @staticmethod def create(str pattern, int flags): + """Create a program from a pattern. + + For detils, see :cpp:func:`cudf::strings::regex_program::create`. + + Parameters + ---------- + pattern : str + Regex pattern + flags : Uniont[int, RegexFlags] + Regex flags for interpreting special characters in the pattern + + """ cdef unique_ptr[regex_program] c_prog cdef regex_flags c_flags cdef string c_pattern = pattern.encode() From 9e043da068200449b478f0702efb438484b91a54 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:11:34 -0700 Subject: [PATCH 4/4] Update python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx --- python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx b/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx index c179446c6b9..ccf84d25572 100644 --- a/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx +++ b/python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx @@ -100,7 +100,7 @@ cpdef Column is_title(Column input): ------- pylibcudf.Column Column of type BOOL8 - """" + """ cdef unique_ptr[column] c_result with nogil: c_result = cpp_capitalize.is_title(input.view())