Building a Setswana spellchecker for real-world language use

A reliable Setswana spellchecker sits at the meeting point of language description and software engineering. It must recognise acceptable words, flag likely errors, and respect the way speakers actually write across Botswana, South Africa, Namibia, and Setswana-speaking communities elsewhere. A dictionary alone cannot provide all that evidence. Learn more about Kak Nauchit Sya Govorit Po Angliiski Za 3 Mesyatsa Real No Li Eto.

The project also belongs to a broader programme of lexicography, corpus linguistics, translation, and language preservation. The work of T.J. Otlogetswe offers a useful reference point because it connects dictionaries and word histories with practical questions about how African languages are recorded, taught, and used.

Defining the language problem

Setswana spelling is governed by an established orthographic tradition, yet written usage is not perfectly uniform. Writers may differ over word division, borrowed terms, punctuation, capitalisation, and the treatment of grammatical elements. A spellchecker therefore needs a defensible standard while allowing researchers to measure variation rather than silently deleting it.

The first task is to define what “correct” means for the intended users. A school tool in Gaborone may prioritise the national orthography, while a community writing project in Perth or Melbourne may encounter code-switching, keyboard substitutions, and forms influenced by English. A dictionary-based checker that treats every unlisted form as an error will produce too many false alarms.

Lexicography can clarify these decisions. Entries should record headwords, variants, part of speech, definitions, examples, and morphological relationships. Etymological information is also valuable, especially for loanwords and culturally specific vocabulary. Discussions of changing word meanings, such as the analysis of fama non est suavis, show why a word’s history and current use should be kept conceptually separate.

Representing Setswana orthography

A spellchecker needs more than a list of correctly spelled words. Setswana has a rich system of noun classes, concords, extensions, and inflectional patterns. A single lexical stem can appear in many surface forms, so the system should combine a lexicon with rules or finite-state descriptions that analyse productive word formation.

Word segmentation presents a particularly important challenge. Some grammatical information is written together, while learners and informal writers may insert spaces or use forms associated with another language. The checker must distinguish a genuine misspelling from a non-standard but interpretable division. It should ideally offer a correction with an explanation rather than simply marking the whole string in red.

Vocabulary can also carry historical evidence. The names Tshosa and Tshane illustrate how specialised cultural terms may be overlooked by general-purpose wordlists. A Setswana tool should include terminology from material culture, oral tradition, agriculture, religion, education, and contemporary public life.

Building a trustworthy language resource

The core lexicon should be assembled from published dictionaries, school materials, newspapers, transcribed speech, translations, and carefully reviewed digital texts. Each entry needs provenance: where it came from, when it was collected, who checked it, and whether it represents formal, colloquial, regional, or technical usage. This prevents an accidental typo in a source from becoming an official spelling.

A balanced corpus is essential. If the data consist mainly of educational texts, the checker may perform well on essays but poorly on messaging, news, health information, or government documents. Australian users may write Setswana while commuting by train in Sydney, sending family messages from Brisbane, or preparing community materials in Perth. Their text can include English names, Australian place names, and mixed-language expressions that a rigid monolingual model would mishandle.

Data governance matters as much as data volume. Recordings and transcriptions may involve personal information, community knowledge, or culturally sensitive material. Researchers should document consent, access conditions, and licensing. The Australian Privacy Act 1988 is relevant when personal information is collected or processed in Australia, while community expectations may require stronger safeguards than a minimum legal standard.

Handling morphology and word boundaries

A practical analyser can begin with a finite-state transducer. One side represents a lexical analysis, such as a noun-class prefix plus stem; the other represents the written surface form. The analyser can then generate valid forms and identify the likely location of an error. This approach is transparent, fast, and easier to audit than a purely opaque prediction model.

Morphological rules must account for sound changes, consonant alternations, vowel sequences, and grammatical agreement. A form that looks unfamiliar may be perfectly regular, while a short typo can produce another valid word. The spellchecker should therefore rank candidates using several signals: edit distance, phonological similarity, word frequency, morphological plausibility, and the surrounding context.

Context is especially important in Setswana because a misspelling may resemble a legitimate word. A language model trained on clean, representative text can estimate which candidate fits the sentence. It should, however, be used as a supporting layer. If the training corpus is small or socially narrow, the model may prefer common urban forms and suppress regional or specialised vocabulary.

The same caution applies to automatic correction. A red underline is safer than silently changing text. In classrooms, explanations such as “check the noun-class prefix” or “possible spacing issue” can support language learning. In publishing workflows, an editor may prefer a ranked list of alternatives with dictionary evidence and corpus examples.

Designing the software system

A modular architecture makes the checker easier to improve. The tokeniser should recognise punctuation, apostrophes, hyphens, numbers, email addresses, URLs, and names before the lexical module evaluates spelling. The morphological analyser can then pass uncertain items to a candidate generator, followed by a ranking model and an interface layer.

Open-source development would help researchers, teachers, translators, and community organisations inspect the rules and add reviewed entries. Standards such as Hunspell can support desktop applications, while browser extensions, mobile keyboards, and language-learning platforms may require different APIs. The system should expose its dictionary and analysis functions in a way that permits reuse without exposing restricted source data.

Australian deployment introduces practical constraints. A community language centre may have limited staff and rely on low-cost laptops, while a commercial education provider may need integration with Microsoft Word, Google Docs, or a learning management system. The Australian market also includes multilingual schools, universities, libraries, and public-service translation teams, each with different procurement and accessibility requirements.

Testing should include real writing rather than invented examples alone. A set of annotated sentences can classify errors into missing letters, substituted letters, misplaced diacritics, incorrect word division, borrowed vocabulary, names, and acceptable variants. Reviewers should report false positives and false negatives separately, since an overactive checker can discourage Setswana writing as effectively as an underdeveloped one.

Measuring quality and sustaining the project

Evaluation should be stratified by genre, region, writer experience, and text length. Word-level accuracy is useful, but it does not reveal whether the system handles morphology or confusing valid words. Character error rate, candidate recall, correction precision, and the percentage of flagged items accepted by expert reviewers provide a fuller picture.

A pilot might compare three configurations: a static wordlist, a morphological analyser, and a hybrid analyser with contextual ranking. The results should be published with the test data or, where privacy prevents release, with detailed documentation of the sampling process. Presentations and research updates can help build this feedback loop; the author’s collection of language talks demonstrates how public scholarly communication can connect specialised work with wider communities.

Maintenance is a permanent responsibility. New technology terms, public institutions, personal names, and regional expressions will enter the language. A versioned editorial process should allow corrections, explain disputed decisions, and preserve older entries for reproducibility. Contributors need clear guidelines for adding words, recording variants, and distinguishing a rare form from an error.

The following comparison shows why a layered design is usually more appropriate than a single method:

Approach Main strength Main weakness Best role in a Setswana checker
Static wordlist Simple and fast Misses productive forms and variants Baseline vocabulary and protected names
Edit-distance matching Finds likely typographical errors Can suggest linguistically impossible forms Candidate generation
Morphological analyser Handles prefixes, stems, and inflection Requires expert rules and maintenance Core linguistic analysis
Statistical language model Uses sentence context May favour dominant genres or varieties Candidate ranking
Hybrid system Balances rules, data, and context More complex to test and govern Production spellchecking

A staged project is therefore sensible: establish the orthographic policy, build a documented lexicon, implement morphological analysis, add contextual ranking, and evaluate each release with speakers and language professionals. The immediate next step is to create a small, licensed gold-standard corpus of annotated Setswana sentences covering formal writing, everyday messaging, technical vocabulary, and regional variation.