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

[SPARK-50963][ML][PYTHON][CONNECT] Support Tokenizers, SQLTransform and StopWordsRemover on Connect #49624

Closed
wants to merge 3 commits into from

Conversation

zhengruifeng
Copy link
Contributor

What changes were proposed in this pull request?

Support a group of text processing algorithms:

  • Tokenizer
  • RegexTokenizer
  • SQLTransform
  • StopWordsRemover

Why are the changes needed?

for feature parity

Does this PR introduce any user-facing change?

yes

How was this patch tested?

added tests

Was this patch authored or co-authored using generative AI tooling?

no

@@ -5072,7 +5073,7 @@ def __init__(
self._setDefault(
stopWords=StopWordsRemover.loadDefaultStopWords("english"),
caseSensitive=False,
locale=self._java_obj.getLocale(),
locale="en_US" if isinstance(self._java_obj, str) else self._java_obj.getLocale(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PySpark Classic calls the jvm side to get the default value

private val getDefaultOrUS: Locale = {
if (Locale.getAvailableLocales.contains(Locale.getDefault)) {
Locale.getDefault
} else {
logWarning(log"Default locale set was [${MDC(LogKeys.LOCALE, Locale.getDefault)}]; " +
log"however, it was not found in available locales in JVM, falling back to en_US locale. " +
log"Set param `locale` in order to respect another locale.")
Locale.US
}
}

which is not available in Connect Mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me rethink here, if we skip _setDefault locale, then remover.getLocale() fails if user does not explicitly set it, but it will reuse the default value in the jvm side.

zhengruifeng added a commit that referenced this pull request Jan 24, 2025
…nd StopWordsRemover on Connect

### What changes were proposed in this pull request?

Support a group of text processing algorithms:

- Tokenizer
- RegexTokenizer
- SQLTransform
- StopWordsRemover

### Why are the changes needed?
for feature parity

### Does this PR introduce _any_ user-facing change?
yes

### How was this patch tested?
added tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes #49624 from zhengruifeng/ml_connect_tokenizer.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
(cherry picked from commit 42b15c9)
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
@zhengruifeng
Copy link
Contributor Author

thanks. merged to master/4.0

@zhengruifeng zhengruifeng deleted the ml_connect_tokenizer branch January 24, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants