Aspell - Free and Open Source spell checker

mail

Error: Expected language "fr" but got "en".

Situation

I got this with :

Details

No more error after removing the --personal and --repl flags.

Steps to reproduce :

  1. Let's create a dummy file and try to spell-check it with personal word list + replacements list :
    fileToCheck=$(mktemp); echo 'bonjour' > "$fileToCheck"; aspell --personal='personalWordList' --repl='replacementsList' -c "$fileToCheck"; [ -f "$fileToCheck" ] && rm "$fileToCheck"
    What happens at this step :
    1. no dictionary is specified, so fallback to the default dictionary (here : english)
    2. spellcheck is performed
    3. whether or not words not found in the selected dictionary are added to the personal dictionary makes no difference : the personal dictionary is created anyway
  2. Ooops : I realize I forgot to specify I want to use a french dictionary. My command becomes :
    fileToCheck=$(mktemp); echo 'bonjour > "$fileToCheck"; aspell --personal='personalWordList' --repl='replacementsList' -c "$fileToCheck" -d fr; [ -f "$fileToCheck" ] && rm "$fileToCheck"
    But then :
    Error: Expected language "fr" but got "en".

What happened ?

The first time I ran aspell, the personal word list + replacements list are created. Even though I added nothing to them, both contain a header line :
cat personalWordList replacementsList
personal_ws-1.1 en 0
personal_repl-1.1 en 0 
Both files state that they apply to english spell-checking.

Solution

Depending on the situation, you can :
mail

Aspell : how to install a new dictionary ?

  1. list available dictionaries :
    apt-cache search aspell | grep dictionary
    aspell-am - Amharic dictionary for aspell
    aspell-ar - Arabic dictionary for aspell
    aspell-ar-large - Large Arabic dictionary for aspell
    aspell-bn - Bengali (bn) dictionary for GNU aspell
    aspell-br - Breton dictionary for GNU Aspell		Demat d'an holl !
    aspell-cs - Czech dictionary for GNU Aspell
    
    So far, 57 dictionaries are packaged by Debian. You can also have a look at the full list of Available Aspell Dictionaries. Each dictionary is packaged in a compressed archive. Installation instructions are in a README file.
  2. install :
    apt install aspell-fr
  3. check it's here :
  4. use it : you'll need -d to specify which dictionary to use :
    • tmpFile=$(mktemp); echo 'bonjour le monde' > "$tmpFile"; aspell -c "$tmpFile"; rm "$tmpFile"
      yells because file contents is in french whereas my default dictionary is not french :
      aspell dump config | grep -C 1 'main dictionary'
      # master (string)
      #   base name of the main dictionary to use
      # default: <lang> = en_US
    • tmpFile=$(mktemp); echo 'bonjour le monde' > "$tmpFile"; aspell -d fr -c "$tmpFile"; rm "$tmpFile"
      Returns instantly with no output, which means I'm still able to say hello in french .
mail

Error: aspell.personalWordList: The word "Métrique" is invalid. The character '©' (U+A9) may not appear in the middle of a word.

Situation

After manually converting my personal wordlist (aspell.personalWordList) to UTF-8, I get this error when running Aspell to spell-check files :
Error: aspell.personalWordList: The word "Métrique" is invalid. The character '©' (U+A9) may not appear in the middle of a word.

Solution

Just specify the encoding at the end of the 1st line of the personal wordlist :
personal_ws-1.1 en n utf-8
mail

aspell

Usage

interactive spell checker

Flags

Flag Usage
check fileToCheck
-c fileToCheck
Spell-check the file fileToCheck
  • this command expects a single file as parameter. To check several files :
    for i in *; do aspell -c "$i"; done
  • The words added to the "personal dictionary" during the interactive session will be stored in ~/.aspell.en.pws
dump option With option being one of :
  • config : show current configuration
  • dicts : lists available dictionaries
--dont-backup don't create a backup file. Without this flag, will create a .bak backup of file(s) receiving corrections
-d name
--master=name
Base name of the dictionary to use. How to install a new dictionary ?
defaults to the OS language ($LANG ?)
-p path/to/myWordList
--personal=path/to/myWordList
Use path/to/myWordList as personal word list. Will be created if missing
If no path is specified, defaults to $HOME/myWordList
--repl=path/to/myReplacementList Use path/to/myReplacementList as replacement list. Will be created if missing
If no path is specified, defaults to $HOME/myReplacementList

Example

View full wordlist :

aspell -d english dump master

Check spelling of a file :

see
	/usr/lib/aspell
	/var/lib/aspell