I'm building a "did you mean" funcionality on an internal search engine, using aspell and php (php-pspell).
I have a catalog of products and I want the names of those products to be also words in the dictionary so the "did you mean" can suggest'em.
The problem is that when I try to create a custom dictionary with PHP Pspell functions, I receive errors when the words contain characters that are not in the a-z range, as numbers, hifens, etc.
For example:
iphone 3gs: iphone is added smoothly, but 3gs isn't
blu-ray: can't be added due to the -
Is it possible to add that kind of word in a dictionary? Or aspell just don't accept them?
Suppose your dictionary language is English (“en”) then find the en.dat file in aspell installation.
en.dat
is the language data file and each language has its own data file named as<lang>.dat
. The data file should be present at following location:Now open this file for editing:
At the end of this file add the following line:
special
is the keyword that tell aspell that following characters are to be treated as special characters. The format for adding special characters is:char is the non-letter character in question. begin, middle, end are either a ‘-‘ or a ‘*‘. A star for begin means that the character can begin a word, a ‘-‘ means it can’t. The same is true for middle and end. Full article: http://www.webspeaks.in/2015/01/adding-special-characters-in-aspell-dictionary-for-php.html