Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing pylibcudf strings docs #16471

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
capitalize
==========

.. automodule:: cudf._lib.pylibcudf.strings.capitalize
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
char_types
==========

.. automodule:: cudf._lib.pylibcudf.strings.char_types
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
====
find
====

.. automodule:: cudf._lib.pylibcudf.strings.find
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ strings
.. toctree::
:maxdepth: 1

capitalize
char_types
contains
find
regex_flags
regex_program
replace
slice
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
===========
regex_flags
===========

.. automodule:: cudf._lib.pylibcudf.strings.regex_flags
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=============
regex_program
=============

.. automodule:: cudf._lib.pylibcudf.strings.regex_program
:members:
48 changes: 47 additions & 1 deletion python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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
""""
lithomas1 marked this conversation as resolved.
Show resolved Hide resolved
cdef unique_ptr[column] c_result
with nogil:
c_result = cpp_capitalize.is_title(input.view())
Expand Down
19 changes: 19 additions & 0 deletions python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading