The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Olaven (2) [Avatar] Offline
Hi, I've tried to figure out why I can't run the Precision Recall example in Appendix C for some time.

The execution stops at the line:

"QualityStats stats[] = qrun.execute(judge, submitLog, logger);"

And produces the stacktrace:

"Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(
at org.apache.lucene.benchmark.quality.QualityStats.fracFormat(
at org.apache.lucene.benchmark.quality.QualityStats.log(
at org.apache.lucene.benchmark.quality.QualityBenchmark.analyzeQueryResults(
at org.apache.lucene.benchmark.quality.QualityBenchmark.execute(
at PrecisionRecall.main("

Obviously some parameter is wrong/null, but I'm not able to find anything wrong with either the judge, submitLog or logger..

regards - Olav
mike.mccandless (221) [Avatar] Offline
Re: Precision/Recall - Appendix C
Hmm, how are you running the test? Are you using the sample files that came with the book? (Ie, "ant PrecisionRecall"). Or your own topics/qrels?

This exception looks like a silly bug, regardless -- that code is looking for the '.' in a String (that's supposed to be a float, eg 17.42), but the '.' is apparently not there...

Olaven (2) [Avatar] Offline
Re: Precision/Recall - Appendix C
I'm just running the test using "ant Precision" and haven't altered anything in either the source code or the folder structure compared to the download available at this site. The exception is still there regardless of what I try:

0 - contents:apache contents:source

0 Stats:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(
at uib.percisionRecall.QualityStats.fracFormat(
at uib.percisionRecall.QualityStats.log(
at uib.percisionRecall.QualityBenchmark.analyzeQueryResults(
at uib.percisionRecall.QualityBenchmark.execute(
at uib.percisionRecall.PrecisionRecall.main(
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)"

After sifting through the API / source of the benchmark package it looks like there is no output from the query since the execution stops at this formatting method:

"private String fracFormat(String frac) {
int k = frac.indexOf('.');
String s1 = padd+frac.substring(0,k);

int n = Math.max(k,6);
s1 = s1.substring(s1.length()-n);
return s1 + frac.substring(k);

It looks to me like as you mentioned that the method never gets to this output where it looks for '.' in the float:

Search Seconds: 0.015
DocName Seconds: 0.006
Num Points: 15.000
Num Good Points: 3.000

Right now I'm somewhat at a loss - having checked most possibilities I wonder if there are any tests or somthing to check that all elements are present when the QualityBenchmark.execute() method executes.

regards - Olav