Sonnet
kspell_hspelldict.cpp
Go to the documentation of this file.00001
00023 #include "kspell_hspelldict.h"
00024 #include <kdebug.h>
00025
00026 #include <QtCore/QTextCodec>
00027
00028 using namespace Sonnet;
00029
00030 HSpellDict::HSpellDict( const QString& lang )
00031 : SpellerPlugin( lang )
00032 {
00033 int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
00034 if ( int_error == -1 )
00035 kDebug() << "HSpellDict::HSpellDict: Init failed";
00036
00037 codec = QTextCodec::codecForName( "iso8859-8-i" );
00038 }
00039
00040 HSpellDict::~HSpellDict()
00041 {
00042
00043 hspell_uninit( m_speller );
00044 }
00045
00046 bool HSpellDict::isCorrect( const QString& word ) const
00047 {
00048 kDebug() << "HSpellDict::check word = " << word;
00049 int preflen;
00050 QByteArray wordISO = codec->fromUnicode( word );
00051
00052 int correct = hspell_check_word ( m_speller,
00053 wordISO,
00054 &preflen);
00055
00056
00057 if( correct != 1 ){
00058 if( hspell_is_canonic_gimatria( wordISO ) != 0 )
00059 correct = 1;
00060 }
00061 return correct == 1;
00062 }
00063
00064 QStringList HSpellDict::suggest( const QString& word ) const
00065 {
00066 QStringList qsug;
00067 struct corlist cl;
00068 int n_sugg;
00069 corlist_init( &cl );
00070 hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
00071 for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
00072 qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
00073 }
00074 corlist_free( &cl );
00075 return qsug;
00076 }
00077
00078 bool HSpellDict::storeReplacement( const QString& bad,
00079 const QString& good )
00080 {
00081
00082 kDebug() << "HSpellDict::storeReplacement: Sorry, cannot.";
00083 return false;
00084 }
00085
00086 bool HSpellDict::addToPersonal( const QString& word )
00087 {
00088
00089 kDebug() << "HSpellDict::addToPersonal: Sorry, cannot.";
00090 return false;
00091 }
00092
00093 bool HSpellDict::addToSession( const QString& word )
00094 {
00095
00096 kDebug() << "HSpellDict::addToSession: Sorry, cannot.";
00097 return false;
00098 }