keymanapp / keymanapp/keyman

feat(web): better predictive-text punctuation handling 🚂

Open
#12,013 4 comments 0 reactions 1 assignee Claimed by @jahorton View on GitHub
epic-autocorrect feat web/ web/predictive-text/
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

### Is your feature request related to a problem? Please describe.

Related to #11963.

One minor pain point in our existing predictive-text engine is that if a user types a punctuation mark after an applied suggestion, any whitespace appended by the suggestion remains, rather than being replaced by the punctuation mark.

For example, with an English keyboard and our MTNT model, applying a suggestion for `this` and then typing `.` will result in `this .`, with the whitespace having been applied as part of the `this ` suggestion.

### Describe the solution you'd like

As different languages and scripts use different punctuation marks, I believe we should add a new field of some sort to lexical models (likely within the `punctuation` config object) that enumerate the language's punctuation marks. There's a chance we may want to associate properties with each, rather than assume they would all be handled the same way, though the latter would make a decent starting point toward a solution for the noted issue.
- For example, a hyphen (or dash?) shouldn't _replace_ whitespace. It's perfectly happy to leave it there and follow it. Though... perhaps this could be modeled by just... leaving it out of the new field.

Default behavior for any specified punctuation mark:
- Any token that exactly matches such a punctuation mark will be ignored by predictive text when making new suggestions.
- Any token that exactly matches such a punctuation mark will trigger whitespace replacement if it follows whitespace.
- Basically, #7163 (as noted below)
- Additional idea: we _could_ also treat it just like whitespace and start producing new suggestions that preserve the punctuation mark...
- Though if so, we may want an `insertBeforeWord` entry in the existing `punctuation` config object to automatically insert whitespace after the punctuation mark but before the new suggestion.

### Describe alternatives you've considered

_No response_

### Related issues

#11963

### Keyman apps

- [X] Keyman for Android
- [X] Keyman for iPhone and iPad
- [ ] Keyman for Linux
- [ ] Keyman for macOS
- [ ] Keyman for Windows
- [ ] Keyman Developer
- [X] KeymanWeb
- [ ] Other - give details at bottom of form

### Keyman version

current (as of 18.0.74-alpha)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.