mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
What: the English and Spanish models (HEXKeyboard/TypingModel/en.hextm,
es.hextm, 3.6 MB each) are now built from Google Books Ngram v3 (CC BY
3.0) word and word-pair counts summed over 1980-2019, keeping only
words SCOWL (sizes up to 70, lowercase, ASCII) or RLA-ES (LibreOffice's
es_ES and es_MX dictionaries, MPL 1.1) accept, and are committed.
- English: 86,133 words, 417,480 word pairs; Spanish: 110,000 words,
326,366 pairs. Pairs are the ones that tell most over the single-word
model (count x log of P(b|a) over 0.4 P(b)), as many as fit.
- Format v3: pairs grouped by first word (u32 row starts, u32 second
word, u8 cost), 5 bytes a pair instead of 9, so ~70% more pairs fit
in the same size. TypingDecoderModel reads v3 only.
- scripts/build-typing-model.py downloads, counts (each ngram file
deleted once counted, every stage cached for a resumable rerun) and
writes a model: python build-typing-model.py <en|es> <workdir> <out>.
- Tuning for the new models (dev sentences): English leans more on the
word before (lmWeight 1.5; Parameters.tuned(for:)); an accent-only
change ("esta" -> "está") needs a 2-nat margin instead of 7 (ñ for n
isn't one: "ano"/"año"); an accented letter also reads from its base
key when it has its own (ñ from n), whichever is cheaper.
- Settings › Acknowledgements (new row and sheet, AcknowledgementsView)
and ios/README.md credit Google Books Ngram (CC BY 3.0), SCOWL with its
and WordNet's notices, and RLA-ES (MPL 1.1).
- AutocorrectEngineTests: decoder ranking cases on the bundled models
("need t^o" -> "need to", a missed space with a slip -> "see how",
correct words kept, Spanish "aqui manana" -> "aquí mañana", "esta"
kept).
Why: Ryan's licence decision: CC BY with credit, no share-alike, no
non-commercial or GPL/LGPL data, and not SymSpell's word-pair list
(unverified provenance). The Spanish model was built from Tatoeba,
the same corpus as its test set.
Removed: the SymSpell- and Tatoeba-built prototype models and the v2
format (pairs as sorted u64 keys); models are no longer gitignored.
Verified (Mac Studio, iPhone 18 Pro simulator, iOS 27.2; benchmark
harness outside the repo; word error rate on words that aren't names):
English held-out test, 13,870 words: today's engine 13.0%, decoder
3.6% (3.4% with tap offsets), correct words broken 4 -> 2 of 7,716;
labelled real typing logs, 172 words: 14.5% -> 4.1%; the shared
example sentence decodes exactly; Spanish held-out Tatoeba test (no
source shared with the model), 13,301 words: 25.7% -> 8.0%, broken
16 -> 20 of 7,246. Per letter p50 1.0 ms, p95 2.6 ms.
AutocorrectEngineTests 19 passed.
93 lines
4.2 KiB
Swift
93 lines
4.2 KiB
Swift
import SwiftUI
|
||
|
||
/// Settings › Acknowledgements: the data Hex ships, with the notices its licences ask for.
|
||
struct AcknowledgementsView: View {
|
||
@Environment(\.dismiss) private var dismiss
|
||
|
||
var body: some View {
|
||
NavigationStack {
|
||
ScrollView {
|
||
VStack(alignment: .leading, spacing: 20) {
|
||
ForEach(Self.entries, id: \.title) { entry in
|
||
VStack(alignment: .leading, spacing: 6) {
|
||
Text(entry.title)
|
||
.font(.system(size: 15, weight: .medium))
|
||
.foregroundStyle(HexTheme.textBase)
|
||
Text(entry.body)
|
||
.font(.system(size: 13))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
.textSelection(.enabled)
|
||
}
|
||
}
|
||
}
|
||
.padding(20)
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
.background(HexTheme.bgBase)
|
||
.navigationTitle("Acknowledgements")
|
||
.navigationBarTitleDisplayMode(.inline)
|
||
.toolbar {
|
||
ToolbarItem(placement: .confirmationAction) {
|
||
Button("Done") { dismiss() }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
struct Entry {
|
||
let title: String
|
||
let body: String
|
||
}
|
||
|
||
/// Spatial autocorrect's word lists (`scripts/build-typing-model.py`); keep in step with
|
||
/// ios/README.md.
|
||
static let entries: [Entry] = [
|
||
Entry(
|
||
title: "Google Books Ngram data",
|
||
body: """
|
||
Spatial autocorrect's word and word-pair frequencies come from the Google Books \
|
||
Ngram Viewer data, version 3 (2020), by Google, licensed under Creative Commons \
|
||
Attribution 3.0 (creativecommons.org/licenses/by/3.0). Hex sums the counts from \
|
||
1980 to 2019 and keeps only words in the lists below.
|
||
"""
|
||
),
|
||
Entry(
|
||
title: "SCOWL",
|
||
body: """
|
||
English words are checked against SCOWL (Spell Checker Oriented Word Lists) and \
|
||
VarCon by Kevin Atkinson, sizes up to 70 (wordlist.aspell.net).
|
||
|
||
Copyright 2000-2018 by Kevin Atkinson
|
||
|
||
Permission to use, copy, modify, distribute and sell these word lists, the \
|
||
associated scripts, the output created from the scripts, and its documentation \
|
||
for any purpose is hereby granted without fee, provided that the above copyright \
|
||
notice appears in all copies and that both that copyright notice and this \
|
||
permission notice appear in supporting documentation. Kevin Atkinson makes no \
|
||
representations about the suitability of this array for any purpose. It is \
|
||
provided "as is" without express or implied warranty.
|
||
|
||
SCOWL's inflections come from WordNet 1.6, Copyright 1997 by Princeton \
|
||
University. All rights reserved. THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" \
|
||
AND PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR \
|
||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO \
|
||
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR \
|
||
PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL \
|
||
NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. The \
|
||
name of Princeton University or Princeton may not be used in advertising or \
|
||
publicity pertaining to distribution of the software and/or database.
|
||
|
||
Its other sources (12Dicts, Moby Words II, and Brian Kelk's UK English Wordlist) \
|
||
are in the public domain.
|
||
"""
|
||
),
|
||
Entry(
|
||
title: "RLA-ES",
|
||
body: """
|
||
Spanish words are checked against RLA-ES, the Spanish spelling dictionaries for \
|
||
LibreOffice by Santiago Bosio and contributors (Spain and Mexico), used under the \
|
||
Mozilla Public License 1.1 (github.com/sbosio/rla-es).
|
||
"""
|
||
),
|
||
]
|
||
}
|