Repository navigation
Rename unicode_word tokenizer to unicodeWord and improve docs - #99837
Conversation
|
Workflow [PR], commit [379ef72] Summary: ❌
AI ReviewSummaryThis PR renames tokenizer Findings
Tests
ClickHouse Rules
Final Verdict
|
860fbf8 to
048382b
Compare
| @@ -170,7 +170,7 @@ ALTER TABLE table DROP INDEX text_idx; | |||
| Compared to `ngrams(N)`, the `sparseGrams` tokenizer produces variable-length N-grams, allowing for a more flexible representation of the original text. | |||
| For example, `tokenizer = sparseGrams(3, 5, 4)` internally generates 3-, 4-, 5-grams from the input string but only the 4- and 5-grams are returned. | |||
| - `array` performs no tokenization, i.e. every row value is a token (see function [array](/sql-reference/functions/array-functions.md/#array)). | |||
| - `unicode_word` splits strings into tokens using Unicode word boundary rules (similar to UAX #29). ASCII alphanumeric characters and underscores form tokens with connectors (`:` for letters, `.` and `'` for same-type characters). Non-ASCII Unicode characters become single-character tokens. Stop words (configurable, defaults to common CJK punctuation) are skipped. An optional parameter `stop_words` can be specified as an array of strings, for example, `tokenizer = unicode_word([',', '。'])`. | |||
| - `unicodeWord` splits strings into tokens using Unicode word boundary rules (similar to [Unicode Text Segmentation (UAX #29)](https://unicode.org/reports/tr29/)). ASCII alphanumeric characters and underscores form tokens with connectors (ASCII `:` for letters, `.` and `'` for same-type characters). Non-ASCII Unicode characters, including [CJK](https://en.wikipedia.org/wiki/CJK_characters) characters, become single-character tokens. An optional parameter (for example, `tokenizer = unicodeWord([',', '。'])`) specifies character sequences that are ignored, i.e. stopwords. The default skipped characters are: `,` `。` `!` `?` `;` `:` `、` `'` `'` `"` `"` (common CJK punctuation and typographic quotation marks). | |||
There was a problem hiding this comment.
The default skipped quote characters documented here do not match the implementation.
TokenizerFactory currently initializes unicodeWord stop words with typographic quotes (‘ ’ “ ”), but this line lists straight ASCII quotes (' ' " "). That is user-visible and can mislead debugging of tokenization behavior.
Please update this sentence to list the actual defaults from code (or avoid enumerating them inline and link to the source/system.tokenizers docs).
There was a problem hiding this comment.
Fixed, the quotes are now the actual typographic characters (U+2018, U+2019, U+201C, U+201D).
048382b to
6f256c1
Compare
Sure. We should probably get both merged before the 26.3 release. |
|
Another minor thing I noticed: The docs have this sentence which is now no longer true: |
6f256c1 to
f7948f8
Compare
|
Updated the "Working with non-ASCII inputs" section — removed the outdated CJK warning and pointed to the |
f7948f8 to
510c2ba
Compare
| {"n", "Only relevant if argument `tokenizer` is `ngrams`: An optional parameter which defines the length of the ngrams. If not set explicitly, defaults to `3`.", {"const UInt8"}}, | ||
| {"separators", "Only relevant if argument `tokenizer` is `split`: An optional parameter which defines the separator strings. If not set explicitly, defaults to `[' ']`.", {"const Array(String)"}}, | ||
| {"min_length", "Only relevant if argument `tokenizer` is `sparseGrams`: An optional parameter which defines the minimum gram length, defaults to 3.", {"const UInt8"}}, | ||
| {"max_length", "Only relevant if argument `tokenizer` is `sparseGrams`: An optional parameter which defines the maximum gram length, defaults to 100.", {"const UInt8"}}, | ||
| {"min_cutoff_length", "Only relevant if argument `tokenizer` is `sparseGrams`: An optional parameter which defines the minimum cutoff length.", {"const UInt8"}}, | ||
| {"stop_words", "Only relevant if argument `tokenizer` is `unicodeWord`: An optional parameter which defines the stop words. If not set explicitly, defaults to common CJK punctuation marks.", {"const Array(String)"}}, |
There was a problem hiding this comment.
tokens documentation now advertises unicodeWord with optional stop_words, but the resolver logic still rejects that argument.
In getReturnTypeImpl, the arguments.size() == 3 branch only permits the 3rd argument for ngrams and splitByString; unicodeWord is not handled there. So calls like tokens('x', 'unicodeWord', ['and']) still fail argument validation even though this PR adds docs/tests expecting them to work.
Please either:
- add
unicodeWordhandling in argument validation (and corresponding tokenizer-construction support), or - remove
stop_wordsfrom docs/tests in this PR.
There was a problem hiding this comment.
Removed all stop_words references from this PR. Stop words support is in #99834.
510c2ba to
d6e3c13
Compare
|
@Ergus It looks like |
|
Something in the sync PR went wrong, I closed it, it will be re-created in a few minutes (theoretically). |
Follow-up to PR ClickHouse#99357 addressing post-merge review comments: - Rename `unicode_word` to `unicodeWord` for naming consistency with other tokenizers - Add link to Unicode Text Segmentation (UAX ClickHouse#29) spec in docs - Add link to CJK Wikipedia article in docs - Rewrite stop words documentation with explicit default character list - Add `unicodeWord` to valid tokenizer lists in `hasAnyTokens`/`hasAllTokens` docs - Clarify comments: ASCII-only connectors, CJK as single-char tokens, split validity rules - Add `unicodeWord` tests to 03403_function_tokens and 02346_text_index_creation
…stop words removal Revert accidental submodule pointer changes for libstemmer_c, NuRaft, and rust_vendor that leaked in during rebase. Update test references to reflect that stop words were removed from unicodeWord tokenizer by PR ClickHouse#99834: fullwidth comma is now returned as a token, and the stop-words-as-argument test case is removed.
e660cab to
379ef72
Compare
george-larionov
left a comment
There was a problem hiding this comment.
Looks good according to two other reviewers, I've rebased on top of the recent stop_words changes.
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 97.30% (36/37, 0 noise lines excluded) |
323bf0d
Summary
Follow-up to #99357 addressing post-merge review feedback from @rschu1ze.
unicode_word→unicodeWordfor naming consistency with other tokenizers (splitByNonAlpha,ngrams,sparseGrams)unicodeWord([',', '。'])exampleunicodeWordto valid tokenizer lists inhasAnyTokens/hasAllTokensdoc stringsITokenizer.h: ASCII-only connectors withU+003A, CJK as single-char tokens, split validity rules for ASCII vs non-ASCII tokensunicodeWordtests to03403_function_tokensand02346_text_index_creationChangelog category (leave one):
Changelog entry (a user-readable short description of the changes):
Not for changelog.
Version info
26.4.1.59