• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdespell2
 

tdespell2

tdespell_hspelldict.cpp

00001 
00023 #include "tdespell_hspelldict.h"
00024 #include <kdebug.h>
00025 
00026 #include <tqtextcodec.h>
00027 
00028 using namespace KSpell2;
00029 
00030 HSpellDict::HSpellDict( const TQString& lang )
00031     : Dictionary( lang )
00032 {
00033    int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
00034    if ( int_error == -1 )
00035       kdDebug() << "HSpellDict::HSpellDict: Init failed" << endl;
00036     /* hspell understans only iso8859-8-i            */
00037     codec = TQTextCodec::codecForName( "iso8859-8-i" );
00038 }
00039 
00040 HSpellDict::~HSpellDict()
00041 {
00042     /* It exists in =< hspell-0.8 */
00043     hspell_uninit( m_speller );
00044 }
00045 
00046 bool HSpellDict::check( const TQString& word )
00047 {
00048     kdDebug() << "HSpellDict::check word = " << word <<endl;
00049     int preflen;
00050     TQCString wordISO = codec->fromUnicode( word );
00051     /* returns 1 if the word is correct, 0 otherwise */
00052     int correct = hspell_check_word ( m_speller,
00053                               wordISO,
00054                                       &preflen); //this going to be removed
00055                                                  //in next hspell releases
00056     /* I do not really understand what gimatria is   */
00057     if( correct != 1 ){
00058         if( hspell_is_canonic_gimatria( wordISO ) != 0 )
00059     correct = 1;
00060     }
00061     return correct == 1;
00062 }
00063 
00064 TQStringList HSpellDict::suggest( const TQString& word )
00065 {
00066     TQStringList 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::checkAndSuggest( const TQString& word,
00079                                   TQStringList& suggestions )
00080 {
00081     bool c = check( word );
00082     if( c )
00083         suggestions = suggest( word );
00084     return c;
00085 }
00086 
00087 bool HSpellDict::storeReplacement( const TQString& bad,
00088                                    const TQString& good )
00089 {
00090     // hspell-0.9 cannot do this
00091     kdDebug() << "HSpellDict::storeReplacement: Sorry, cannot." << endl; 
00092     return false;
00093 }
00094 
00095 bool HSpellDict::addToPersonal( const TQString& word )
00096 {
00097     // hspell-0.9 cannot do this
00098     kdDebug() << "HSpellDict::addToPersonal: Sorry, cannot." << endl; 
00099     return false;
00100 }
00101 
00102 bool HSpellDict::addToSession( const TQString& word )
00103 {
00104     // hspell-0.9 cannot do this
00105     kdDebug() << "HSpellDict::addToSession: Sorry, cannot." << endl; 
00106     return false;
00107 }

tdespell2

Skip menu "tdespell2"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

tdespell2

Skip menu "tdespell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdespell2 by doxygen 1.6.3
This website is maintained by Timothy Pearson.