Repository navigation
feat(bmj): add Ticuna (tca) lexical model - #358
Conversation
Word suggestions for the new Ticuna and Kaingang keyboards (keymanapp/keyboards#4218 and #4219). Word lists with frequencies come from official Brazilian translations by Indigenous translators (ECA/Youth Statute, ILO 169, SDGs and the 1988 Constitution; AGU legal glossary for Kaingang). The apostrophe (glottal stop) is part of the word; search ignores diacritics and apostrophes.
|
Thank you for your pull request. You'll see a "build failed" message until the Keyman team has reviewed the pull request and manually initiated the build process. Every change committed to this branch will become part of this pull request. When you have finished submitting files and are ready for the Keyman team to review this pull request, please post a "Ready for review" comment. |
|
Ready for review |
|
Thank you for your submission! |
|
Thanks @darcywong00! Noted about separate PRs: the later models (Kaiowá #359 and Nheengatu #360) were submitted one per PR. The readme.htm language is now pt-BR in all four models. Ready for review. |
|
Also added 50 author-supplied Ticuna words and names to the Ticuna wordlist (now 2,393 words), noted in README.md. Ready for review. |
darcywong00
left a comment
There was a problem hiding this comment.
Thanks for fixing the License files.
I'll be away for a week, but @jahorton will get around to reviewing the custom word breaker.
Appreciate your patience, as he's regularly full-time as the software developer for lexical-models.
| wordBreaker: { | ||
| use: function (text: string): Span[] { | ||
| const spans: Span[] = []; | ||
| const re = /[\p{L}\p{N}][\p{L}\p{M}\p{N}'’]*/gu; | ||
| let m: RegExpExecArray | null; | ||
| while ((m = re.exec(text)) !== null) { | ||
| spans.push({ start: m.index, end: m.index + m[0].length, length: m[0].length, text: m[0] }); | ||
| } | ||
| return spans; | ||
| } | ||
| }, |
There was a problem hiding this comment.
First things first, there is an issue here: custom functions should not be specified via the use: option as you have done here. Instead...
| wordBreaker: { | |
| use: function (text: string): Span[] { | |
| const spans: Span[] = []; | |
| const re = /[\p{L}\p{N}][\p{L}\p{M}\p{N}'’]*/gu; | |
| let m: RegExpExecArray | null; | |
| while ((m = re.exec(text)) !== null) { | |
| spans.push({ start: m.index, end: m.index + m[0].length, length: m[0].length, text: m[0] }); | |
| } | |
| return spans; | |
| } | |
| }, | |
| wordBreaker: function (text: string): Span[] { | |
| const spans: Span[] = []; | |
| const re = /[\p{L}\p{N}][\p{L}\p{M}\p{N}'’]*/gu; | |
| let m: RegExpExecArray | null; | |
| while ((m = re.exec(text)) !== null) { | |
| spans.push({ start: m.index, end: m.index + m[0].length, length: m[0].length, text: m[0] }); | |
| } | |
| return spans; | |
| } |
Setting custom wordbreaking functions via use: is unintended. Even if it does compile properly now, we can't guarantee it won't break in the future.
There was a problem hiding this comment.
This looks like it would cover the majority of cases we'd expect to see for your language, based on what I see in the wordlist. I do have a couple of questions to make sure this is sufficient, though.
What do abbreviations look like in your language? For example, in English, we might right e.g. or e.x. to indicate examples. Alternatively, consider typing out a website name, such as www.example.com. Would you want your model to keep those together as a "single word", or would those who write and type this language be fine with suggestions "starting over" after each period, as this wordbreaker implementation would do?
The same question arises with numbers: 3,000.48 would be split into 3, ,, 000, ., and 48, rather than treated as a single, whole number. Of course, numbers probably aren't in your wordlist... so this is probably fine.
If you would prefer wordbreaking to not occur in the middle of a URL or an abbreviation, we'd advise adding a small customization to the default word-breaker instead, per https://help.keyman.com/developer/current-version/guides/lexical-models/advanced/unicode-breaker-extension:
| wordBreaker: { | |
| use: function (text: string): Span[] { | |
| const spans: Span[] = []; | |
| const re = /[\p{L}\p{N}][\p{L}\p{M}\p{N}'’]*/gu; | |
| let m: RegExpExecArray | null; | |
| while ((m = re.exec(text)) !== null) { | |
| spans.push({ start: m.index, end: m.index + m[0].length, length: m[0].length, text: m[0] }); | |
| } | |
| return spans; | |
| } | |
| }, | |
| wordBreaker: function (text: string): Span[] { | |
| let customization = { | |
| /*** Character class overrides for specific characters ***/ | |
| propertyMapping: (char) => { | |
| // Treats the single-quote (apostrophe) only as a standard letter, | |
| // rather than like the English quotation-mark. | |
| // | |
| // This will keep it attached to any words it ends. | |
| if(char == '\'') { | |
| return "ALetter"; | |
| } else { | |
| // Treat every other character normally. | |
| return null; | |
| } | |
| }, | |
| }; | |
| /*** Applies the customization for actual use in wordbreaking ***/ | |
| return wordBreakers['default'](text, customization); | |
| }, |
There was a problem hiding this comment.
Thanks for catching this. Fixed in cde1c6a: wordBreaker is now the function itself, with no use:.
There was a problem hiding this comment.
Thanks, I'd rather keep URLs, abbreviations and numbers together, so cde1c6a uses your customization of the default breaker. It maps U+0027 to ALetter and also U+2019, since text pasted from PDFs often has the typographic apostrophe as the glottal stop. These languages are written in Latin script with Portuguese punctuation, so the UAX #29 defaults fit them.
Checked with the compiled model in KeymanWeb 18.0.255:
nü'ü̃ naca' pã'i→nü'ü̃|naca'|pã'i(the word-final glottal stays attached)Ngẽma i ü̃́ tchorü'ü̃→ combining marks stay with their letterswww.exemplo.com,3.000,48and10,50stay whole
Ready for review
| searchTermToKey: function (wordform: string): string { | ||
| let s = ''; | ||
| for (const ch of wordform) { | ||
| s += ch.toLowerCase(); | ||
| } | ||
| return s.normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/['’]/g, ''); |
There was a problem hiding this comment.
Per your submission description...
and a searchTermToKey that lowercases, strips diacritics and apostrophes (typing nuu suggests nü'ü̃, pai suggests pã'i).
This implementation only strips certain diacritics, though it does appear to cover the common cases I was able to find from your wordlist. Just to confirm, only cases like ó and ẽ are expected here?
I don't see any other cases near the top of your wordlist; I didn't read through the full thing in case rarer diacritics do appear.
There was a problem hiding this comment.
It strips every combining mark, not just some. After NFKD, every mark falls in U+0300–U+036F, and that whole range is removed. The range was written with the literal combining characters, so it rendered as [̀-ͯ] and was hard to read; cde1c6a writes it as \u0300-\u036f.
I checked every character in the four wordlists. After NFKD the only marks are:
- Ticuna: U+0300, U+0301, U+0303, U+0304, U+0308
- Kaingang: U+0301, U+0303, U+0304, U+0328
- Kaiowá (feat(bmj): add Kaiowá (kgk) lexical model #359): U+0301, U+0302, U+0303, U+0328
- Nheengatu (feat(bmj): add Nheengatu (yrl) lexical model #360): U+0301, U+0302, U+0303
So every key comes out as plain a–z.
There was a problem hiding this comment.
Thanks for the change in cde1c6a - it was hard to read as a character range with the combining characters and is much clearer with the Unicode escapes. 👍 That definitely helps with code clarity and ongoing maintenance.
Address review on keymanapp#358: assign the wordBreaker function directly instead of via 'use:', and build on the default UAX #29 breaker so abbreviations, URLs and numbers are handled; only the apostrophe (U+0027, U+2019) is remapped to ALetter so glottals stay inside words. Also clarify searchTermToKey: NFKD + stripping U+0300-U+036F removes all diacritics used in the wordlists (acute, grave, tilde, diaeresis, macron, ogonek), not just some. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015YPauqHVapcn1BMJU2JvPR
|
Ready for review |
jahorton
left a comment
There was a problem hiding this comment.
The models themselves look good to go, but it is our policy that each model be submitted in a separate PR. If you could put one of the two models in a separate PR and remove it from here, that would be most preferable.
| searchTermToKey: function (wordform: string): string { | ||
| let s = ''; | ||
| for (const ch of wordform) { | ||
| s += ch.toLowerCase(); | ||
| } | ||
| return s.normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/['’]/g, ''); |
There was a problem hiding this comment.
Thanks for the change in cde1c6a - it was hard to read as a character range with the combining characters and is much clearer with the Unicode escapes. 👍 That definitely helps with code clarity and ongoing maintenance.
Address review on keymanapp#358: assign the wordBreaker function directly instead of via 'use:', and build on the default UAX #29 breaker so abbreviations, URLs and numbers are handled; only the apostrophe (U+0027, U+2019) is remapped to ALetter so glottals stay inside words. Also clarify searchTermToKey: NFKD + stripping U+0300-U+036F removes all diacritics used in the wordlists (acute, grave, tilde, diaeresis, macron, ogonek), not just some.
Per review, each model goes in its own PR. bmj.kgp.kaingang is now in keymanapp#361 with the same files; this PR keeps only bmj.tca.ticuna.
cde1c6a to
290fbb3
Compare
Wordlist lexical model for the Kaingang keyboard (keymanapp/keyboards#4219), split out of #358 so that each model has its own PR. The files are the same as reviewed there, including the default word breaker with the apostrophe mapped to ALetter and the \u0300-\u036f range in searchTermToKey.
New wordlist lexical model
bmj.tca.ticunafor Ticuna (Tikuna, Magüta;tca) as written in Brazil. It is for the Ticuna keyboard in keymanapp/keyboards#4218.The Kaingang model that was first submitted here is now in its own PR, #361.
naca'), and URLs, abbreviations and numbers stay whole.searchTermToKeylowercases and strips diacritics (U+0300–U+036F after NFKD) and apostrophes, so typingnuusuggestsnü'ü̃.languageUsesCasing: true.Official acts are not protected by copyright in Brazil (Law 9,610/98, art. 8); the sources are listed in the README. Tested with KeymanWeb 18.0.255 together with the keyboard on simulated iPhone 13 and Pixel 7.
Modelo de palavras para o teclado Ticuna.