How to use special chars on aspell custom dictionary?
Asked Answered
P

3

8

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?

Pickar answered 4/11, 2009 at 19:44 Comment(1)
I have a similar problem: I can't add a German word "Künstliche" to an otherwise English personal dictionary. Aspell complains "The character (U+BC) may not appear in the middle of a word" even if I use the options "-d en-w_accents --encoding=utf-8"Thorazine
L
2

One resource that may prove helpful. You should be able to add words with special characters by configuring your language datafile, but there is a caviat:

However, please be aware that adding special characters can have unintended consequences due to limitations of Aspell. For example if the -' was accepted as a middle character, then every word with a-' in it would be flagged as a spelling error unless that exact word is in the dictionary, even if both parts are in the dictionary. Also, having a .' as an end character will cause the.' to be part of any misspelled words. Which can get very annoying if you misspell a word at the end of a sentence.

Limiting answered 4/5, 2011 at 22:34 Comment(1)
Can you describe in detail how add a German word "Künstliche" to an otherwise English personal dictionary?Thorazine
C
2

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:

/usr/lib64/aspell/en.dat

Now open this file for editing:

vi /usr/lib64/aspell/en.dat

At the end of this file add the following line:

special ' -*-

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

Cavorelievo answered 20/1, 2015 at 5:44 Comment(0)
L
0

The best way to do this is replace the special characters including white space with some key sequence. say xxx. You will have to do that for all characters outside the ones aspell accepts.

Laspisa answered 18/2, 2010 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.