]> git.lyx.org Git - lyx.git/blob - src/Thesaurus.C
Enable the file dialog to open files with non-latin filenames.
[lyx.git] / src / Thesaurus.C
1 /**
2  * \file Thesaurus.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Thesaurus.h"
14
15 #ifdef HAVE_LIBAIKSAURUS
16
17 #include <algorithm>
18
19 using std::sort;
20
21
22 Thesaurus::Thesaurus()
23 {
24         aik_ = new Aiksaurus;
25 }
26
27
28 Thesaurus::~Thesaurus()
29 {
30         delete aik_;
31 }
32
33
34 Thesaurus::Meanings Thesaurus::lookup(string const & text)
35 {
36         Meanings meanings;
37
38         if (!aik_->find(text.c_str()))
39                 return meanings;
40
41         // weird api, but ...
42
43         int prev_meaning = -1;
44         int cur_meaning;
45         string meaning;
46
47         // correct, returns "" at the end
48         string ret = aik_->next(cur_meaning);
49
50         while (!ret.empty()) {
51                 if (cur_meaning != prev_meaning) {
52                         meaning = ret;
53                         ret = aik_->next(cur_meaning);
54                         prev_meaning = cur_meaning;
55                 } else {
56                         if (ret != text) {
57                                 meanings[meaning].push_back(ret);
58                         }
59                 }
60
61                 ret = aik_->next(cur_meaning);
62         }
63
64         for (Meanings::iterator it = meanings.begin();
65                 it != meanings.end(); ++it) {
66                         sort(it->second.begin(), it->second.end());
67         }
68
69         return meanings;
70 }
71
72 #else
73
74 Thesaurus::Thesaurus()
75 {
76 }
77
78
79 Thesaurus::~Thesaurus()
80 {
81 }
82
83
84 Thesaurus::Meanings Thesaurus::lookup(string const &)
85 {
86         return Meanings();
87 }
88
89 #endif // HAVE_LIBAIKSAURUS
90
91 // Global instance
92 Thesaurus thesaurus;