VoiceGem

How to dictate a Go regexp with a backtick raw string

Go conventionally wraps patterns in backtick raw strings, which removes the escaping problem completely. VoiceGem turns “regexp dot pascal case must compile open paren backtick caret backslash w plus dollar sign backtick close paren” into a working call, with two quantifier spaces to remove.

A fifteen-word MustCompile call is about 17 seconds of typing against about 5.5 seconds of speech. (sources: Dhakal, Feit, Kristensson & Oulasvirta, “Observations on Typing from 136 Million Keystrokes”, CHI 2018, 168,000 participants, 136 million keystrokes; Yuan, Liberman & Cieri, “Towards an Integrated Understanding of Speaking Rate in Conversation”, Interspeech 2006, 2,438 American English telephone conversations (Switchboard corpus). The speech figure is conversational rate, not a measured dictation rate — no such measurement exists.)

What lands in your editor
slugPattern: = regexp.MustCompile(`^\w + $`)

This tool runs entirely in your browser. Nothing you type is sent anywhere, stored, or logged.

Step by step

  1. 1

    Declare with the short operator

    Say “camel case slug pattern colon equals”. The colon attaches left and the equals keeps its spacing, giving Go's short declaration.

  2. 2

    Say the package and function

    Speak “regexp dot pascal case must compile”. VoiceGem's period binds on both sides and the casing command builds the exported name.

  3. 3

    Wrap the pattern in backticks

    Say “backtick” either side. The character attaches on both sides, so the raw string closes up around the pattern with no gaps at the delimiters.

  4. 4

    Strip the quantifier spaces

    Close the gaps around plus and star. Anchors and escapes land clean; only the quantifiers need work.

Go raw strings remove the escaping problem that Java dictation has to work around

Backticks in Go mean no escape sequences are interpreted, so a pattern needs single backslashes rather than doubled ones. VoiceGem's backtick attaches on both sides, which means the delimiters close up perfectly and the pattern inside needs exactly what the regex needs and nothing more.

The contrast with Java is instructive. Java's dictation advantage is that saying “backslash backslash” is easier than counting backslashes; Go's advantage is that there is nothing to count. Language conventions decide how much the Deterministic Pass can help before it does anything.

Where the manual path breaks

The backtick key sits at the far top left of a US layout, which is a genuine reach, and Go asks for two of them on every pattern. Short patterns are still faster typed.

Anchored patterns with character classes are where speaking helps. A slug pattern with an anchor at each end, a bracketed class and a quantifier is punctuation from start to finish, and dictating it in VoiceGem at least puts the characters down in the order you intended them.

Doing this somewhere else? speech-to-code converter, on your own input, dictating Go doc comments, dictating Go functions specifically, or what changes for naming things in Go by voice.

Common questions

Yes. VoiceGem's backtick attaches on both sides, so the raw string closes up around the pattern with no gaps at either delimiter.

No. A backtick raw string interprets no escape sequences, so single backslashes are correct and there is nothing to count.

Quantifiers. Plus, star and brace quantifiers keep their spaces, so strip the whitespace before MustCompile runs.

Dictate an anchored slug pattern and check both backticks.

Open the tool