You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simplified Chinese doesn't split words or allow splitting words #278
Describe the bug
Adding & opening a Simplified Chinese shows the following. There's no ability to select a character or character-grouping & add or otherwise track vocabulary.
To Reproduce
Steps to reproduce the behavior:
Add a text in simplified chinese
Open the text
Note no ability to select characters
Expected behavior
I don't actually know what the expected behavior is for Chinese, but I would expect to somehow be able to track vocabulary.
Screenshots
Server (please complete)
Server
LWT version v003004002
Web Server Apache/2.4.68 (Debian)
Server Software Apache/2.4.68
Server Location http://localhost:8010
PHP Version 8.4.24
Database
Database name learning-with-texts
Database Size 209.6 MB
MySQL Version 12.1.2-MariaDB-ubu2404
Client API
REST API Version 3.4.2
REST API Release date 2026-08-16
Hi, for Chinese the easiest solution for now is to pass your text to an external parser to separate words and add spaces. You can have two chinese languages : one with space separation, and one without, depending of the text you want to read.
If you are ready to use some experimental feature, there is built-in support for jieba, a parser for mandarin Chinese, see the external parsers page. However I don't have much time to maintain this feature, so expect some rough edges. PRs welcome!
Cause. A language written without spaces gives the regex tokenizer nothing to match on, so it takes the longest run of word characters it can find — with no gaps, that is the whole sentence:
That is the reported "no ability to select a character or character-grouping", and the second half of the title follows from the first — you cannot select a grouping out of a sentence that is already one token.
Fix. Reaching StandardTextParser at all means no tokenizer ran (MeCab goes to JapaneseTextParser; an opted-in parser either handled the text or was unavailable). At that point a spaceless language has one way left to find boundaries, and it is the one the presets already encode: Chinese (Simplified), Chinese (Traditional) and Japanese are the only presets setting removeSpaces, all three also set makeCharacterWord, and no other preset sets it at all. getOptedInParserFromRow() already documents that it falls back on "their split-each-character setting"; getLanguageSettings() now makes that hold for a language that lost the flag or never had it.
Verification. On a real corpus of 13 texts, the same Chinese text on two differently configured Chinese languages went from 78 and 103 words to 103 and 103; Thai went 8 → 19; French, German, Japanese, Korean and Hebrew were unchanged. 北京大学, 图书馆 and 天气 are all detected as multi-character terms once the text is segmented, which covers the "or allow splitting words" half. Four DB-backed regression tests added; PHPUnit 9073 passing, Cypress 304 passing, Psalm clean.
One case deliberately not covered. A Chinese language whose LgRemoveSpaces is 0 still produces sentence-words — that is the language asserting its words are space-separated, and no fallback can infer around a statement the configuration makes about itself. Detecting it from token output alone is not reliable (one long word per sentence is indistinguishable from a legitimate one-word sentence), so it would need the config fact rather than a heuristic. The reported path — a language created from the Simplified Chinese preset, which sets removeSpaces: true — is covered.
Activity
HugoFara commentedon Aug 23, 2026
Hi, for Chinese the easiest solution for now is to pass your text to an external parser to separate words and add spaces. You can have two chinese languages : one with space separation, and one without, depending of the text you want to read.
If you are ready to use some experimental feature, there is built-in support for jieba, a parser for mandarin Chinese, see the external parsers page. However I don't have much time to maintain this feature, so expect some rough edges. PRs welcome!
fix(language): make the parser setting real, and Chinese use jieba (#278
sarahmccuan commentedon Aug 24, 2026
I'll check it out, thanks.
Merge pull request #281 from HugoFara/fix/278-wire-parser-registry
Merge pull request #282 from HugoFara/feat/278-warn-when-a-text-parse…
fix(text): judge a parse by its letters, not its length
fix(text): split spaceless languages that have no tokenizer
HugoFara commentedon Aug 31, 2026
Fixed on
developin 81a704c.Cause. A language written without spaces gives the regex tokenizer nothing to match on, so it takes the longest run of word characters it can find — with no gaps, that is the whole sentence:
That is the reported "no ability to select a character or character-grouping", and the second half of the title follows from the first — you cannot select a grouping out of a sentence that is already one token.
Fix. Reaching
StandardTextParserat all means no tokenizer ran (MeCab goes toJapaneseTextParser; an opted-in parser either handled the text or was unavailable). At that point a spaceless language has one way left to find boundaries, and it is the one the presets already encode: Chinese (Simplified), Chinese (Traditional) and Japanese are the only presets settingremoveSpaces, all three also setmakeCharacterWord, and no other preset sets it at all.getOptedInParserFromRow()already documents that it falls back on "their split-each-character setting";getLanguageSettings()now makes that hold for a language that lost the flag or never had it.Verification. On a real corpus of 13 texts, the same Chinese text on two differently configured Chinese languages went from 78 and 103 words to 103 and 103; Thai went 8 → 19; French, German, Japanese, Korean and Hebrew were unchanged. 北京大学, 图书馆 and 天气 are all detected as multi-character terms once the text is segmented, which covers the "or allow splitting words" half. Four DB-backed regression tests added; PHPUnit 9073 passing, Cypress 304 passing, Psalm clean.
One case deliberately not covered. A Chinese language whose
LgRemoveSpacesis0still produces sentence-words — that is the language asserting its words are space-separated, and no fallback can infer around a statement the configuration makes about itself. Detecting it from token output alone is not reliable (one long word per sentence is indistinguishable from a legitimate one-word sentence), so it would need the config fact rather than a heuristic. The reported path — a language created from the Simplified Chinese preset, which setsremoveSpaces: true— is covered.