3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "Thesaurus.h"
15 #include "support/lstrings.h"
22 #ifdef HAVE_LIBAIKSAURUS
28 Thesaurus::Thesaurus()
33 Thesaurus::~Thesaurus()
39 Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
43 // aiksaurus is for english text only, therefore it does not work
44 // with non-ascii strings.
45 // The interface of the Thesaurus class uses docstring because a
46 // non-english thesaurus is possible in theory.
47 if (!support::isAscii(t))
48 // to_ascii() would assert
51 string const text = to_ascii(t);
52 if (!aik_->find(text.c_str()))
57 int prev_meaning = -1;
61 // correct, returns "" at the end
62 string ret = aik_->next(cur_meaning);
64 while (!ret.empty()) {
65 if (cur_meaning != prev_meaning) {
66 meaning = from_ascii(ret);
67 ret = aik_->next(cur_meaning);
68 prev_meaning = cur_meaning;
71 meanings[meaning].push_back(from_ascii(ret));
74 ret = aik_->next(cur_meaning);
77 for (Meanings::iterator it = meanings.begin();
78 it != meanings.end(); ++it)
79 sort(it->second.begin(), it->second.end());
86 Thesaurus::Thesaurus()
91 Thesaurus::~Thesaurus()
96 Thesaurus::Meanings Thesaurus::lookup(docstring const &)
101 #endif // HAVE_LIBAIKSAURUS