hex/ios/HEXMobile/AcknowledgementsView.swift
Ryan Vogel 21e6ffb5b1 iOS keyboard: never suggest or correct to slurs or swear words
The full keyboard's suggestion strip and autocorrect could offer and
autocorrect into profanity and slurs. They came from Spatial autocorrect's
Google Books v3 models (#2059): before this change, tapping "niggee" or
"nigget" at key centres was corrected to "nigger" on space, and "fucj" to
"fuck". Hex is rated 4+, and Apple's keyboard never offers these words.

- never-suggest.tsv: a copy of Hex for Android's curated LDNOOBW list
  (#2081, android/app/src/main/assets/typing/never-suggest.tsv). Its data
  lines match Android's entry for entry: en/es/de/nb, slur or swear, and *
  lines shared by every layout. Only the first comment line differs. It is
  credited in Settings > Acknowledgements (CC BY 4.0).
- OffensiveWords reads it for the layout's language. AutocorrectEngine
  checks it when a suggestion is looked up: UITextChecker guesses and
  completions, learned fixes, and the decoder's readings and replacement.
  Slurs are always blocked. Swear words are blocked unless allowsSwearing
  is set (the setting arrives in the next commit). A two-word expression
  ("blow job") is blocked as a pair, after its first word, never as its
  words alone.
- TypingDecoder.NeverSuggest flags model word indices at lookup time.
  The beam search walks through them but never returns them, and split
  readings skip blocked pairs. The models are unchanged, so a listed word
  still scores as a real word.
- A listed word typed in full is never autocorrected into another word.
- Your own UILexicon words (Contacts names, text replacements) are still
  offered, as on Apple's keyboard. Words Hex learned are not.

UITextChecker on iOS 27.2 already returns no offensive guesses or
completions for the probes tried (fuc, shiy, niggr, faggit, asshol...).
The filter covers that path too.

Verified on an iPhone 17 simulator (iOS 27.2): the full HEXMobileTests
suite ran 289 tests with 0 failures, skipping
FullKeyboardEngineTests.testEveryLayoutAsksForTheSameKeyHaptics, which
crashes the same way on origin/dev. New cases were added to
AutocorrectEngineTests.
2026-11-20 15:14:50 -05:00

106 lines
5 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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`) and the keyboard's
/// never-suggest list (`OffensiveWords`); 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: "List of Dirty, Naughty, Obscene, and Otherwise Bad Words",
body: """
The keyboard's suggestion filter uses the List of Dirty, Naughty, Obscene, and \
Otherwise Bad Words (LDNOOBW), © 2012–2020 Shutterstock, Inc., and contributors: \
its English, Spanish, German and Norwegian lists, revision 5faf2ba \
(github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words), \
licensed under Creative Commons Attribution 4.0 International \
(creativecommons.org/licenses/by/4.0). Hex lowercased and classified the entries, \
omitted ordinary, medical and search-only terms, and added common slurs, \
inflections and spelling variants.
"""
),
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).
"""
),
]
}