I know this is mostly a technical / data question, but it is majorly about linguistics too and I don't think this is really up the alley of a lot of software engineers, so I am asking here.
So the Hunspell dictionaries are the foundation of modern spell-checking, and used by pretty much every browser (Chrome, Firefox, etc.), many applications (OpenOffice, Adobe products, maybe more), and several operating systems (MacOS, etc.). It is a very weird format though, here's the official docs which might help explain what's possible with it.
A hunspell dictionary is 2 files, .dic
(list of words, with mapping to possible affixes) and .aff
("affixes", list how they work, but also has much more functionality). Here is the English hunspell .dic and .aff. Here is a snippet of the .dic
:
accommodate/XGNDS
accommodating/Y
accommodation/M
accompanied/U
accompaniment/MS
accompanist/SM
accompany/DSG
accomplice/SM
accomplish/DSLG
accomplished/U
accomplishment/MS
First it is the word, then a slash, then the affix directives. So here is a snippet of the .aff
file (that file is actually quite small at under 200 lines):
SFX N Y 3
SFX N e ion e
SFX N y ication y
SFX N 0 en [^ey]
SFX X Y 3
SFX X e ions e
SFX X y ications y
SFX X 0 ens [^ey]
The SFX (suffix) format is n+1 lines:
- first line:
1 2 3
- ID (name of the affix class)
- Cross product (permission to combine prefixes and suffixes). Possible values: Y (yes) or N (no)
- Line count of the following rules.
- n+1 lines:
- ID
- stripping characters from beginning (at prefix rules) or end (at suffix rules) of the word
- affix (optionally with flags of continuation classes, separated by a slash)
- condition.
The Sanskrit .dic and .aff (1000 lines), for example, are much more complex than the English one it seems. Hunspell seems to be able to handle Sanskrit sandhi just fine. For example, we have this rule:
SFX 397 Y 1
SFX 397 म ्देताम् म
So that is saying, there is 1 rule for ID 397, where we strip म
from the end of the previous word, and add ्देताम्, assuming the previous word ends in म
.
So Hunspell can handle situations where you basically do:
Apply this suffix to the previous word if the previous word ends with X, and remove Y from the previous word.
My question at a super high level is basically, can Hunspell handle every situation of how to combine affixes across every language, or are there cases where it breaks down?
To narrow the question down and take it out of the clouds a little, my more specific question is, can Hunspell handle situations like infixes or "circumfixes" of things like that? Like Turkish adjective intensifications:
- siyah ("black") → simsiyah ("pitch black")
- güzel ("pretty") → güpgüzel ("very pretty")
- temiz ("clean") → tertemiz ("clean as a pin")
- katı ("hard") → kaskatı ("hard as a rock")
Is it possible to define a rule for that in Hunspell? Or other situations more complex than Sanskrit?
Here it says:
Main features of Hunspell spell checker and morphological analyzer:
- Support complex compoundings (for example, Hungarian and German)
- Support language specific features (for example, special casing of Azeri and Turkish dotted i, or German sharp s)
- Handle conditional affixes, circumfixes, fogemorphemes, forbidden words, pseudoroots and homonyms.
So I assume it does, but if so, what is an example of these advanced cases (specifically around *fixes)?