|
a/src/rcldb/synfamily.h |
|
b/src/rcldb/synfamily.h |
|
... |
|
... |
33 |
*/
|
33 |
*/
|
34 |
|
34 |
|
35 |
#include <string>
|
35 |
#include <string>
|
36 |
#include <vector>
|
36 |
#include <vector>
|
37 |
|
37 |
|
38 |
#include "xapian.h"
|
38 |
#include <xapian.h>
|
|
|
39 |
|
|
|
40 |
#include "debuglog.h"
|
|
|
41 |
#include "xmacros.h"
|
39 |
|
42 |
|
40 |
namespace Rcl {
|
43 |
namespace Rcl {
|
41 |
|
44 |
|
42 |
class XapSynFamily {
|
45 |
class XapSynFamily {
|
43 |
public:
|
46 |
public:
|
|
... |
|
... |
96 |
* the english member, add expansion for floor -> floors, flooring.. */
|
99 |
* the english member, add expansion for floor -> floors, flooring.. */
|
97 |
virtual bool addSynonyms(const std::string& membername,
|
100 |
virtual bool addSynonyms(const std::string& membername,
|
98 |
const std::string& term,
|
101 |
const std::string& term,
|
99 |
const std::vector<std::string>& trans);
|
102 |
const std::vector<std::string>& trans);
|
100 |
|
103 |
|
|
|
104 |
// Need to call setCurrentMemberName before addSynonym !
|
|
|
105 |
// We don't check it, for speed
|
|
|
106 |
virtual void setCurrentMemberName(const std::string& nm)
|
|
|
107 |
{
|
|
|
108 |
m_currentPrefix = entryprefix(nm);
|
|
|
109 |
}
|
|
|
110 |
virtual bool addSynonym(const std::string& term, const std::string& trans)
|
|
|
111 |
{
|
|
|
112 |
std::string key = m_currentPrefix + term;
|
|
|
113 |
std::string ermsg;
|
|
|
114 |
try {
|
|
|
115 |
m_wdb.add_synonym(key, trans);
|
|
|
116 |
} XCATCHERROR(ermsg);
|
|
|
117 |
if (!ermsg.empty()) {
|
|
|
118 |
LOGERR(("XapSynFamily::addSynonym: xapian error %s\n",
|
|
|
119 |
ermsg.c_str()));
|
|
|
120 |
return false;
|
|
|
121 |
}
|
|
|
122 |
return true;
|
|
|
123 |
}
|
|
|
124 |
|
101 |
protected:
|
125 |
protected:
|
102 |
Xapian::WritableDatabase m_wdb;
|
126 |
Xapian::WritableDatabase m_wdb;
|
|
|
127 |
std::string m_currentPrefix;
|
103 |
};
|
128 |
};
|
104 |
|
129 |
|
105 |
|
130 |
|
106 |
//
|
131 |
//
|
107 |
// Prefixes are centrally defined here to avoid collisions
|
132 |
// Prefixes are centrally defined here to avoid collisions
|
108 |
//
|
133 |
//
|
109 |
// Stem expansion family prefix. The family member name is the language
|
134 |
// Stem expansion family prefix. The family member name is the
|
|
|
135 |
// language ("all" for Dia and Cse)
|
110 |
static const std::string synFamStem("Stm");
|
136 |
static const std::string synFamStem("Stm");
|
111 |
static const std::string synFamDiac("Dia");
|
137 |
static const std::string synFamDiac("Dia");
|
112 |
static const std::string synFamCase("Cse");
|
138 |
static const std::string synFamCase("Cse");
|
113 |
|
139 |
|
114 |
|
140 |
|