]> git.lyx.org Git - lyx.git/blob - src/Thesaurus.C
John's Layout Tabular UI improvements and Martins fixes to clearing the
[lyx.git] / src / Thesaurus.C
1 /**
2  * \file Thesaurus.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #include <config.h>
10
11 #include "Thesaurus.h"
12
13 Thesaurus thesaurus; 
14
15 #ifdef HAVE_LIBAIKSAURUS
16  
17 Thesaurus::ThesaurusEntry::ThesaurusEntry(string const & ent, char part)
18         : entry(ent), pos(Thesaurus::NONE)
19 {
20         if (part & AikSaurus::Unknown)
21                 pos |= OTHER;
22         if (part & AikSaurus::Other)
23                 pos |= OTHER;
24         if (part & AikSaurus::Noun)
25                 pos |= NOUN;
26         if (part & AikSaurus::Verb)
27                 pos |= VERB;
28         if (part & AikSaurus::Adjective)
29                 pos |= ADJECTIVE;
30         if (part & AikSaurus::Adverb)
31                 pos |= ADVERB;
32 }
33
34
35 Thesaurus::Thesaurus()
36 {
37         aik_ = new AikSaurus;
38 }
39
40
41 Thesaurus::~Thesaurus()
42 {
43         delete aik_;
44 }
45
46
47 std::vector<Thesaurus::ThesaurusEntry> Thesaurus::lookup(string const & text)
48 {
49         std::vector<ThesaurusEntry> entries;
50
51         if (!aik_->find(text.c_str()))
52                 return entries;
53
54         char pos;
55
56         string ret = aik_->next(pos);
57         while (!ret.empty()) {
58                 entries.push_back(ThesaurusEntry(ret, pos));
59                 ret = aik_->next(pos);
60         }
61
62         return entries;
63 }
64
65 #else
66
67 Thesaurus::ThesaurusEntry::ThesaurusEntry(string const &, char)
68 {
69 }
70
71  
72 Thesaurus::Thesaurus()
73 {
74 }
75  
76  
77 Thesaurus::~Thesaurus()
78 {
79 }
80
81  
82 std::vector<Thesaurus::ThesaurusEntry>
83 Thesaurus::lookup(string const & /*text*/)
84 {
85         return std::vector<ThesaurusEntry>();
86 }
87
88 #endif // HAVE_LIBAIKSAURUS