From 5bfbd89faa07d7f0cb4db48d2970231a6ce42d47 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Mon, 16 Apr 2007 13:58:20 +0000 Subject: [PATCH] added first shot on relevance ranking testing, still incomplete and segfaulting. Compile an run using 'make check' --- src/Makefile.am | 14 ++++-- src/test_relevance.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/test_relevance.c diff --git a/src/Makefile.am b/src/Makefile.am index 2de3ac3..d1125aa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,8 @@ -# $Id: Makefile.am,v 1.7 2007-04-16 09:07:57 adam Exp $ +# $Id: Makefile.am,v 1.8 2007-04-16 13:58:20 marc Exp $ bin_PROGRAMS = pazpar2 +check_PROGRAMS = test_relevance +TESTS = $(check_PROGRAMS) noinst_LIBRARIES = libpazpar2.a @@ -8,12 +10,16 @@ MAINTAINERCLEANFILES = Makefile.in cconfig.h AM_CFLAGS = $(YAZINC) -pazpar2_SOURCES = pazpar2.c -pazpar2_LDADD = libpazpar2.a $(YAZLIB) - libpazpar2_a_SOURCES = config.c config.h eventl.c eventl.h \ http.c http_command.c http_command.h http.h \ logic.c pazpar2.h reclists.c reclists.h \ relevance.c relevance.h termlists.c termlists.h \ util.c util.h zeerex.c zeerex.h database.c database.h \ settings.h settings.c + + +pazpar2_SOURCES = pazpar2.c +pazpar2_LDADD = libpazpar2.a $(YAZLIB) + +test_relevance_SOURCES = test_relevance.c +test_relevance_LDADD = libpazpar2.a $(YAZLIB) diff --git a/src/test_relevance.c b/src/test_relevance.c new file mode 100644 index 0000000..b3b0f3e --- /dev/null +++ b/src/test_relevance.c @@ -0,0 +1,117 @@ +/* $Id: test_relevance.c,v 1.1 2007-04-16 13:58:20 marc Exp $ + Copyright (c) 2006-2007, Index Data. + +This file is part of Pazpar2. + +Pazpar2 is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Pazpar2; see the file LICENSE. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAVE_CONFIG_H +#include "cconfig.h" +#endif + +#define USE_TIMING 0 +#if USE_TIMING +#include +#endif + +#include + + +//#include "pazpar2.h" +#include "relevance.h" + + + + + + + + +void test_relevance(int argc, char **argv) +{ + NMEM nmem = nmem_create(); + struct conf_service service; + struct record record; + struct reclist list; + struct record_cluster *cluster = 0; + struct relevance *rel = 0; + int numrecs = 10; + char mergekey[128]; + //const char * terms[] = + // {"ål", "abe", "økologi", "fisk", "æble", "yoghurt"}; + const char * terms[] = + {"abe", "fisk"}; + int total = 0; + struct record_metadata *metadata = 0; + + + relevance_create(nmem, terms, numrecs); + + relevance_prepare_read(rel, &list); + + cluster = reclist_insert(&service, &list, &record, mergekey, &total); + + //relevance_newrec(rel, cluster); + + //relevance_donerecord(se->relevance, cluster); + // relevance_countwords(se->relevance, cluster, + // (char *) value, md->rank); + // + + nmem_destroy(nmem); + + YAZ_CHECK(0 == 0); + //YAZ_CHECK_EQ(0, 1); + + + +} + + +int main(int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); + + + test_relevance(argc, argv); + + + YAZ_CHECK_TERM; +} + + + + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ -- 1.7.10.4