NVIDIA / NVIDIA/cudf

[FEA] Add `string_transforms` examples for `like` and `replace_re`

Open
#20,330 0 comments 0 reactions 1 assignee Claimed by @davidwendt View on GitHub
doc feature request libcudf strings
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**
We have a nice set of cuDF UDFs (user defined functions) in the [string transforms](https://github.com/rapidsai/cudf/tree/main/cpp/examples/string_transforms) examples.

Some users are interested in running strings functions including `like` and `replace_re`, but with higher throughput than the general-purpose APIs in cuDF.

**Describe the solution you'd like**

## LIKE

We should add an example UDF for `like`, using the pattern `%special%requests%` (derived from tpch Q13). This pattern is similar to an ordered, multi-contains. A transform UDF should be able to return correct results.

Sample data for this example:
```
ess packages. ironically final accounts nag. special instructions haggle acc
ions haggle carefully about the quickly bold theodolites-- furiously final f
uffily quiet instructions! unusual request
excuses boost boldly
structions. doggedly even dependencies are along the furiously busy hock
s x-ray slyly. blithely regular deposits detect slyly unusua
against the bold pinto beans are bli
phins against the blithely regular requests
e slyly after the packages. carefully express
ld deposits. carefully special deposits along the requests boost carefully iro
d deposits. carefully special deposits along the requests boost carefully iro
s promise idly ironic, special requests. carefu
n excuses. special requests sleep. silent dolphins
he unusual accounts. slyly special requests cajole furiously e
sublate special requests. slyly pending accounts sleep. special
ake after the blithely special foxes. pending, ironic requests thrash sl
quests. special, bold requests wake.
, pending requests was. furiously special requests haggle ironic, ironic a
ts wake blithely furiously special requests. d
posits. carefully special requests haggle carefully above the q
thely special requests. carefully ruthless requests will sl
the sometimes special requests are beside the final, ru
ly special instructions. fluffily ironic requests am
```

## REPLACE_RE

Another example is to redact email addresses in the context of text, using `replace_re`

here is a simple, permissive pattern: `[^\s@]+@[^\s@]+\.[^\s@]+`
another option: `[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+`

Sample data for this example:
```
support@company.com is the best way to reach our support team for assistance.
Please contact john.doe123@gmail.com or j.doe@work-email.com for more info.
For sales inquiries, email sales@tech-startup.io or call us directly.
Send your resume to jobs+engineering@acme.org for consideration.
You can reach customer service at help@shop.co.uk anytime.
Our team includes alice@example.com, bob@example.com, and charlie@example.com for support.
spam-filter-test_123@verification.net
The old contact was info@oldsite.com but now use contact@newsite.com instead.
admin@server-01.cloud.provider.com
Marketing campaigns should go to newsletter@promotions.biz for review.
webmaster@site.gov handles technical issues while support@site.gov handles user questions.
Anonymous tips can be sent to tips@investigation.news confidentially.
founder@startup.xyz was the original email but now we use contact@startup.xyz and hello@startup.xyz
s promise idly ironic, special requests. carefu
n excuses. special requests sleep. silent dolphins
legal.team@lawfirm.com
Subscribe to updates at subscribe@newsletter.io and never miss a post.
Report security issues to security-team@vendor.com or emergency@vendor.com or call security.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.