Thanks for the quick reply!?I?really appreciate?your help but still no luck with
synonums. The goal is to get some results from database providing synonum
to?query not origin word.
?
Full code example:
?
#pragma warning(disable : 4996)
#include <iostream>
#include "xapian.h"
?
int main()
{
?? ?Xapian::WritableDatabase db("./index_data_test",
Xapian::DB_CREATE_OR_OPEN);
?? ?//db.add_synonym("time", "clock");
??  ?db.add_synonym("?????", "?????");
?
?? ?Xapian::TermGenerator indexer;
?? ?indexer.set_database(db);
?? ?indexer.set_flags(indexer.FLAG_SPELLING);
?
?? ?//Xapian::Stem stemmer("ru"); //no effect
?? ?//indexer.set_stemmer(stemmer);
?
?? ?//std::string content = "Old clock";
?? ? std::string content = "?????? ?????";
?? ?Xapian::Document doc1;
?? ?doc1.set_data(content);
?? ?indexer.set_document(doc1);
?? ?indexer.index_text(content);
?? ?db.add_document(doc1);
?? ?db.commit();
?? ?db.close();
?
?? ?Xapian::Database db1("./index_data_test");
?? ?//std::string word = "time";
?? ? std::string word = "?????";
?? ?for (auto t = db1.synonyms_begin(word); t != db1.synonyms_end(word); t++)
?? ?{
?? ??? ?std::cout << "A synonym for " << word <<
" is " << *t << "\n";
?? ?}
?? ?std::cout << db1.get_description() << " " <<
db1.get_doccount() << std::endl;
?
?? ?Xapian::Enquire enquire(db1);
?? ?Xapian::QueryParser qp;
?? ?//qp.set_stemmer(stemmer);
?? ?qp.set_database(db1);
?? ?//qp.set_stemming_strategy(qp.STEM_ALL);
?
?? ?Xapian::Query query = qp.parse_query("~" + word,
Xapian::QueryParser::FLAG_DEFAULT | Xapian::QueryParser::FLAG_SYNONYM); // no
result without "~". FLAG_AUTO_SYNONYMS is the way to
avoid?"~"
?? ?enquire.set_query(query);
?? ?Xapian::MSet matches = enquire.get_mset(0, db1.get_doccount());
?? ?std::cout << matches.get_matches_estimated() << std::endl;
?? ?std::cout << matches.size() << std::endl;
?
?? ?db1.close();
}
?
-?If I use Russain there are no matches in database:
A synonym for ????? is ?????
Database() 1
0
0
?
- If I use English?the output results are:
A synonym for time is clock
Database() 1
1
1
?
Am I indexing wrong way?
Or it is need to put some extra?flags while building? Using:
./configure ?CC="cl -nologo"
CXX="D:/_CPP/xapian-core-1.4.29/compile cl -nologo"
CXXFLAGS="-EHsc -Zi" AR=lib
CPPFLAGS="-I/D/_CPP/_Lib/zlib/include"
LDFLAGS="-L/D/_CPP/_Lib/zlib/lib" --prefix="D:/x"?
?
?
?
-----
??????
?
?