Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm searching for an editor with the ability to spell-check two languages at the same time (German and English). Gedit can't do it out of the box.

But I want to use Gedit. It should be possible by merging the English and German dictionaries and select the created file under Tools->Set Language...

edit

I got it almost (some warnings in step 6 and e.g. zzgl. (words with a dot at the end) are not spell-checked) :) Thanks to your post Kevin Atkinson :)

(I may add that for English I used aspell6-en-7.1-0.tar.bz2 (is already new version/updated) but for German I used http://extensions.services.openoffice.org/project/dict-de_DE_frami because it's more updated. Extract this .oxt using unzip. In de_DE_frami are the two needed affix and dictionary files called de_DE_frami.aff and de_DE_frami.dic. Rename the de_DE_frami.aff to qed_affix.dat and the de_DE_frami.dic to de.txt.

Note: For German there is also an extension: http://extensions.services.openoffice.org/de/project/DFEW which I'm going to merge later too)

In step 6 I had to use $ cat de_en | aspell --encoding=utf-8 create master -l ./qed ./qed.rws because all üäöß.. were skipped and were not in the created dictionary, but now they are there: $ aspell -d ./qed.rws -a (Testing: typing e.g. "Käse" or "zweiunddreißig" prints an *, so it finds these words now)

Filesizes: $ du -b qed*
18725   qed_affix.dat
103 qed.dat
12  qed.multi
6763456 qed.rws
Lines: $ wc -l qed* de_en
       6 qed.dat
       1 qed.multi
   54403 qed.rws
     717 qed_affix.dat
  334974 de_en

Download of this package in case someone needs it.

The most warnings I can see now at step 6 look like this - last 5 lines:

$ cat de_en | aspell --encoding=utf-8 create master -l ./qed ./qed.rws
...(many warnings appear)
Warning: Removing invalid affix 'o' from word zytostatika.
Warning: Removing invalid affix 'z' from word zytostatika.
Warning: Removing invalid affix 'o' from word zytostatikum.
Warning: Removing invalid affix 'z' from word zytostatikum.
Warning: The word "zzgl." is invalid. The character '.' (U+2E) may not appear at the end of a word. Skipping word.
$

Now I removed aspell-en and aspell-de ($sudo apt-get remove aspell-en aspell-de) and put all the four files qed.dat, qed.multi, qed.rws and qed_affix.dat into /usr/lib/aspell. My /var/lib/aspell is empty BTW.

The new package can be selected now: gedit->Tools->Set Language...->Unknown (qed).

Regarding to the warnings in step 6 zzlg. words with a dot at the end are not spell-checked. I tried playing with qed.dat special ' -*- line by adding a . because the de.dat uses a . in there too, but it unfortunately didn't work.

edit

Solved the spell-checking of words with a dot at the end by grepping these only and adding them to the spell-checking white-list. $ cat de_en | sed -n '/\./{s/[./]\+[^./]*$//;p}' >> /home/<username>/.config/enchant/qed.dic

share|improve this question
1  
I didn't try this, but Emacs uses for example aspell, which in turn uses files (of course) as dictionaries. So, what would happen if you would merge the aspell files for German and English? Try whereis aspell. –  Emanuel Berg Aug 9 '12 at 10:18
    
Good idea by merging the two word files into one. I merged and now I need to be able to select the file in gedit->Tools->Set language. Maybe someone knows where to put it so one can select it in gedit. I googled buy couldn't find the answer so far. –  removelastdotonlyifitsthere Aug 9 '12 at 12:53
    
Examine the directory structure where the original files were. You should replicate it, but with your new file. Probably Gedit is set to look for dictionaries at a fixed place, and the merged dictionary should behave just the same. –  Emanuel Berg Aug 9 '12 at 13:15
add comment

3 Answers 3

up vote 2 down vote accepted

Aspell Author Here.

As I said in an earlier answer, you can't just combine dictionaries from different languages and expect it to work. You need to create a new language that combines the features of the two original languages.

Fortunately for English and German this is fairly easy; however, the suggestion quality will suffer for English words since we will disable the use of soundslike lookup.

  1. Install the aspell-en and the aspell-de dictionary package

  2. Go to a empty directory to keep everything clean. Also to avoid any charset issues change the locale to "C" by setting LC_ALL=C.

  3. Dump the English and German dictionaries into plan wordlists

    aspell dump master en > en.txt
    aspell dump master de > de.txt
    
  4. Combine en.dat and de.dat, which you can generally find in usr/lib/aspell.

    The English dictionary uses soundslike lookup but that won't with the German dictionary (due to the fact that it is English specific, and more importable it is incompatible with Affix compression) so we will disable it. The English dictionary doesn't use affix compression but the German dictionary does so we will just use the affix file for the German dictionary. (This will avoid having to expand the German dictionary and thus increasing it size).

    We will call the language qed, 'q' since very few languages start with q, 'e' for English, and 'g' for German. (The language name should generally be 2 to 3 letters, but aspell doesn't really care, so en-de or some other name might work, but a 2 or 3 letter name is guaranteed to work)

    The file will be named qed.dat and contain the following:

    name qed
    charset iso8859-1
    special ' -*-
    soundslike      none
    affix           qed
    affix-compress  true
    
  5. Copy de_affix.dat into the current directory and rename it qed_affix.dat.

  6. Create the combined dictionary:

    cat en.txt de.txt | aspell create master -l ./qed ./qed.rws
    
  7. Create the file qed.multi:

    add qed.rws
    
  8. Test the dictionary by using -d ./qed. the ./ is needed to force aspell to search the current directory.

  9. Install qed.dat qed.rws qed.multi and qed_affix.dat somewhere where aspell will find it. Please see the manual for info on how aspell searches for dictionary and language data files.

  10. Done. Everything should work now. A more sophisticated solution will enable some form of soundslike lookup for better suggestion quality. But that requires special care when used with affix compression (see the Aspell manual for details). As an alternative the German dictionary can be expanded and the English soundlike lookup can be used, but that might not work so well on German words.

The case of combing English and German was easy because they both use the same charset (iso-8859-1) and because only one language used Affix compression. Combining other languages will take more work but it is possible once you know what you are doing. I spelled out the steps here in detail to give readers some idea of how Aspell works so a similar thing can be used for other language combinations.

If both languages use affix compression, either the affix files will need to be combined so there are no conflicting flags, or one of the dictionaries will need to be expanded.

If the two languages use a different 8-bit charset than a compatible charset that can support both languages we need to be used. If a standard one doesn't exist, than a new one can be created. To avoid confusion the wordlists should be converted to utf-8 and Aspell should be instructed to expect all input and output in utf-8 instead of the charset that is used internally, which for historical reasons is the default.

share|improve this answer
    
I got it almost (some warnings in step 6 and "zzgl." is not spell-checked) :) Thanks to your post Kevin Atkinson :) Checkout my first post. –  removelastdotonlyifitsthere Aug 14 '12 at 10:07
    
