Skip to content

[Feature] Custom dictionary for names, jargon, and product terms #2

Description

@ryleydotmp3

A user-editable word list that feeds the same SymSpell index the shipped frequency dictionaries use.

Words that aren't in the shipped dictionary (names, product names, domain jargon) currently degrade suggestions in four separate ways, and reading through it, all four go through SymSpell.words / SymSpell.deletes:

  1. Autocorrect rewrites the word into a dictionary neighbour (Engine.swift:848 -> SpellChecker.correct)
  2. The typo gate skips generation entirely after an unknown completed word (Engine.swift:1253)
  3. reconcileMidWord rejects a mid-word completion when partial+fragment isn't a known prefix (Engine.swift:984)
  4. No instant dictionary ghost for the term (SymSpell.topCompletion, SymSpell.swift:52)

Number 3 already has a workaround at Engine.swift:973-982 that rescues the completion if the word happens to be visible on screen, so I assume this is a known rough edge.

How does Cotypist or another tool handle it? (optional)

macOS has "Learn Spelling" via NSSpellChecker, but that writes to the system-wide dictionary and can't do frequency-ranked prefix completion, so it wouldn't cover number 4.

Anything else

Rough sketch of the approach:

  • SymSpell.add(words:frequency:) inserting into words and running editsPrefix into deletes
  • Called from SpellChecker.ensureLoaded rather than once at startup, so custom words survive the maxLoaded = 2 LRU eviction and index rebuild
  • Word list editor in the Personalization pane
  • The assigned frequency has to land above the best.freq >= 1000 gate in topCompletion, or custom words never produce an instant ghost

Happy to open a PR if you're interested. Two things I'd want your call on first: whether the word list should be per-language or global, and whether you'd want it to also suppress autocorrect (number 1) or only affect completion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions