Back to index

Public Member Functions | Public Attributes | Private Attributes
dictionary_rep Class Reference

#include <dictionary.hpp>

Inheritance diagram for dictionary_rep:
Inheritance graph
Collaboration diagram for dictionary_rep:
Collaboration graph

List of all members.

Public Member Functions

 dictionary_rep (string from, string to)
void load (url fname)
void load (string fname)
string translate (string s)

Public Attributes

string res_name

Private Attributes

hashmap< string, stringtable
string from
string to

Detailed Description

Definition at line 23 of file dictionary.hpp.

Constructor & Destructor Documentation

Definition at line 24 of file dictionary.cpp.

  rep<dictionary> (from2 * "-" * to2), table ("?"), from (from2), to (to2) {}

Member Function Documentation

void dictionary_rep::load ( url  fname)

Definition at line 28 of file dictionary.cpp.

  if (is_none (u)) return;
  if (is_or (u)) {
    load (u[1]);
    load (u[2]);

  string s;
  if (load_string (u, s, false)) return;
  tree t= block_to_scheme_tree (s);
  if (!is_tuple (t)) return;

  int i, n= N(t);
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2) &&
       is_atomic (t[i][0]) && is_atomic (t[i][1]))
       string l= t[i][0]->label; if (is_quoted (l)) l= scm_unquote (l);
       string r= t[i][1]->label; if (is_quoted (r)) r= scm_unquote (r);
       if (to == "chinese" || to == "japanese" ||
           to == "korean" || to == "taiwanese")
         r= utf8_to_cork (r);
       table (l)= r;

Here is the call graph for this function:

Here is the caller graph for this function:

void dictionary_rep::load ( string  fname)

Definition at line 56 of file dictionary.cpp.

  fname= fname * ".scm";
  if (DEBUG_VERBOSE) cout << "TeXmacs] Loading " << fname << "\n";
  url u= url ("$TEXMACS_DIC_PATH") * url_wildcard ("*" * fname);
  load (expand (complete (u)));

Here is the call graph for this function:

Definition at line 78 of file dictionary.cpp.

  // Is s in dictionary?
  if (s == "" || from == to) return s;
  //cout << "Translate <" << s << ">\n";
  if (table->contains (s) && table[s] != "")
    return table[s];

  // remove trailing non iso_alpha characters
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (is_iso_alpha (s[i]))
  int start= i;
  for (i=n; i>0; i--)
    if (is_iso_alpha (s[i-1]))
  int end= i;
  if (start >= n || end <= 0) return s;
  if (start != 0 || end != n) {
    ASSERT (start < end, "invalid situation");
    string s1= translate (s (0, start));
    string s2= translate (s (start, end));
    string s3= translate (s (end, n));
    if (to == "french") {
      if (s3 == ":") s3= " :";
      if (s3 == "!") s3= " !";
      if (s3 == "?") s3= " ?";
    return s1 * s2 * s3;

  // Is lowercase version of s in dictionary?
  string ls= locase_first (s);
  if (table->contains (ls) && table[ls] != "")
    return upcase_first (table[ls]);

  // break at last non iso_alpha character which is not a space
  for (i=n; i>0; i--)
    if (!is_iso_alpha (s[i-1]) && s[i-1] != ' ')
  if (i > 0) {
    string s1= translate (s (0, i));
    string s2= translate (s (i, n));
    return s1 * s2;

  // no translation available
  return s;

Here is the call graph for this function:

Member Data Documentation

Definition at line 25 of file dictionary.hpp.

string rep< dictionary >::res_name [inherited]

Definition at line 17 of file resource.hpp.

Definition at line 24 of file dictionary.hpp.

Definition at line 25 of file dictionary.hpp.

The documentation for this class was generated from the following files: