-
Notifications
You must be signed in to change notification settings - Fork 81
Implement "replace" transformation in Field operation module #879
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
base: main
Are you sure you want to change the base?
Conversation
Implements correct functionality for "replace" attirbute in mlc.Transform. It takes a string of the form "pattern/replacement" and peforms re.sub with `pattern` and `replacement`. Slashes can be escaped using a backslash, e.g, "my\/path/your\/path".
Implements correct functionality for "replace" attirbute in mlc.Transform. It takes a string of the form "pattern/replacement" and peforms re.sub with `pattern` and `replacement`. Slashes can be escaped using a backslash, e.g, "my\/path/your\/path".
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
I added my GitHub ID when signing up for the newsletter. Please let me know if there is anything else I have to do to sign the CLA. |
Hi @sebschu , thank you for your contribution! |
recheck |
Could you please also add details on this transformation to the new 1.1 specs? Thank you! |
python/mlcroissant/mlcroissant/_src/operation_graph/operations/field.py
Outdated
Show resolved
Hide resolved
Thank you! Looks great, and it seems that the CLA check passes now :) |
I fixed the two issues and added a brief description to the 1.1 specs draft. |
The "replace" transformation is currently not implemented. This is an implementation that allows users to specify a string of the form
pattern/replacement
to replace substitutereplacement
forpattern
. In the background it runsre.sub
, so match groups can be included in the replacement string.Slashes can be escaped using a backslash, e.g,
my\/path/your\/path
to replacemy/path
withyour/path
.Functional tests are implemented in
python/mlcroissant/mlcroissant/_src/operation_graph/operations/field_test.py
.I followed the syntax of
python/mlcroissant/mlcroissant/_src/structure_graph/nodes/source_test.py#L19
for the replacement string.