Setting Typing Costs
Este conteúdo não está disponível em sua língua ainda.
If a layout can type the same text more than one way, costs tell analysis which path to prefer. Most layouts use the default, which weighs the actions and movement needed to type a sequence. Override it only when you want the analysis to prefer different paths. Costs are relative weights, not measured typing times.
On Power, a brief wait lets you type “ab” at the start of a word even though the same presses ordinarily produce “an”. Compare
[layers.base]rules = [ { after_keys = ["a"], word_start = true, default_when_shadowed = "miss", set = { b = "n", c = "t", e = "s", f = "r", j = "b", s = "l", w = "g", y = "f" } },]The rule uses after_keys, word_start, default_when_shadowed, set. The standard cost model prices the resulting miss.
Power leaves [cost] out, so the built-in objective charges the normal action cost and an additional miss penalty for that wait. A custom objective replaces the entire default and will not price the wait unless the expressions account for it.
Cost Fields
Section titled “Cost Fields”| Field | Input and result |
|---|---|
cost.uni | One candidate keystroke. Return a positive integer. |
cost.bi | Two adjacent candidate keystrokes. Return a nonnegative integer, or use "0" to omit a bigram contribution. |
cost.tri | Three adjacent candidate keystrokes. Return a nonnegative integer, or use "0" to omit a trigram contribution. |
A custom objective needs all three cost expressions. Handle missing values explicitly; an undefined cost is not a zero. The default objective prices waits for a shadowed default. If your custom objective should do the same, use current.miss.count in uni with the penalty you intend. The expressions evaluate a single candidate window before a path is chosen; corpus frequencies are unavailable.
Use the editor diagnostics to check the expressions and compare a short typing sample before relying on corpus results. See Default and custom costs for the default prices.
Reference
Section titled “Reference”Analysis costs#
Omit [cost] for the shared default described in the layout usage guide. An explicit table overrides the complete objective; all three expressions are required and each runs on one candidate n-gram before a path is selected.
Unigram cost#
cost.uni
Prices one keystroke. Every evaluated result must be a positive integer.
Use 5 + 6 * current.miss.count to charge 5 for an ordinary event and 11 for a shadowed-default miss. This prices fallback access offered by default_when_shadowed = "miss"; it does not change which outputs are available.
Bigram cost#
cost.bi
Prices two adjacent keystrokes. Every evaluated result must be a nonnegative integer; use 0 to disable the contribution.
Trigram cost#
cost.tri
Prices three adjacent keystrokes. Every evaluated result must be a nonnegative integer; use 0 to disable the contribution.
Default and custom costs#
akp means active key pairs and ends means trigram endpoints. Custom costs have no automatic additions or scaling, and corpus frequency and weight are unavailable here.
[cost]
uni = "5"
bi = "akp.sf.count * 5"
tri = "ends.akp.sf.count"