Back to index

texmacs  1.0.7.15
Classes | Functions | Variables
ispell.cpp File Reference
#include "Ispell/ispell.hpp"
#include "file.hpp"
#include "resource.hpp"
#include "tm_link.hpp"
#include "convert.hpp"

Go to the source code of this file.

Classes

struct  ispeller_rep

Functions

string ispell_dictionary (string lang)
string ispell_extra_args (string lang)
string ispell_encode (string lan, string s)
string ispell_decode (string lan, string s)
 RESOURCE (ispeller)
 RESOURCE_CODE (ispeller)
static void init_dictionary (string lang, string dict)
static tree parse_ispell (string s)
static void ispell_send (string lan, string s)
static string ispell_eval (string lan, string s)
string ispell_start (string lan)
tree ispell_check (string lan, string s)
void ispell_accept (string lan, string s)
void ispell_insert (string lan, string s)
void ispell_done (string lan)

Variables

static hashmap< string, stringthe_dict ("")

Function Documentation

static void init_dictionary ( string  lang,
string  dict 
) [static]

Definition at line 120 of file ispell.cpp.

                                           {
  if (the_dict->contains (lang)) return;
  if (exists ("/usr/lib/ispell/" * dict * ".hash") ||
      exists ("/usr/lib/aspell/" * dict) ||
      exists ("/usr/lib/aspell/" * dict * ".multi"))
    the_dict (lang)= dict;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ispell_accept ( string  lan,
string  s 
)

Definition at line 285 of file ispell.cpp.

                                     {
  if (DEBUG_IO) cout << "Ispell] Accept " << s << "\n";
  ispell_send (lan, "@" * s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree ispell_check ( string  lan,
string  s 
)

Definition at line 272 of file ispell.cpp.

                                    {
  if (DEBUG_IO) cout << "Ispell] Check " << s << "\n";
  ispeller sc= ispeller (lan);
  if (is_nil (sc) || (!sc->ln->alive)) {
    string message= ispell_start (lan);
    if (starts (message, "Error: ")) return message;
  }
  string ret_s= ispell_eval (lan, "^" * s);
  if (starts (ret_s, "Error: ")) return ret_s;
  return parse_ispell (ret_s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string ispell_decode ( string  lan,
string  s 
)

Definition at line 195 of file ispell.cpp.

                                     {
  if ((lan == "czech") || (lan == "hungarian") ||
      (lan == "polish") || (lan == "slovene"))
    return il2_to_cork (s);
  else if ((lan == "bulgarian") || (lan == "russian"))
    return iso_to_koi8 (s);
  else if (lan == "ukrainian")
    return iso_to_koi8uk (s);
  else if (lan == "spanish")
    return ispanish_to_spanish (s);
  else if (lan == "german")
    return igerman_to_german (s);
  else return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 129 of file ispell.cpp.

                                {
  if (N(the_dict) == 0) {
    init_dictionary ("english", "english");
    init_dictionary ("english", "american");
    init_dictionary ("danish", "danish");
    init_dictionary ("danish", "dansk");
    init_dictionary ("dutch", "dutch");
    init_dictionary ("dutch", "nederlands");
    init_dictionary ("french", "french");
    init_dictionary ("french", "francais");
    init_dictionary ("german", "german");
    init_dictionary ("german", "deutsch");
    init_dictionary ("german", "ngerman");
    init_dictionary ("german", "ndeutsch");
    init_dictionary ("german", "ogerman");
    init_dictionary ("german", "odeutsch");
    init_dictionary ("german", "swiss");
    init_dictionary ("portuguese", "portuguese");
    init_dictionary ("portuguese", "portugues");
    init_dictionary ("portuguese", "brazilian");
    init_dictionary ("portuguese", "brasileiro");
    init_dictionary ("spanish", "spanish");
    init_dictionary ("spanish", "espaƱol");
    init_dictionary ("spanish", "espa~nol");
    init_dictionary ("spanish", "espanol");
    init_dictionary ("spanish", "castellano");
    init_dictionary ("swedish", "swedish");
    init_dictionary ("swedish", "svenska");
  }
  if (the_dict->contains (lang)) return the_dict [lang];
  return lang;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ispell_done ( string  lan)

Definition at line 297 of file ispell.cpp.

                         {
  if (DEBUG_IO) cout << "Ispell] End " << lan << "\n";
  ispell_send (lan, "#");
}

Here is the call graph for this function:

Here is the caller graph for this function:

string ispell_encode ( string  lan,
string  s 
)

Definition at line 179 of file ispell.cpp.

                                     {
  if ((lan == "czech") || (lan == "hungarian") ||
      (lan == "polish") || (lan == "slovene"))
    return cork_to_il2 (s);
  else if ((lan == "bulgarian") || (lan == "russian"))
    return koi8_to_iso (s);
  else if (lan == "ukrainian")
    return koi8uk_to_iso (s);
  else if (lan == "spanish")
    return spanish_to_ispanish (s);
  else if (lan == "german")
    return german_to_igerman (s);
  else return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string ispell_eval ( string  lan,
string  s 
) [static]

Definition at line 250 of file ispell.cpp.

                                   {
  ispeller sc= ispeller (lan);
  if ((!is_nil (sc)) && sc->ln->alive) {
    sc->send (s);
    return sc->retrieve ();
  }
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 167 of file ispell.cpp.

                               {
  if (lan == "german")
    return " -T latin1";
  else
    return "";
}

Here is the caller graph for this function:

void ispell_insert ( string  lan,
string  s 
)

Definition at line 291 of file ispell.cpp.

                                     {
  if (DEBUG_IO) cout << "Ispell] Insert " << s << "\n";
  ispell_send (lan, "*" * s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ispell_send ( string  lan,
string  s 
) [static]

Definition at line 244 of file ispell.cpp.

                                   {
  ispeller sc= ispeller (lan);
  if ((!is_nil (sc)) && sc->ln->alive) sc->send (s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 264 of file ispell.cpp.

                          {
  if (DEBUG_IO) cout << "Ispell] Start " << lan << "\n";
  ispeller sc= ispeller (lan);
  if (is_nil (sc)) sc= tm_new<ispeller_rep> (lan);
  return sc->start ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree parse_ispell ( string  s) [static]

Definition at line 215 of file ispell.cpp.

                        {
#if defined (__MINGW__) || defined (__MINGW32__)
  while (ends (s, "\r\n")) s= s (0, N(s)-2);
#else
  while (ends (s, "\n")) s= s (0, N(s)-1);
#endif
  bool flag= true;
  int i, j;
  tree t (TUPLE);
  for (i=0, j=0; j<N(s); j++)
    if (s[j]==':') flag= false;
    else if (((s[j]==' ') && (flag || (j==i) || (s[j-1]==':'))) || (s[j]==','))
      {
       if (j>i) t << s (i, j);
       i= j+1;
      }
  t << s (i, j);

  if (N(t) == 0) return tree (TUPLE, "0");
  if ((t[0] == "+") || (t[0] == "*") || (t[0] == "-")) return "ok";
  if ((N(t)>=4) && ((t[0] == "&") || (t[0]=="?"))) {
    tree u (TUPLE, t[2]);
    u << A (t (4, N (t)));
    return u;
  }
  return tree (TUPLE, "0");
}

Here is the call graph for this function:

Here is the caller graph for this function:

RESOURCE ( ispeller  )
RESOURCE_CODE ( ispeller  )

Variable Documentation

hashmap<string,string> the_dict("") [static]