Forum > General
Hyphenation routine to Spanish
José Mejuto:
--- Quote from: typo on March 10, 2010, 09:45:20 pm ---I would be satisfied with a routine that recognizes 90% of syllables without using dictionaries.
--- End quote ---
Hello,
here you have one spanish in C http://tip.dis.ulpgc.es/es/silabas/descargar which should be quite easy to port to pascal, take care that it uses ANSI characters and maybe you need UTF8, in that case the UTF8Tools package will help you.
And here there is a description of the basic rules to decompose words in spanish http://f01.middlebury.edu/SP210A/gramatica/acentu-index.html
theo:
I've once written a wrapper class for the hyphen lib.
http://sourceforge.net/projects/hunspell/files/ see hyphen 2.5
There are many dictionaries for it:
http://wiki.services.openoffice.org/wiki/Dictionaries#Spanish_.28Spain.2C_....29
See "Hyphenation" under "Spanish"
This is probably the most professional solution you can get.
There are different ways to use the wrapper. For ex:
--- Code: ---procedure TForm1.Button1Click(Sender: TObject);
var
hList: TList;
hyp: THyphen;
i, Start: integer;
AWord: UTF8String;
begin
hList := TList.Create;
hyp := THyphen.Create('/home/theo/install/hyphen-2.5/hyph_es_ES.dic',
'/home/theo/install/hyphen-2.5/.libs/libhyphen.so');
AWord := 'electroencefalografistas';
Start := 1;
hyp.Hyphenate(UTF8LowerCase(AWord), hList);
for i := 0 to hList.Count - 1 do
begin
Memo1.Lines.add(Copy(AWord, Start, PtrUInt(hList[i]) - Start + 1));
Start := PtrUInt(hList[i]) + 1;
end;
Memo1.Lines.add(Copy(AWord, Start, Length(AWord) - Start + 1));
hyp.Free;
hList.Free;
end;
--- End code ---
Result:
--- Quote ---elec-
tro-
en-
ce-
fa-
lo-
gra-
fis-
tas
--- End quote ---
If you need the wrapper, tell me.
typo:
Yes, I want it.
BTW, trying to compile uHunSpellLib.pas I receive this error message:
uHunSpellLib.pas(64,28) Error: Illegal type conversion: "ShortString" to "^Char"
in this line:
DLLHandle := LoadLibrary(PAnsiChar(libraryName));
Any suggestions?
theo:
--- Quote from: typo on March 15, 2010, 03:38:55 pm ---Yes, I want it.
--- End quote ---
OK, http://www.theo.ch/lazarus/hyphen.zip
You do not need Hunspell for Hyphenation.
typo:
Thanks.
Navigation
[0] Message Index
[#] Next page
[*] Previous page