openstenoproject/plover

Allow two apostrophe-separated words in a single keystroke

Closed this issue · 10 comments

Hello,
I would like to request a feature:

The premise:

For certain languages, articles that go placed before a noun or adjective that starts with a vowel (eg. le appétit) can get contracted (into l'appétit).
This means that contracting an expression like l'appétit would take the steno strokes from L{apostropheKey}/A/PE/TI (pronounced le appétit) to L{apostropheKey}A/PE/TI. Given that french and italian are full of these little contractions, it would save a lot of keystrokes to be able to have contracted articles and vowel-starting words into a single stroke. A few more examples:
L{apostropheKey}An: l'an (tr: the year)
J{apostropheKey}A/T*Or: j'adore

What's the use:

To give perspective on how common this syntax is: in french and italian, every noun and adjective is preceded by an article, and every article preceding a vowel-started noun/adjective is contracted. That's a solid 50% of sentences - just about enough to make the subject impossible to ignore when trying to steno.
Though punctuations are not part of the layout in traditional sténo, the plug-in I'm developing would largely benefit from this: I designed a modified version of grandjean theory for ortholinear keyboards (sizes 40% and up), it uses very few letters, and thus the layout has plenty of available punctuation keys.
Other french and italian steno systems would benefit from this as well, given how widespread contractions are in these languages.

Alternatives I've considered:

The alternative to having a word-separating key (like apostrophe) would be to define every contraction explicitly in the dictionary. This is sadly not an option either: it would mean I'd have to have a special dictionary entry for every article contraction (le/la/les/de/du/des, etc.) in front of every vowel-starting-noun and adjective of the dictionary. That increases the size of the dictionary exponentially - which is not a good idea, though that's what the previous version of the grandjean plugin was doing.

functionality:

Having apostrophe-separated strokes assumes the following:

  1. The apostrophe-key must act as a word-boundary at its position in the steno-order. Using my current steno-order: S K P M T F * R N L {apostropheKey} Y O ^ E È A À U I l É n $ B D C # ß - any stroke following the pattern: [SKPMTFRNL]{apostropheKey}[YO^EÈAÀUIlÉn$BDC#ß] would be interpreted by plover as [SKPMTFRNL]{apostropheKey}{^}[YO^EÈAÀUIlÉn$BDC#ß].
  2. The strokes on the left-side of the apostrophe-key terminate a word, the ones on the right-side start a new one.
  3. Plover needs a notation to represent the keys on either side of the apostrophe-key as strokes. This is similar to the current way of handling conditionals that plover has ({=REGEXP/TRANSLATION_IF_MATCH/TRANSLATION_IF_NOT}) - with the notable difference that capture groups from the =REGEXP would have to be re-usable in the TRANSLATION_IF_MATCH.

Request:

Would it please be possible to have a word-separating key for this use?

I don't fully understand the request, but if I understood correctly you want that when you stroke e.g. L'A / PE / TI, then the A/PE/TI part is looked up in the dictionary independently of the L'.

One way is to use Python dictionary to handle that part I think, so the actual stored size does not increase exponentially. Another is to define it so that L'A is a Plover macro that inserts two strokes L' and A, although you would need to (re)implement how the undo macro works so that it deletes both of those strokes in one undo.

This function would be very useful also for the Michela system.

Thanks for your prompt response!
Looking at the documentation for macros seems a little cryptic atm: I get that macro functions receive a translator, a stroke and argument.

I would like to get the stroke split into two new strokes at a specific key (let's say H and each of these get output separately.
How do I do that?

indeed it is. You might want to contribute to the documentation (there's one at https://plover.readthedocs.io/en/latest/api/translation.html#plover.translation.Translator maintained by Jen, and also in docstrings of the source code. Personally I think it's better to generate documentation from source code docstrings, but the website does not do that), although I don't know how active is the maintainer.

Anyway, for now stick with looking at some example plugins that seems to do what you want (there's some list at https://github.com/openstenoproject/plover/wiki/Plugins and of course the plover plugin registry)

https://github.com/stenoshrink/plover_agnostic_toggle/blob/master/plover_agnostic_toggle.py#L25 so I guess you just call translate_stroke() twice with two constructed Stroke objects?

Thank you very much for pointing me in the right direction! I found the solution to include in my plugin:

def split_at_apostrophe(translator: Translator, stroke: Stroke, cmdline: str):
    apostrophe_postition = stroke.steno_keys.index(apostrophe_key)
    if apostrophe_postition > -1:
        translator.translate_stroke(
            Stroke(stroke.steno_keys[0:apostrophe_postition+1]))
        translator.translate_stroke(
            Stroke(stroke.steno_keys[apostrophe_postition+1]))

It's working wonders! Thank you!

Is your plugin available in the plugin manager?

Not yet, sorry I haven't taken any steps towards that yet. I have it here, though: https://github.com/AntoineBalaine/plover-split-at-apostrophe

For reference there's a guide to manually install plugin from GitHub repository Manually Installing Plugins · openstenoproject/plover Wiki