summaryrefslogtreecommitdiffstats
path: root/tdespell2/plugins/hspell
diff options
context:
space:
mode:
Diffstat (limited to 'tdespell2/plugins/hspell')
-rw-r--r--tdespell2/plugins/hspell/CMakeLists.txt49
-rw-r--r--tdespell2/plugins/hspell/Makefile.am17
-rw-r--r--tdespell2/plugins/hspell/tdespell_hspell.desktop18
-rw-r--r--tdespell2/plugins/hspell/tdespell_hspellclient.cpp57
-rw-r--r--tdespell2/plugins/hspell/tdespell_hspellclient.h60
-rw-r--r--tdespell2/plugins/hspell/tdespell_hspelldict.cpp107
-rw-r--r--tdespell2/plugins/hspell/tdespell_hspelldict.h53
7 files changed, 361 insertions, 0 deletions
diff --git a/tdespell2/plugins/hspell/CMakeLists.txt b/tdespell2/plugins/hspell/CMakeLists.txt
new file mode 100644
index 000000000..960b54ff4
--- /dev/null
+++ b/tdespell2/plugins/hspell/CMakeLists.txt
@@ -0,0 +1,49 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdespell2
+ ${CMAKE_SOURCE_DIR}/tdecore
+ ${HSPELL_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+ ${HSPELL_LIBARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES tdespell_hspell.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#### tdespell_hspell ##############################
+
+### FIXME Not checked because hspell was removed from gentoo few years ago.
+### FIXME The maintainer recommend to use aspell with hebrew dictionary.
+### FIXME Maybe support for hspell will be removed too?
+### FIXME http://bugs.gentoo.org/show_bug.cgi?id=177546
+
+set( target tdespell_hspell )
+
+set( ${target}_SRCS
+ tdespell_hspellclient.cpp tdespell_hspelldict.cpp
+)
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK tdespell2-shared ${HSPELL_LIBRARIES}
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdespell2/plugins/hspell/Makefile.am b/tdespell2/plugins/hspell/Makefile.am
new file mode 100644
index 000000000..fb4a193f9
--- /dev/null
+++ b/tdespell2/plugins/hspell/Makefile.am
@@ -0,0 +1,17 @@
+METASOURCES = AUTO
+
+AM_CPPFLAGS = -I$(top_srcdir)/tdespell2 -I$(top_srcdir) $(all_includes)
+
+# For the future: examine if condensing the tons of *_LDFLAGS variables
+# into $(all_libraries) isn't better
+AM_LDFLAGS = $(LDFLAGS_AS_NEEDED) $(LDFLAGS_NEW_DTAGS)
+
+kde_module_LTLIBRARIES = tdespell_hspell.la
+
+tdespell_hspell_la_SOURCES = tdespell_hspellclient.cpp tdespell_hspelldict.cpp
+
+tdespell_hspell_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN)
+tdespell_hspell_la_LIBADD = ../../ui/libtdespell2.la -lhspell -lz $(LIB_QT) $(LIB_TDECORE)
+
+service_DATA = tdespell_hspell.desktop
+servicedir = $(kde_servicesdir)
diff --git a/tdespell2/plugins/hspell/tdespell_hspell.desktop b/tdespell2/plugins/hspell/tdespell_hspell.desktop
new file mode 100644
index 000000000..dbeaac73f
--- /dev/null
+++ b/tdespell2/plugins/hspell/tdespell_hspell.desktop
@@ -0,0 +1,18 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=KSpell/Client
+X-TDE-Library=tdespell_hspell
+X-TDE-PluginInfo-Author=Mashrab Kuvatov
+X-TDE-PluginInfo-Name=tdespell_hspell
+X-TDE-PluginInfo-Version=0.0.1
+X-TDE-PluginInfo-Website=http://www.kde.org
+X-TDE-PluginInfo-Category=Clients
+X-TDE-PluginInfo-Depends=
+X-TDE-PluginInfo-License=LGPL
+X-TDE-PluginInfo-EnabledByDefault=true
+Name=HSpell
+Name[bn]=এইচ-স্পেল
+Name[ne]=एच स्पेल
+Name[sv]=Hspell
+Name[te]=హెచ్ స్పెల్
diff --git a/tdespell2/plugins/hspell/tdespell_hspellclient.cpp b/tdespell2/plugins/hspell/tdespell_hspellclient.cpp
new file mode 100644
index 000000000..331b0a9cb
--- /dev/null
+++ b/tdespell2/plugins/hspell/tdespell_hspellclient.cpp
@@ -0,0 +1,57 @@
+/**
+ * tdespell_hspellclient.cpp
+ *
+ * Copyright (C) 2003 Zack Rusin <[email protected]>
+ * Copyright (C) 2005 Mashrab Kuvatov <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "tdespell_hspellclient.h"
+
+#include "tdespell_hspelldict.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+typedef KGenericFactory<HSpellClient> HSpellClientFactory;
+K_EXPORT_COMPONENT_FACTORY( tdespell_hspell, HSpellClientFactory( "tdespell_hspell" ) )
+
+using namespace KSpell2;
+
+HSpellClient::HSpellClient( TQObject *parent, const char *name, const TQStringList& /* args */ )
+ : Client( parent, name )
+{
+}
+
+HSpellClient::~HSpellClient()
+{
+}
+
+Dictionary* HSpellClient::dictionary( const TQString& language )
+{
+ HSpellDict *ad = new HSpellDict( language );
+ return ad;
+}
+
+TQStringList HSpellClient::languages() const
+{
+ TQStringList langs;
+ langs.append( "he" );
+
+ return langs;
+}
+
+#include "tdespell_hspellclient.moc"
diff --git a/tdespell2/plugins/hspell/tdespell_hspellclient.h b/tdespell2/plugins/hspell/tdespell_hspellclient.h
new file mode 100644
index 000000000..993cfe907
--- /dev/null
+++ b/tdespell2/plugins/hspell/tdespell_hspellclient.h
@@ -0,0 +1,60 @@
+/**
+ * tdespell_hspellclient.h
+ *
+ * Copyright (C) 2003 Zack Rusin <[email protected]>
+ * Copyright (C) 2005 Mashrab Kuvatov <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef KSPELL_HSPELLCLIENT_H
+#define KSPELL_HSPELLCLIENT_H
+
+#include "client.h"
+#include <tqobject.h>
+
+/* libhspell is a C library and it does not have #ifdef __cplusplus */
+extern "C" {
+#include "hspell.h"
+}
+
+namespace KSpell2 {
+ class Dictionary;
+}
+using KSpell2::Dictionary;
+
+class HSpellClient : public KSpell2::Client
+{
+ Q_OBJECT
+public:
+ HSpellClient( TQObject *parent, const char *name, const TQStringList & /* args */ );
+ ~HSpellClient();
+
+ virtual int reliability() const {
+ return 20;
+ }
+
+ virtual Dictionary* dictionary( const TQString& language );
+
+ virtual TQStringList languages() const;
+
+ virtual TQString name() const {
+ return "HSpell";
+ }
+private:
+
+};
+
+#endif
diff --git a/tdespell2/plugins/hspell/tdespell_hspelldict.cpp b/tdespell2/plugins/hspell/tdespell_hspelldict.cpp
new file mode 100644
index 000000000..fa2efaccb
--- /dev/null
+++ b/tdespell2/plugins/hspell/tdespell_hspelldict.cpp
@@ -0,0 +1,107 @@
+/**
+ * tdespell_hspelldict.cpp
+ *
+ * Copyright (C) 2003 Zack Rusin <[email protected]>
+ * Copyright (C) 2005 Mashrab Kuvatov <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "tdespell_hspelldict.h"
+#include <kdebug.h>
+
+#include <tqtextcodec.h>
+
+using namespace KSpell2;
+
+HSpellDict::HSpellDict( const TQString& lang )
+ : Dictionary( lang )
+{
+ int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
+ if ( int_error == -1 )
+ kdDebug() << "HSpellDict::HSpellDict: Init failed" << endl;
+ /* hspell understans only iso8859-8-i */
+ codec = TQTextCodec::codecForName( "iso8859-8-i" );
+}
+
+HSpellDict::~HSpellDict()
+{
+ /* It exists in =< hspell-0.8 */
+ hspell_uninit( m_speller );
+}
+
+bool HSpellDict::check( const TQString& word )
+{
+ kdDebug() << "HSpellDict::check word = " << word <<endl;
+ int preflen;
+ TQCString wordISO = codec->fromUnicode( word );
+ /* returns 1 if the word is correct, 0 otherwise */
+ int correct = hspell_check_word ( m_speller,
+ wordISO,
+ &preflen); //this going to be removed
+ //in next hspell releases
+ /* I do not really understand what gimatria is */
+ if( correct != 1 ){
+ if( hspell_is_canonic_gimatria( wordISO ) != 0 )
+ correct = 1;
+ }
+ return correct == 1;
+}
+
+TQStringList HSpellDict::suggest( const TQString& word )
+{
+ TQStringList qsug;
+ struct corlist cl;
+ int n_sugg;
+ corlist_init( &cl );
+ hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
+ for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
+ qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
+ }
+ corlist_free( &cl );
+ return qsug;
+}
+
+bool HSpellDict::checkAndSuggest( const TQString& word,
+ TQStringList& suggestions )
+{
+ bool c = check( word );
+ if( c )
+ suggestions = suggest( word );
+ return c;
+}
+
+bool HSpellDict::storeReplacement( const TQString& bad,
+ const TQString& good )
+{
+ // hspell-0.9 cannot do this
+ kdDebug() << "HSpellDict::storeReplacement: Sorry, cannot." << endl;
+ return false;
+}
+
+bool HSpellDict::addToPersonal( const TQString& word )
+{
+ // hspell-0.9 cannot do this
+ kdDebug() << "HSpellDict::addToPersonal: Sorry, cannot." << endl;
+ return false;
+}
+
+bool HSpellDict::addToSession( const TQString& word )
+{
+ // hspell-0.9 cannot do this
+ kdDebug() << "HSpellDict::addToSession: Sorry, cannot." << endl;
+ return false;
+}
diff --git a/tdespell2/plugins/hspell/tdespell_hspelldict.h b/tdespell2/plugins/hspell/tdespell_hspelldict.h
new file mode 100644
index 000000000..7b18003be
--- /dev/null
+++ b/tdespell2/plugins/hspell/tdespell_hspelldict.h
@@ -0,0 +1,53 @@
+/**
+ * tdespell_hspelldict.h
+ *
+ * Copyright (C) 2003 Zack Rusin <[email protected]>
+ * Copyright (C) 2005 Mashrab Kuvatov <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef KSPELL_HSPELLDICT_H
+#define KSPELL_HSPELLDICT_H
+
+#include "dictionary.h"
+/* libhspell is a C library and it does not have #ifdef __cplusplus */
+extern "C" {
+#include "hspell.h"
+}
+
+class HSpellDict : public KSpell2::Dictionary
+{
+public:
+ HSpellDict( const TQString& lang );
+ ~HSpellDict();
+ virtual bool check( const TQString& word );
+
+ virtual TQStringList suggest( const TQString& word );
+
+ virtual bool checkAndSuggest( const TQString& word,
+ TQStringList& suggestions ) ;
+
+ virtual bool storeReplacement( const TQString& bad,
+ const TQString& good );
+
+ virtual bool addToPersonal( const TQString& word );
+ virtual bool addToSession( const TQString& word );
+private:
+ struct dict_radix *m_speller;
+ TQTextCodec *codec;
+};
+
+#endif