Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 18.0Version 17.0 (current version)Version 16.0Version 15.0Version 14.0Version 13.0

On this page

Punctuation

The lexical models use two different kinds of punctuation:

  • Quotation marks around the “keep” suggestion.
  • What kind of space to insert after words, if any.

Both of these can be customized by adding the punctuation to model definition file. Here is a full example of a model definition file using default punctuation:

const source: LexicalModelSource = {
  format: 'trie-1.0',
  sources: ['wordlist.tsv'],
  // CUSTOMIZE THIS:
  punctuation: {
    quotesForKeepSuggestion: {
      open: "“", close: "”"
    },
    insertAfterWord: " ",
  },
  // other customizations go here:
};

export default source;

Customizing quotesForKeepSuggestion

These are the quotation marks that surrond the “keep” suggestion when it's displayed in the suggestion bar. By defaut, the quotations used are “smart” quotation marks used in English typography. Namely, the open quote is U+201C LEFT DOUBLE QUOTATION MARK, and the close quote is U+201D RIGHT DOUBLE QUOTATION MARK.

Let's customize this to use « and » for the open and close quote, respectively. To do this, change the part labeled quotesForKeepSuggestion:

punctuation: {
  quotesForKeepSuggestion: {
    open: "«", close: "»"
  },
},

Customizing insertAfterWord

Many languages insert a space after a word. Some languages, a like Thai or Khmer, do not use spaces. To suppress the space, you may set insertAfterWord to the empty string:

punctuation: {
  insertAfterWord: "",
},

You can even use an alternate spacing character, if required by your language:

punctuation: {
  insertAfterWord: "\u200B", // U+200B ZERO WIDTH SPACE
},

See also

The TypeScript definition of LexicalModelPunctuation


Return to “Advanced Lexical Model Topics”