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

kspell2

  • kspell2
  • plugins
  • hspell
kspell_hspelldict.cpp
1 
23 #include "kspell_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 }
ASpellDict::suggest
virtual TQStringList suggest(const TQString &word)
Fetches suggestions for the word.
Definition: kspell_aspelldict.cpp:61
ASpellDict::check
virtual bool check(const TQString &word)
Checks the given word.
Definition: kspell_aspelldict.cpp:53
HSpellDict::storeReplacement
virtual bool storeReplacement(const TQString &bad, const TQString &good)
Stores user defined good replacement for the bad word.
Definition: kspell_hspelldict.cpp:87
HSpellDict::addToSession
virtual bool addToSession(const TQString &word)
Adds word to the words recognizable in the current session.
Definition: kspell_hspelldict.cpp:102
KSpell2::Dictionary
Class is returned by from Broker.
Definition: dictionary.h:37
HSpellDict::addToPersonal
virtual bool addToPersonal(const TQString &word)
Adds word to the list of of personal words.
Definition: kspell_hspelldict.cpp:95
HSpellDict::checkAndSuggest
virtual bool checkAndSuggest(const TQString &word, TQStringList &suggestions)
Checks the word and fetches suggestions for it.
Definition: kspell_hspelldict.cpp:78
HSpellDict::check
virtual bool check(const TQString &word)
Checks the given word.
Definition: kspell_hspelldict.cpp:46
HSpellDict::suggest
virtual TQStringList suggest(const TQString &word)
Fetches suggestions for the word.
Definition: kspell_hspelldict.cpp:64
KSpell2
kspell_hspellclient.h
Definition: backgroundchecker.h:28

kspell2

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

kspell2

Skip menu "kspell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kspell2 by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |