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

tdespell2

  • tdespell2
  • plugins
  • hspell
tdespell_hspelldict.cpp
1 
23 #include "tdespell_hspelldict.h"
24 #include <kdebug.h>
25 
26 #include <tqtextcodec.h>
27 
28 using namespace KSpell2;
29 
30 HSpellDict::HSpellDict( const TQString& lang )
31  : Dictionary( lang )
32 {
33  int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
34  if ( int_error == -1 )
35  kdDebug() << "HSpellDict::HSpellDict: Init failed" << endl;
36  /* hspell understans only iso8859-8-i */
37  codec = TQTextCodec::codecForName( "iso8859-8-i" );
38 }
39 
40 HSpellDict::~HSpellDict()
41 {
42  /* It exists in =< hspell-0.8 */
43  hspell_uninit( m_speller );
44 }
45 
46 bool HSpellDict::check( const TQString& word )
47 {
48  kdDebug() << "HSpellDict::check word = " << word <<endl;
49  int preflen;
50  TQCString wordISO = codec->fromUnicode( word );
51  /* returns 1 if the word is correct, 0 otherwise */
52  int correct = hspell_check_word ( m_speller,
53  wordISO,
54  &preflen); //this going to be removed
55  //in next hspell releases
56  /* I do not really understand what gimatria is */
57  if( correct != 1 ){
58  if( hspell_is_canonic_gimatria( wordISO ) != 0 )
59  correct = 1;
60  }
61  return correct == 1;
62 }
63 
64 TQStringList HSpellDict::suggest( const TQString& word )
65 {
66  TQStringList qsug;
67  struct corlist cl;
68  int n_sugg;
69  corlist_init( &cl );
70  hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
71  for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
72  qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
73  }
74  corlist_free( &cl );
75  return qsug;
76 }
77 
78 bool HSpellDict::checkAndSuggest( const TQString& word,
79  TQStringList& suggestions )
80 {
81  bool c = check( word );
82  if( c )
83  suggestions = suggest( word );
84  return c;
85 }
86 
87 bool HSpellDict::storeReplacement( const TQString& bad,
88  const TQString& good )
89 {
90  // hspell-0.9 cannot do this
91  kdDebug() << "HSpellDict::storeReplacement: Sorry, cannot." << endl;
92  return false;
93 }
94 
95 bool HSpellDict::addToPersonal( const TQString& word )
96 {
97  // hspell-0.9 cannot do this
98  kdDebug() << "HSpellDict::addToPersonal: Sorry, cannot." << endl;
99  return false;
100 }
101 
102 bool HSpellDict::addToSession( const TQString& word )
103 {
104  // hspell-0.9 cannot do this
105  kdDebug() << "HSpellDict::addToSession: Sorry, cannot." << endl;
106  return false;
107 }
HSpellDict::storeReplacement
virtual bool storeReplacement(const TQString &bad, const TQString &good)
Stores user defined good replacement for the bad word.
Definition: tdespell_hspelldict.cpp:87
HSpellDict::addToSession
virtual bool addToSession(const TQString &word)
Adds word to the words recognizable in the current session.
Definition: tdespell_hspelldict.cpp:102
KSpell2::Dictionary
Class is returned by from Broker.
Definition: dictionary.h:36
HSpellDict::addToPersonal
virtual bool addToPersonal(const TQString &word)
Adds word to the list of of personal words.
Definition: tdespell_hspelldict.cpp:95
HSpellDict::checkAndSuggest
virtual bool checkAndSuggest(const TQString &word, TQStringList &suggestions)
Checks the word and fetches suggestions for it.
Definition: tdespell_hspelldict.cpp:78
HSpellDict::check
virtual bool check(const TQString &word)
Checks the given word.
Definition: tdespell_hspelldict.cpp:46
HSpellDict::suggest
virtual TQStringList suggest(const TQString &word)
Fetches suggestions for the word.
Definition: tdespell_hspelldict.cpp:64
KSpell2
tdespell_hspellclient.h
Definition: backgroundchecker.h:28

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdespell2 by doxygen 1.8.8
This website is maintained by Timothy Pearson.