*** empty log message ***
This commit is contained in:
+37
-1
@@ -2,7 +2,7 @@
|
||||
CXXFLAGS = -Wall -g -I. -I../index -I../utils -I../common -I/usr/local/include
|
||||
|
||||
|
||||
PROGS = xadump
|
||||
PROGS = qtry qxtry xadump
|
||||
all: $(PROGS)
|
||||
|
||||
XADUMP_OBJS= xadump.o transcode.o
|
||||
@@ -10,8 +10,44 @@ xadump : $(XADUMP_OBJS)
|
||||
$(CXX) $(CXXFLAGS) -o xadump $(XADUMP_OBJS) \
|
||||
-L/usr/local/lib -lxapian -liconv
|
||||
|
||||
QXTRY_OBJS= qxtry.o transcode.o
|
||||
qxtry : $(QXTRY_OBJS)
|
||||
$(CXX) $(CXXFLAGS) -o qxtry $(QXTRY_OBJS) \
|
||||
-L/usr/local/lib -lxapian -liconv
|
||||
|
||||
QTRY_OBJS= qtry.o conftree.o rclconfig.o \
|
||||
rcldb.o transcode.o \
|
||||
textsplit.o unac.o unacpp.o pathut.o
|
||||
|
||||
qtry : $(QTRY_OBJS)
|
||||
$(CXX) $(CXXFLAGS) -o qtry $(QTRY_OBJS) \
|
||||
-L/usr/local/lib -lxapian -liconv
|
||||
|
||||
transcode.o : ../index/transcode.cpp ../index/transcode.h
|
||||
$(CXX) $(CXXFLAGS) -c -o transcode.o ../index/transcode.cpp
|
||||
|
||||
conftree.o : ../utils/conftree.cpp ../utils/conftree.h
|
||||
$(CXX) $(CXXFLAGS) -c -o conftree.o ../utils/conftree.cpp
|
||||
rclconfig.o : ../common/rclconfig.cpp ../common/rclconfig.h
|
||||
$(CXX) $(CXXFLAGS) -c -o rclconfig.o ../common/rclconfig.cpp
|
||||
unacpp.o : ../common/unacpp.cpp ../common/unacpp.h
|
||||
$(CXX) $(CXXFLAGS) -I../unac -c -o unacpp.o ../common/unacpp.cpp
|
||||
pathut.o : ../utils/pathut.cpp ../utils/pathut.h
|
||||
$(CXX) $(CXXFLAGS) -c -o pathut.o ../utils/pathut.cpp
|
||||
rcldb.o : ../common/rcldb.cpp ../common/rcldb.h
|
||||
$(CXX) $(CXXFLAGS) -c -o rcldb.o ../common/rcldb.cpp
|
||||
textsplit.o : ../common/textsplit.cpp ../common/textsplit.h
|
||||
$(CXX) $(CXXFLAGS) -c -o textsplit.o ../common/textsplit.cpp
|
||||
|
||||
|
||||
CFLAGS = -g -I. -I../unac -I/usr/local/include -DUNAC_VERSION=\"1.0.7\"
|
||||
unac.o : ../unac/unac.c ../unac/unac.h
|
||||
$(CC) $(CFLAGS) -c -o unac.o ../unac/unac.c
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROGS)
|
||||
alldeps:depend
|
||||
depend:
|
||||
$(CXX) $(CXXFLAGS) -M *.cpp > alldeps
|
||||
include alldeps
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: qtry.cpp,v 1.1 2005-01-24 13:17:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
// Tests with the query interface
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "conftree.h"
|
||||
#include "rclconfig.h"
|
||||
#include "rcldb.h"
|
||||
#include "transcode.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "rcldb.h"
|
||||
|
||||
static string thisprog;
|
||||
|
||||
static string usage =
|
||||
" -d <dbdir> -e <interface encoding> term [term] ..."
|
||||
" \n\n"
|
||||
;
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
cerr << thisprog << ": usage:\n" << usage;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int op_flags;
|
||||
#define OPT_e 0x2
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
string encoding = "ISO8859-1";
|
||||
|
||||
thisprog = argv[0];
|
||||
argc--; argv++;
|
||||
|
||||
while (argc > 0 && **argv == '-') {
|
||||
(*argv)++;
|
||||
if (!(**argv))
|
||||
/* Cas du "adb - core" */
|
||||
Usage();
|
||||
while (**argv)
|
||||
switch (*(*argv)++) {
|
||||
case 'e': op_flags |= OPT_e; if (argc < 2) Usage();
|
||||
encoding = *(++argv);
|
||||
argc--;
|
||||
goto b1;
|
||||
default: Usage(); break;
|
||||
}
|
||||
b1: argc--; argv++;
|
||||
}
|
||||
if (argc < 1)
|
||||
Usage();
|
||||
|
||||
RclConfig *config = new RclConfig;
|
||||
|
||||
if (!config->ok())
|
||||
cerr << "Config could not be built" << endl;
|
||||
|
||||
string dbdir;
|
||||
if (config->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
cerr << "No database directory in configuration" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Rcl::Db *db = new Rcl::Db;
|
||||
|
||||
if (!db->open(dbdir, Rcl::Db::DbRO)) {
|
||||
fprintf(stderr, "Could not open database\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// TOBEDONE: query syntax. Yes it's mighty stupid to cat terms.
|
||||
string query;
|
||||
while (argc--)
|
||||
query += string(*argv++) + " " ;
|
||||
db->setQuery(query);
|
||||
int i = 0;
|
||||
Rcl::Doc doc;
|
||||
while (db->getDoc(i++, doc)) {
|
||||
cout << "Url: " << doc.url << endl;
|
||||
cout << "Mimetype: " << doc.mimetype << endl;
|
||||
cout << "Mtime: " << doc.mtime << endl;
|
||||
cout << "Origcharset: " << doc.origcharset << endl;
|
||||
cout << "Title: " << doc.title << endl;
|
||||
cout << "Text: " << doc.text << endl;
|
||||
cout << "Keywords: " << doc.keywords << endl;
|
||||
cout << "Abstract: " << doc.abstract << endl;
|
||||
cout << endl;
|
||||
|
||||
doc.erase();
|
||||
}
|
||||
delete db;
|
||||
cerr << "Exiting" << endl;
|
||||
exit(0);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: qxtry.cpp,v 1.1 2005-01-24 13:17:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
// Tests with direct xapian questions
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "transcode.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "xapian.h"
|
||||
|
||||
static string thisprog;
|
||||
|
||||
static string usage =
|
||||
" -d <dbdir> -e <interface encoding> term [term] ..."
|
||||
" \n\n"
|
||||
;
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
cerr << thisprog << ": usage:\n" << usage;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int op_flags;
|
||||
#define OPT_d 0x1
|
||||
#define OPT_e 0x2
|
||||
|
||||
Xapian::Database db;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
string dbdir = "/home/dockes/tmp/xapiandb";
|
||||
string encoding = "ISO8859-1";
|
||||
|
||||
thisprog = argv[0];
|
||||
argc--; argv++;
|
||||
|
||||
while (argc > 0 && **argv == '-') {
|
||||
(*argv)++;
|
||||
if (!(**argv))
|
||||
/* Cas du "adb - core" */
|
||||
Usage();
|
||||
while (**argv)
|
||||
switch (*(*argv)++) {
|
||||
case 'd': op_flags |= OPT_e; if (argc < 2) Usage();
|
||||
dbdir = *(++argv);
|
||||
argc--;
|
||||
goto b1;
|
||||
case 'e': op_flags |= OPT_d; if (argc < 2) Usage();
|
||||
encoding = *(++argv);
|
||||
argc--;
|
||||
goto b1;
|
||||
default: Usage(); break;
|
||||
}
|
||||
b1: argc--; argv++;
|
||||
}
|
||||
if (argc < 1)
|
||||
Usage();
|
||||
|
||||
vector<string> qterms;
|
||||
while (argc--) {
|
||||
qterms.push_back(*argv++);
|
||||
}
|
||||
|
||||
try {
|
||||
db = Xapian::Auto::open(dbdir, Xapian::DB_OPEN);
|
||||
|
||||
cout << "DB: ndocs " << db.get_doccount() << " lastdocid " <<
|
||||
db.get_lastdocid() << " avglength " << db.get_avlength() << endl;
|
||||
|
||||
Xapian::Enquire enquire(db);
|
||||
|
||||
Xapian::Query query(Xapian::Query::OP_OR, qterms.begin(),
|
||||
qterms.end());
|
||||
cout << "Performing query `" <<
|
||||
query.get_description() << "'" << endl;
|
||||
enquire.set_query(query);
|
||||
|
||||
Xapian::MSet matches = enquire.get_mset(0, 10);
|
||||
cout << "Estimated results: " << matches.get_matches_lower_bound() <<
|
||||
endl;
|
||||
Xapian::MSetIterator i;
|
||||
for (i = matches.begin(); i != matches.end(); ++i) {
|
||||
cout << "Document ID " << *i << "\t";
|
||||
cout << i.get_percent() << "% ";
|
||||
Xapian::Document doc = i.get_document();
|
||||
cout << "[" << doc.get_data() << "]" << endl;
|
||||
}
|
||||
|
||||
} catch (const Xapian::Error &e) {
|
||||
cout << "Exception: " << e.get_msg() << endl;
|
||||
} catch (const string &s) {
|
||||
cout << "Exception: " << s << endl;
|
||||
} catch (const char *s) {
|
||||
cout << "Exception: " << s << endl;
|
||||
} catch (...) {
|
||||
cout << "Caught unknown exception" << endl;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user