Beispiel #1
0
  public void testSearch() throws IOException {
    int docNumber = 1;
    MetricSpacesInvertedListIndexing ms = MetricSpacesInvertedListIndexing.getDefaultInstance();
    MetricSpacesInvertedListIndexing.numReferenceObjectsUsed = 10;
    MetricSpacesInvertedListIndexing.numReferenceObjects = 50;
    IndexReader reader = ms.getIndexReader(indexPath);
    TopDocs docs = ms.search(reader.document(docNumber), indexPath);

    // print the results
    BufferedWriter bw = new BufferedWriter(new FileWriter("out.html"));
    bw.write("<html><body>");
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc scoreDoc = docs.scoreDocs[i];
      bw.write(
          "<img title=\"ID: "
              + scoreDoc.doc
              + ", "
              + "Score: "
              + scoreDoc.score
              + "\" src=\"file:///"
              + reader.document(scoreDoc.doc).getValues("descriptorImageIdentifier")[0]
              + "\"> ");
    }
    bw.write("</body></html>");
    bw.close();
    showUrl("out.html");
  }
Beispiel #2
0
  public void testMetrics() throws IOException {
    String smallIdx = "wang-cedd";
    MetricSpacesInvertedListIndexing ms = MetricSpacesInvertedListIndexing.getDefaultInstance();
    MetricSpacesInvertedListIndexing.numReferenceObjectsUsed = 10;
    MetricSpacesInvertedListIndexing.numReferenceObjects = 50;

    TopDocs docs = ms.search(ImageIO.read(new FileInputStream("wang-data-1000/10.jpg")), smallIdx);
    IndexReader ir = IndexReader.open(FSDirectory.open(new File(smallIdx)));
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc scoreDoc = docs.scoreDocs[i];
      String identifier =
          ir.document(scoreDoc.doc).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0];
      System.out.println(scoreDoc.score + ": " + identifier + " \t(" + scoreDoc.doc + ")");
    }
  }
Beispiel #3
0
  public void testIndexing() throws IOException {
    MetricSpacesInvertedListIndexing ms = MetricSpacesInvertedListIndexing.getDefaultInstance();
    MetricSpacesInvertedListIndexing.numReferenceObjectsUsed = 10;
    MetricSpacesInvertedListIndexing.numReferenceObjects = 50;
    ms.setProgress(
        new ProgressIndicator() {
          @Override
          public void setCurrentState(MetricSpacesInvertedListIndexing.State currentState) {
            super.setCurrentState(currentState);
            System.out.println("currentState = " + currentState);
          }

          @Override
          public void setNumDocsProcessed(int numDocsProcessed) {
            super.setNumDocsProcessed(numDocsProcessed);
            if (numDocsProcessed % 100 == 0)
              System.out.println("numDocsProcessed = " + numDocsProcessed);
          }
        });
    ms.createIndex(indexPath);
  }
Beispiel #4
0
  public void testPerformance() throws IOException {
    MetricSpacesInvertedListIndexing mes = MetricSpacesInvertedListIndexing.getDefaultInstance();
    int numSearches = 10;
    IndexReader reader = mes.getIndexReader(indexPath);
    System.out.println(reader.maxDoc() + " documents");
    TopDocs docs;

    long ms = System.currentTimeMillis();
    for (int i = 0; i < numSearches; i++) {
      docs = mes.search(reader.document(i), indexPath);
    }
    ms = System.currentTimeMillis() - ms;
    System.out.println("ms = " + ms);

    ImageSearcher ceddSearcher = ImageSearcherFactory.createCEDDImageSearcher(100);
    ms = System.currentTimeMillis();
    for (int i = 0; i < numSearches; i++) {
      ceddSearcher.search(reader.document(i), reader);
    }
    ms = System.currentTimeMillis() - ms;
    System.out.println("ms = " + ms);
  }