Yes, Aspell doesn't support special characters, such as the period ("."), at the end of a word very well. I actually wrote about the problem (see aspell.net/man-html/Words-With-Symbols-in-Them.html). There are command line flags to force Aspell to accept them when creating a dictionary (see manual) which might help, but only when the application itself is doing the parsing (splitting a line to words) and not Aspell. With emacs I think it is Aspell that is doing the parsing. –  Kevin Atkinson Aug 19 '12 at 12:00
add comment

Vim allows to set more than one language for the spellcheck, e.g.

:set spelllang=de,en

for German and English.

share|improve this answer
    
Thank you for your answer. Read my edit. –  removelastdotonlyifitsthere Aug 9 '12 at 17:07
    
I'd suggest that you change the subject as well then so as not to mislead people. –  Lars Kotthoff Aug 9 '12 at 17:38
    
Oh you are right sorry, still a non-commandline editor is ok if I don't get gedit to work. –  removelastdotonlyifitsthere Aug 9 '12 at 17:45
    
Have you considered gvim? –  Lars Kotthoff Aug 9 '12 at 18:04
    
I have checked emacs and gvim but they are some kind of commandline-gui mix and not really good to use. Checkout my second edit :) –  removelastdotonlyifitsthere Aug 13 '12 at 15:00
add comment

Aspell Author Here.

You can not just combine two dictionaries from two different languages and expect it to work. Each dictionary also has a data file associated with it that describes language specific features.

Your best bet is to create a new language which can handle both English and German correctly. Doing so is a doable, but non-trivial task. I might be able to help you with this task latter this week if you can't find any other solution.

General multi-language spell checking is not currently supported by Aspell (or most other spell checkers that I know of, including Hunspell).

share|improve this answer
    
It would be awesome if you could help creating this both-languages package :) I tried just pasting the content from en_affix.dat into de_affix.dat but this of course didn't work. I don't know how this all works. Having a simple file with all the words would be very easy to understand but I guess it would make the file bigger and slow down the spell-checking. –  removelastdotonlyifitsthere Aug 13 '12 at 17:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.