public void tttestMAPLocalFeatureHistogram() throws IOException { int maxSearches = 200; int maxHits = 100; IndexReader reader = IndexReader.open(FSDirectory.open(new File(indexPath))); IndexSearcher is = new IndexSearcher(reader); ImageSearcher searcher; // searcher = new SiftLocalFeatureHistogramImageSearcher(maxHits); searcher = ImageSearcherFactory.createColorHistogramImageSearcher(maxHits); // searcher = ImageSearcherFactory.createCEDDImageSearcher(maxHits); // searcher = ImageSearcherFactory.createFCTHImageSearcher(maxHits); Pattern p = Pattern.compile("\\\\\\d+\\.jpg"); double map = 0; for (int i = 0; i < sampleQueries.length; i++) { int id = sampleQueries[i]; System.out.print("id = " + id + ": "); String file = testExtensive + "/" + id + ".jpg"; ImageSearchHits hits = searcher.search(findDoc(reader, id + ".jpg"), reader); int goodOnes = 0; double avgPrecision = 0; for (int j = 0; j < hits.length(); j++) { Document d = hits.doc(j); String hitsId = d.getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0]; Matcher matcher = p.matcher(hitsId); if (matcher.find()) hitsId = hitsId.substring(matcher.start() + 1, hitsId.lastIndexOf(".")); else fail("Did not get the number ..."); int testID = Integer.parseInt(hitsId); // System.out.print(". " + hitsId + "/" + // d.getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0]+ " "); if ((int) Math.floor(id / 100) == (int) Math.floor(testID / 100)) { goodOnes++; System.out.print("x"); } else { System.out.print("o"); } // System.out.print(" (" + testID + ") "); avgPrecision += (double) goodOnes / (double) (j + 1); } avgPrecision = avgPrecision / hits.length(); map += avgPrecision; System.out.println(" " + avgPrecision + " (" + map / (i + 1) + ")"); } map = map / sampleQueries.length; System.out.println("map = " + map); }