* add also the simplifier scheck unit with SpellCheck function to aspell package

git-svn-id: trunk@8376 -
This commit is contained in:
Almindor 2007-09-04 12:45:12 +00:00
parent ebfd2b6b20
commit 1606ec996f
5 changed files with 129 additions and 53 deletions

1
.gitattributes vendored
View File

@ -1906,6 +1906,7 @@ packages/extra/aspell/Makefile.fpc svneol=native#text/plain
packages/extra/aspell/aspell.pp svneol=native#text/plain
packages/extra/aspell/fpmake.inc svneol=native#text/plain
packages/extra/aspell/fpmake.pp svneol=native#text/plain
packages/extra/aspell/scheck.pp svneol=native#text/plain
packages/extra/bfd/Makefile svneol=native#text/plain
packages/extra/bfd/Makefile.fpc svneol=native#text/plain
packages/extra/bfd/bfd.pas svneol=native#text/plain

View File

@ -233,160 +233,160 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
override PACKAGE_NAME=aspell
override PACKAGE_VERSION=1.0.0
ifeq ($(FULL_TARGET),i386-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-go32v2)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-win32)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-os2)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-freebsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-beos)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-netbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-solaris)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-qnx)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-netware)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-openbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-wdosx)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-darwin)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-emx)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-watcom)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-netwlibc)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-wince)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),i386-symbian)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-freebsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-netbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-amiga)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-atari)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-openbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-palmos)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),m68k-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-amiga)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-macos)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-darwin)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-morphos)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),sparc-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),sparc-netbsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),sparc-solaris)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),sparc-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),x86_64-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),x86_64-freebsd)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),x86_64-win64)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),x86_64-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-palmos)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-wince)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-gba)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-nds)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),arm-symbian)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc64-linux)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc64-darwin)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
override TARGET_UNITS+=aspell
override TARGET_UNITS+=aspell scheck
endif
override INSTALL_FPCPACKAGE=y
ifdef REQUIRE_UNITSDIR

View File

@ -7,7 +7,7 @@ name=aspell
version=1.0.0
[target]
units=aspell
units=aspell scheck
[install]
fpcpackage=y

View File

@ -6,4 +6,5 @@
{$ENDIF}
OS:=[linux,netbsd,freebsd,openbsd,win32,solaris,darwin];
T:=Targets.AddUnit('aspell');
T:=Targets.AddUnit('scheck');
EndPackage;

View File

@ -0,0 +1,74 @@
unit scheck;
{$mode objfpc}{$H+}
interface
uses
Aspell;
type
TSuggestionArray = array of string;
function SpellCheck(const Word, Lang: string; out Suggestions: TSuggestionArray): Integer;
implementation
function SpellCheck(const Word, Lang: string; out Suggestions: TSuggestionArray): Integer;
var
cnf: aspellconfig;
ape: aspellcanhaveerror;
spl: aspellspeller;
sgs: aspellwordlist;
elm: aspellstringenumeration;
tmp: pChar;
i: Integer = 0;
begin
SetLength(Suggestions, 10);
Result := -1;
cnf := new_aspell_config();
aspell_config_replace(cnf, 'lang', pChar(Lang));
aspell_config_replace(cnf, 'encoding', 'utf-8');
ape := new_aspell_speller(cnf);
delete_aspell_config(cnf);
spl := nil;
if aspell_error_number(ape) <> 0 then
Exit
else
spl := to_aspell_speller(ape);
if aspell_speller_check(spl, pChar(Word), Length(Word)) > 0 then
Exit(0)
else begin
sgs := aspell_speller_suggest(spl, pChar(Word), Length(Word));
elm := aspell_word_list_elements(sgs);
repeat
if i >= Length(Suggestions) then
SetLength(Suggestions, Length(Suggestions) + 10);
tmp := aspell_string_enumeration_next(elm);
if tmp <> nil then begin
Suggestions[i] := tmp;
Inc(i);
end;
until tmp = nil;
SetLength(Suggestions, i);
Result := i;
delete_aspell_string_enumeration(elm);
end;
delete_aspell_speller(spl);
end;
end.