From: <tho...@us...> - 2011-05-20 15:05:07
|
Revision: 4530 http://bigdata.svn.sourceforge.net/bigdata/?rev=4530&view=rev Author: thompsonbry Date: 2011-05-20 15:04:59 +0000 (Fri, 20 May 2011) Log Message: ----------- Changed the default minRelevance value to 0.25 (from 0.0) and updated the unit tests and code to match. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/ITextIndexer.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/BD.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestFullTextIndex.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/FreeTextSearchExpander.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlClient.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/ITextIndexer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/ITextIndexer.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/ITextIndexer.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -79,40 +79,42 @@ */ public boolean getIndexDatatypeLiterals(); - /** - * Do free text search - * - * @param query - * The query (it will be parsed into tokens). - * @param languageCode - * The language code that should be used when tokenizing the - * query -or- <code>null</code> to use the default {@link Locale} - * ). - * @param prefixMatch - * When <code>true</code>, the matches will be on tokens which - * include the query tokens as a prefix. This includes exact - * matches as a special case when the prefix is the entire token, - * but it also allows longer matches. For example, - * <code>free</code> will be an exact match on <code>free</code> - * but a partial match on <code>freedom</code>. When - * <code>false</code>, only exact matches will be made. - * @param minCosine - * The minimum cosine that will be returned. - * @param maxCosine - * The maximum cosine that will be returned. Useful for - * evaluating in relevance ranges. - * @param maxRank - * The upper bound on the #of hits in the result set. - * @param matchAllTerms - * if true, return only hits that match all search terms - * @param timeout - * The timeout -or- ZERO (0) for NO timeout (this is equivalent - * to using {@link Long#MAX_VALUE}). - * @param unit - * The unit in which the timeout is expressed. - * - * @return The result set. - */ + /** + * Do free text search + * + * @param query + * The query (it will be parsed into tokens). + * @param languageCode + * The language code that should be used when tokenizing the + * query -or- <code>null</code> to use the default {@link Locale} + * ). + * @param prefixMatch + * When <code>true</code>, the matches will be on tokens which + * include the query tokens as a prefix. This includes exact + * matches as a special case when the prefix is the entire token, + * but it also allows longer matches. For example, + * <code>free</code> will be an exact match on <code>free</code> + * but a partial match on <code>freedom</code>. When + * <code>false</code>, only exact matches will be made. + * @param minCosine + * The minimum cosine that will be returned (in [0:maxCosine]). + * If you specify a minimum cosine of ZERO (0.0) you can drag in + * a lot of basically useless search results. + * @param maxCosine + * The maximum cosine that will be returned (in [minCosine:1.0]). + * Useful for evaluating in relevance ranges. + * @param maxRank + * The upper bound on the #of hits in the result set. + * @param matchAllTerms + * if true, return only hits that match all search terms + * @param timeout + * The timeout -or- ZERO (0) for NO timeout (this is equivalent + * to using {@link Long#MAX_VALUE}). + * @param unit + * The unit in which the timeout is expressed. + * + * @return The result set. + */ public Hiterator<A> search(final String query, final String languageCode, final boolean prefixMatch, final double minCosine, final double maxCosine, Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/BD.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/BD.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/BD.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -165,40 +165,63 @@ * } * * </pre> + * + * The default is {@value #DEFAULT_MAX_HITS}. */ final URI MAX_HITS = new URIImpl(SEARCH_NAMESPACE+"maxHits"); - + /** - * Magic predicate used to query for free text search metadata. Use - * in conjunction with {@link #SEARCH} as follows: - * <p> - * <pre> - * - * select ?s - * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:minRelevance "0.5"^^xsd:double . - * } - * - * </pre> + * The default for {@link #MAX_HITS}. */ + final int DEFAULT_MAX_HITS = Integer.MAX_VALUE; + + /** + * Magic predicate used to query for free text search metadata. Use in + * conjunction with {@link #SEARCH} as follows: + * <p> + * + * <pre> + * + * select ?s + * where { + * ?s bd:search "scale-out RDF triplestore" . + * ?s bd:minRelevance "0.5"^^xsd:double . + * } + * + * </pre> + * + * The relevance scores are in [0.0:1.0]. You should NOT specify a minimum + * relevance of ZERO (0.0) as this can drag in way too many unrelated + * results. The default is {@value #DEFAULT_MIN_RELEVANCE}. + */ final URI MIN_RELEVANCE = new URIImpl(SEARCH_NAMESPACE+"minRelevance"); + final double DEFAULT_MIN_RELEVANCE = 0.25d; + + /** + * Magic predicate used to query for free text search metadata. Use in + * conjunction with {@link #SEARCH} as follows: + * <p> + * + * <pre> + * + * select ?s + * where { + * ?s bd:search "scale-out RDF triplestore" . + * ?s bd:maxRelevance "0.9"^^xsd:double . + * } + * + * </pre> + * + * The relevance scores are in [0.0:1.0]. The default maximum relevance is + * {@value #DEFAULT_MAX_RELEVANCE}. + */ + final URI MAX_RELEVANCE = new URIImpl(SEARCH_NAMESPACE+"maxRelevance"); + /** - * Magic predicate used to query for free text search metadata. Use - * in conjunction with {@link #SEARCH} as follows: - * <p> - * <pre> - * - * select ?s - * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:maxRelevance "0.9"^^xsd:double . - * } - * - * </pre> + * The default value for {@link #MAX_RELEVANCE} unless overridden. */ - final URI MAX_RELEVANCE = new URIImpl(SEARCH_NAMESPACE+"maxRelevance"); + final double DEFAULT_MAX_RELEVANCE = 1.0d; /** * Magic predicate used to query for free text search metadata. Use @@ -216,7 +239,16 @@ */ final URI MATCH_ALL_TERMS = new URIImpl(SEARCH_NAMESPACE+"matchAllTerms"); + final boolean DEFAULT_MATCH_ALL_TERMS = false; + + final boolean DEFAULT_PREFIX_MATCH = false; + /** + * The default timeout for a free text search (milliseconds). + */ + final long DEFAULT_TIMEOUT = Long.MAX_VALUE; + + /** * Sesame has the notion of a "null" graph. Any time you insert a statement * into a quad store and the context position is not specified, it is * actually inserted into this "null" graph. If SPARQL <code>DATASET</code> Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestFullTextIndex.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestFullTextIndex.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestFullTextIndex.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -136,8 +136,9 @@ minCosine, 1.0d/* maxCosine */, Integer.MAX_VALUE/* maxRank */, false/* matchAllTerms */, - 2L/* timeout */, - TimeUnit.SECONDS); + Long.MAX_VALUE,//2L/* timeout */, + TimeUnit.MILLISECONDS// TimeUnit.SECONDS + ); // assertEquals("#hits", (long) expected.length, itr.size()); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -30,7 +30,6 @@ import org.openrdf.query.algebra.BNodeGenerator; import org.openrdf.query.algebra.Bound; import org.openrdf.query.algebra.Compare; -import org.openrdf.query.algebra.Compare.CompareOp; import org.openrdf.query.algebra.CompareAll; import org.openrdf.query.algebra.CompareAny; import org.openrdf.query.algebra.Datatype; @@ -64,7 +63,6 @@ import org.openrdf.query.algebra.Regex; import org.openrdf.query.algebra.SameTerm; import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.StatementPattern.Scope; import org.openrdf.query.algebra.Str; import org.openrdf.query.algebra.TupleExpr; import org.openrdf.query.algebra.UnaryTupleOperator; @@ -72,6 +70,8 @@ import org.openrdf.query.algebra.ValueConstant; import org.openrdf.query.algebra.ValueExpr; import org.openrdf.query.algebra.Var; +import org.openrdf.query.algebra.Compare.CompareOp; +import org.openrdf.query.algebra.StatementPattern.Scope; import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl; import org.openrdf.query.algebra.evaluation.iterator.FilterIterator; import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; @@ -83,12 +83,12 @@ import com.bigdata.bop.IConstant; import com.bigdata.bop.IConstraint; import com.bigdata.bop.IPredicate; -import com.bigdata.bop.IPredicate.Annotations; import com.bigdata.bop.IValueExpression; import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; import com.bigdata.bop.NV; import com.bigdata.bop.PipelineOp; +import com.bigdata.bop.IPredicate.Annotations; import com.bigdata.bop.ap.Predicate; import com.bigdata.bop.bindingSet.ListBindingSet; import com.bigdata.bop.constraint.INBinarySearch; @@ -109,7 +109,6 @@ import com.bigdata.rdf.internal.constraints.IsLiteralBOp; import com.bigdata.rdf.internal.constraints.IsURIBOp; import com.bigdata.rdf.internal.constraints.MathBOp; -import com.bigdata.rdf.internal.constraints.MathBOp.MathOp; import com.bigdata.rdf.internal.constraints.NotBOp; import com.bigdata.rdf.internal.constraints.OrBOp; import com.bigdata.rdf.internal.constraints.RangeBOp; @@ -117,15 +116,16 @@ import com.bigdata.rdf.internal.constraints.SPARQLConstraint; import com.bigdata.rdf.internal.constraints.SameTermBOp; import com.bigdata.rdf.internal.constraints.StrBOp; +import com.bigdata.rdf.internal.constraints.MathBOp.MathOp; import com.bigdata.rdf.lexicon.LexiconRelation; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.sail.BigdataSail.Options; import com.bigdata.rdf.sail.sop.SOp; import com.bigdata.rdf.sail.sop.SOp2BOpUtility; import com.bigdata.rdf.sail.sop.SOpTree; -import com.bigdata.rdf.sail.sop.SOpTree.SOpGroup; import com.bigdata.rdf.sail.sop.SOpTreeBuilder; import com.bigdata.rdf.sail.sop.UnsupportedOperatorException; +import com.bigdata.rdf.sail.sop.SOpTree.SOpGroup; import com.bigdata.rdf.spo.DefaultGraphSolutionExpander; import com.bigdata.rdf.spo.ExplicitSPOFilter; import com.bigdata.rdf.spo.ISPO; @@ -2181,12 +2181,12 @@ final Iterator<IHit> itr = (Iterator)database.getLexiconRelation() .getSearchEngine().search(label, languageCode, - false/* prefixMatch */, - 0d/* minCosine */, - 1.0d/* maxCosine */, - Integer.MAX_VALUE/* maxRank */, - false/* matchAllTerms */, - 0L/* timeout */, + BD.DEFAULT_PREFIX_MATCH,//false/* prefixMatch */, + BD.DEFAULT_MIN_RELEVANCE,//0d/* minCosine */, + BD.DEFAULT_MAX_RELEVANCE,//1.0d/* maxCosine */, + BD.DEFAULT_MAX_HITS,//Integer.MAX_VALUE/* maxRank */, + BD.DEFAULT_MATCH_ALL_TERMS,//false/* matchAllTerms */, + BD.DEFAULT_TIMEOUT,//0/* timeout */, TimeUnit.MILLISECONDS); // ensure that named graphs are handled correctly for quads Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/FreeTextSearchExpander.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/FreeTextSearchExpander.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/FreeTextSearchExpander.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -169,23 +169,15 @@ prefixMatch = false; } - /* - * FIXME This is using a constant (1000ms) for the timeout on - * the free text search. That needs to be passed down from the - * SAIL. - * - * @todo Rather than explicitly passing in all of these as - * parameters to the constructor, why not pass them through as - * annotations on the magic predicate? - */ hiterator = textNdx.search(s, query.getLanguage(), prefixMatch, - minRelevance == null ? 0d : minRelevance.doubleValue()/* minCosine */, - maxRelevance == null ? 1.0d : maxRelevance.doubleValue()/* maxCosine */, - maxHits == null ? Integer.MAX_VALUE : maxHits.intValue()+1/* maxRank */, + minRelevance == null ? BD.DEFAULT_MIN_RELEVANCE : minRelevance.doubleValue()/* minCosine */, + maxRelevance == null ? BD.DEFAULT_MAX_RELEVANCE : maxRelevance.doubleValue()/* maxCosine */, + maxHits == null ? BD.DEFAULT_MAX_HITS/*Integer.MAX_VALUE*/ : maxHits.intValue()+1/* maxRank */, matchAllTerms, - 0L/* timeout */, TimeUnit.MILLISECONDS); + BD.DEFAULT_TIMEOUT/*0L*//* timeout */, + TimeUnit.MILLISECONDS); } return hiterator; Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlClient.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlClient.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlClient.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -866,7 +866,7 @@ public final String queryStr; /** Metadata about each query presentation. */ - public LinkedBlockingQueue<QueryTrial> trials = new LinkedBlockingQueue<QueryTrial>(/* unbounded */); + public final LinkedBlockingQueue<QueryTrial> trials = new LinkedBlockingQueue<QueryTrial>(/* unbounded */); /** * Total elapsed nanoseconds over all {@link QueryTrial}s for this @@ -939,7 +939,7 @@ /** * Order by increasing elapsed time (slowest queries are last). */ - public int compareTo(Score o) { + public int compareTo(final Score o) { if (elapsedNanos < o.elapsedNanos) return -1; if (elapsedNanos > o.elapsedNanos) Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEvaluationStrategyImpl.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEvaluationStrategyImpl.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -706,12 +706,14 @@ System.err.println("\"Mike\" = " + sail.getDatabase().getIV(new LiteralImpl("Mike"))); System.err.println("\"Jane\" = " + sail.getDatabase().getIV(new LiteralImpl("Jane"))); - String query = + final double minRelevance = 0d; + final String query = "select ?s ?label " + "where { " + " ?s <"+RDF.TYPE+"> <"+person+"> . " + // [160, 8, 164], [156, 8, 164] " ?s <"+RDFS.LABEL+"> ?label . " + // [160, 148, 174], [156, 148, 170] " ?label <"+search+"> \"Mi*\" . " + // [174, 0, 0] + " ?label <"+BD.MIN_RELEVANCE+"> \""+minRelevance+"\" . " + "}"; { // evalute it once so i can see it Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -1593,6 +1593,7 @@ public void testSearchQuery() throws Exception { + final double minRelevance = 0d; final BigdataSail sail = getSail(); try { sail.initialize(); @@ -1638,6 +1639,7 @@ "where { " + " ?y <"+ BD.SEARCH+"> \"Chris*\" . " + " ?x <"+ RDFS.LABEL.stringValue() + "> ?y . " + + " ?y <"+BD.MIN_RELEVANCE+"> \""+minRelevance+"\" . " + "}"; final TupleQuery tupleQuery = cxn.prepareTupleQuery( @@ -1671,6 +1673,7 @@ " graph <http://example.org> { " + " ?y <"+ BD.SEARCH+"> \"Chris*\" . " + " ?x <"+ RDFS.LABEL.stringValue() + "> ?y ." + + " ?y <"+BD.MIN_RELEVANCE+"> \""+minRelevance+"\" . " + " } . " + "}"; Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2011-05-20 00:12:12 UTC (rev 4529) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2011-05-20 15:04:59 UTC (rev 4530) @@ -300,7 +300,9 @@ final Set<Value> expected = new HashSet<Value>(); - expected.add(new LiteralImpl("Yellow Rose")); + // Note: Whether or not this solution is present depends on the + // default value for minCosine. +// expected.add(new LiteralImpl("Yellow Rose")); expected.add(new LiteralImpl("Old Yellow House")); @@ -316,11 +318,13 @@ final BindingSet solution = itr.next(); - System.out.println("solution[" + i + "] : " + solution); + if (log.isInfoEnabled()) + log.info("solution[" + i + "] : " + solution); final Value actual = solution.getValue("X"); - System.out.println("X[" + i + "] = " + actual + " (" + if (log.isInfoEnabled()) + log.info("X[" + i + "] = " + actual + " (" + actual.getClass().getName() + ")"); assertTrue("Not expecting X=" + actual, expected @@ -364,6 +368,15 @@ final URI ENTITY = new URIImpl("http://bigdata.com/system#Entity"); + final String query = "construct {"+// + "?s <" + RDF.TYPE + "> <" + ENTITY + "> ."+// + " } " + "where { "+// + " ?s <" + RDF.TYPE + "> <" + ENTITY + "> ."+// + " ?s ?p ?lit ."+// + " ?lit <" + BD.SEARCH + "> \"systap\" ."+// + " ?lit <" + BD.MIN_RELEVANCE + "> \"0.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."+// + " }"; + // the ontology (nothing is indexed for full text search). final Graph test_restart_1 = new GraphImpl(); { @@ -446,10 +459,6 @@ } { // run the query (free text search) - final String query = "construct { ?s <" + RDF.TYPE + "> <" - + ENTITY + "> . } " + "where { ?s <" + RDF.TYPE - + "> <" + ENTITY + "> . ?s ?p ?lit . ?lit <" - + BD.SEARCH + "> \"systap\" . }"; final RepositoryConnection cxn = repo.getConnection(); try { // silly construct queries, can't guarantee distinct @@ -459,13 +468,9 @@ QueryLanguage.SPARQL, query); graphQuery.evaluate(new StatementCollector(results)); for (Statement stmt : results) { - log.info(stmt); + if(log.isInfoEnabled()) + log.info(stmt); } - /* - * @todo this test is failing : review with MikeP and - * figure out if it is the test or the system under - * test. - */ assertTrue(results.contains(new StatementImpl(SYSTAP, RDF.TYPE, ENTITY))); } finally { @@ -489,10 +494,10 @@ repo.initialize(); { // run the query again - final String query = "construct { ?s <" + RDF.TYPE + "> <" - + ENTITY + "> . } " + "where { ?s <" + RDF.TYPE - + "> <" + ENTITY + "> . ?s ?p ?lit . ?lit <" - + BD.SEARCH + "> \"systap\" . }"; +// final String query = "construct { ?s <" + RDF.TYPE + "> <" +// + ENTITY + "> . } " + "where { ?s <" + RDF.TYPE +// + "> <" + ENTITY + "> . ?s ?p ?lit . ?lit <" +// + BD.SEARCH + "> \"systap\" . }"; final RepositoryConnection cxn = repo.getConnection(); try { // silly construct queries, can't guarantee distinct @@ -502,7 +507,8 @@ QueryLanguage.SPARQL, query); graphQuery.evaluate(new StatementCollector(results)); for (Statement stmt : results) { - log.info(stmt); + if(log.isInfoEnabled()) + log.info(stmt); } assertTrue("Lost commit?", results .contains(new StatementImpl(SYSTAP, RDF.TYPE, @@ -782,9 +788,10 @@ int i = 0; while (result.hasNext()) { - System.err.println(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results", i == 7); + assertEquals("wrong # of results", 7, i); result = tupleQuery.evaluate(); @@ -795,12 +802,12 @@ final Hiterator<IHit> hits = search.search(searchQuery, null, // languageCode - false, // prefixMatch - 0d, // minCosine - 1.0d, // maxCosine - 10000, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_PREFIX_MATCH,//false, // prefixMatch + BD.DEFAULT_MIN_RELEVANCE,//0d, // minCosine + BD.DEFAULT_MAX_RELEVANCE,//1.0d, // maxCosine + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -814,7 +821,8 @@ new BindingImpl("s", s), new BindingImpl("o", o), new BindingImpl("score", score)); - System.err.println(bs); + if(log.isInfoEnabled()) + log.info(bs); answer.add(bs); } @@ -845,9 +853,10 @@ int i = 0; while (result.hasNext()) { - System.err.println(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results", i == 5); + assertEquals("wrong # of results", 5, i); result = tupleQuery.evaluate(); @@ -858,12 +867,12 @@ final Hiterator<IHit> hits = search.search(searchQuery, null, // languageCode - false, // prefixMatch - 0d, // minCosine - 1.0d, // maxCosine + BD.DEFAULT_PREFIX_MATCH,//false, // prefixMatch + BD.DEFAULT_MIN_RELEVANCE,//0d, // minCosine + BD.DEFAULT_MAX_RELEVANCE,//1.0d, // maxCosine maxHits+1, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -877,7 +886,8 @@ new BindingImpl("s", s), new BindingImpl("o", o), new BindingImpl("score", score)); - System.err.println(bs); + if(log.isInfoEnabled()) + log.info(bs); answer.add(bs); } @@ -910,9 +920,10 @@ int i = 0; while (result.hasNext()) { - System.err.println(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results", i == 2); + assertEquals("wrong # of results", 2, i); result = tupleQuery.evaluate(); @@ -923,12 +934,12 @@ final Hiterator<IHit> hits = search.search(searchQuery, null, // languageCode - false, // prefixMatch + BD.DEFAULT_PREFIX_MATCH,//false, // prefixMatch minRelevance, // minCosine maxRelevance, // maxCosine - 10000, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -942,7 +953,8 @@ new BindingImpl("s", s), new BindingImpl("o", o), new BindingImpl("score", score)); - System.err.println(bs); + if(log.isInfoEnabled()) + log.info(bs); answer.add(bs); } @@ -969,7 +981,8 @@ "} " + "order by desc(?score)"; - log.info("\n"+query); + if(log.isInfoEnabled()) + log.info("\n"+query); final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); @@ -978,9 +991,10 @@ int i = 0; while (result.hasNext()) { - log.info(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results: " + i, i == 2); + assertEquals("wrong # of results: " + i, 2, i); result = tupleQuery.evaluate(); @@ -991,12 +1005,12 @@ final Hiterator<IHit> hits = search.search(searchQuery, null, // languageCode - false, // prefixMatch + BD.DEFAULT_PREFIX_MATCH,//false, // prefixMatch minRelevance, // minCosine maxRelevance, // maxCosine - 10000, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -1039,7 +1053,8 @@ "} " + "order by desc(?score)"; - log.info("\n"+query); + if(log.isInfoEnabled()) + log.info("\n"+query); final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); @@ -1048,9 +1063,10 @@ int i = 0; while (result.hasNext()) { - log.info(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results: " + i, i == 3); + assertEquals("wrong # of results: " + i, 3, i); result = tupleQuery.evaluate(); @@ -1064,9 +1080,9 @@ true, // prefixMatch minRelevance, // minCosine maxRelevance, // maxCosine - 10000, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -1092,7 +1108,7 @@ final String searchQuery = "to*"; final double minRelevance = 0.0d; - final double maxRelevance = 1.0d; + final double maxRelevance = BD.DEFAULT_MAX_RELEVANCE;//1.0d; final String query = "select ?s ?o ?score " + @@ -1101,13 +1117,14 @@ " ?s <"+RDFS.LABEL+"> ?o . " + " ?o <"+BD.SEARCH+"> \""+searchQuery+"\" . " + " ?o <"+BD.RELEVANCE+"> ?score . " + -// " ?o <"+BD.MIN_RELEVANCE+"> \""+minRelevance+"\" . " + + " ?o <"+BD.MIN_RELEVANCE+"> \""+minRelevance+"\" . " + // " ?o <"+BD.MAX_HITS+"> \"5\" . " + // " filter regex(?o, \""+searchQuery+"\") " + "} " + "order by desc(?score)"; - log.info("\n"+query); + if(log.isInfoEnabled()) + log.info("\n"+query); final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); @@ -1116,9 +1133,10 @@ int i = 0; while (result.hasNext()) { - log.info(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } - assertTrue("wrong # of results: " + i, i == 1); + assertEquals("wrong # of results: " + i, 1, i); result = tupleQuery.evaluate(); @@ -1132,9 +1150,9 @@ true, // prefixMatch minRelevance, // minCosine maxRelevance, // maxCosine - 10000, // maxRank (=maxResults + 1) - false, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MATCH_ALL_TERMS,//false, // matchAllTerms + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); @@ -1180,7 +1198,8 @@ int i = 0; while (result.hasNext()) { - log.info(i++ + ": " + result.next().toString()); + if(log.isInfoEnabled()) + log.info(i++ + ": " + result.next().toString()); } // assertTrue("wrong # of results: " + i, i == 1); @@ -1196,9 +1215,9 @@ true, // prefixMatch minRelevance, // minCosine maxRelevance, // maxCosine - 10000, // maxRank (=maxResults + 1) + BD.DEFAULT_MAX_HITS,//10000, // maxRank (=maxResults + 1) true, // matchAllTerms - 1000L, // timeout + BD.DEFAULT_TIMEOUT,//1000L, // timeout TimeUnit.MILLISECONDS // unit ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |