/** * Constructs a new Index object. Don't call this method, * call the createIndex(String, String) factory method to * construct an Index object. */ public static IndexOnDisk createIndex() { return createIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX); }
/** * Constructs a new Index object. Don't call this method, * call the createIndex(String, String) factory method to * construct an Index object. */ public static IndexOnDisk createIndex() { return createIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX); }
/** * main * * @param args */ public static void main(String[] args) { Index index = Index.createIndex(); System.out.println("Index " + index.toString()); }
/** * main * * @param args */ public static void main(String[] args) { Index index = Index.createIndex(); System.out.println("Index " + index.toString()); }
protected void checkIndex() throws Exception { Index i = Index.createIndex(); for(BatchEndToEndTestEventHooks hook : testHooks) { hook.checkIndex(this, i); } }
@Override public int run(String[] args) { try{ IndexOnDisk.setIndexLoadingProfileAsRetrieval(false); IndexOnDisk index = Index.createIndex(); recompressInverted(index); index.close(); }catch (Exception e) { throw new RuntimeException(e); } return 0; }
@Override public int run(String[] args) { try{ IndexOnDisk.setIndexLoadingProfileAsRetrieval(false); IndexOnDisk index = Index.createIndex(); recompressInverted(index); index.close(); }catch (Exception e) { throw new RuntimeException(e); } return 0; }
/** Reopen an existing index */ public static IndexOnDisk reOpenIndex(IndexOnDisk index) throws IOException { IndexOnDisk rtr = null; String path = index.getPath(); String prefix = index.getPrefix(); index.close(); rtr = Index.createIndex(path, prefix); return rtr; }
/** * main * @param args */ public static void main(String[]args) { Index.setIndexLoadingProfileAsRetrieval(false); Index index = Index.createIndex(); if (index == null) { System.err.println("No such index"); return; } DFRDependenceScoreModifier d = new DFRDependenceScoreModifier(); d.setCollectionStatistics(index.getCollectionStatistics(), index); System.out.println(d.scoreFDSD(Integer.parseInt(args[0]), Integer.parseInt(args[1]))); }
/** * main * @param args */ public static void main(String[]args) { Index.setIndexLoadingProfileAsRetrieval(false); Index index = Index.createIndex(); if (index == null) { System.err.println("No such index"); return; } DFRDependenceScoreModifier d = new DFRDependenceScoreModifier(); d.setCollectionStatistics(index.getCollectionStatistics(), index); System.out.println(d.scoreFDSD(Integer.parseInt(args[0]), Integer.parseInt(args[1]))); }
/** Reopen an existing index */ public static IndexOnDisk reOpenIndex(IndexOnDisk index) throws IOException { IndexOnDisk rtr = null; String path = index.getPath(); String prefix = index.getPrefix(); index.close(); rtr = Index.createIndex(path, prefix); return rtr; }
@Test public void test() throws Exception { PrintWriter p = new PrintWriter(Files.writeFileWriter(ApplicationSetup.COLLECTION_SPEC)); p.println(System.getProperty("user.dir") + "/../../share/tests/shakespeare/shakespeare-merchant.trec.1"); p.println(System.getProperty("user.dir") + "/../../share/tests/shakespeare/shakespeare-merchant.trec.2"); p.close(); CLITool.main(new String[]{"batchindexing", "-b"}); Index index = Index.createIndex(); assertNotNull(index); assertEquals(22, index.getCollectionStatistics().getNumberOfDocuments()); assertTrue( index.getDirectIndex().getPostings(index.getDocumentIndex().getDocumentEntry(0)) instanceof BlockPosting ); }
@Test public void testParallel() throws Exception { PrintWriter p = new PrintWriter(Files.writeFileWriter(ApplicationSetup.COLLECTION_SPEC)); p.println(System.getProperty("user.dir") + "/../../share/tests/shakespeare/shakespeare-merchant.trec.1"); p.println(System.getProperty("user.dir") + "/../../share/tests/shakespeare/shakespeare-merchant.trec.2"); p.close(); CLITool.main(new String[]{"batchindexing", "-b", "-p"}); Index index = Index.createIndex(); assertNotNull(index); assertEquals(22, index.getCollectionStatistics().getNumberOfDocuments()); assertTrue( index.getDirectIndex().getPostings(index.getDocumentIndex().getDocumentEntry(0)) instanceof BlockPosting ); }
public static Index makeIndex(String[] docnos, String[] documents, Indexer indexer) throws Exception { assertEquals(docnos.length, documents.length); Document[] sourceDocs = new Document[docnos.length]; for(int i=0;i<docnos.length;i++) { Map<String,String> docProperties = new HashMap<String,String>(); docProperties.put("filename", docnos[i]); sourceDocs[i] = new FileDocument(new ByteArrayInputStream(documents[i].getBytes()), docProperties, new EnglishTokeniser()); } Collection col = new CollectionDocumentList(sourceDocs, "filename"); indexer.index(new Collection[]{col}); Index index = Index.createIndex(); assertEquals(sourceDocs.length, index.getCollectionStatistics().getNumberOfDocuments()); return index; }
@Test public void test_todisk() throws Exception { MemoryIndex mem = TestUtils.memory(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); assertNotNull(mem2disk); }
@Test public void test_todisk() throws Exception { MemoryFieldsIndex mem = TestUtils.memoryFields(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); assertNotNull(mem2disk); }
@Test public void test_compare2() throws Exception { MemoryIndex mem = TestUtils.memory(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); assertNotNull(mem2disk); TestUtils.compareIndices(mem, mem2disk); TestUtils.compareProperties(mem, mem2disk); TestUtils.compareRetrieval("curry", mem, mem2disk); TestUtils.compareRetrieval("church", mem, mem2disk); TestUtils.compareRetrieval("knuth", mem, mem2disk); TestUtils.compareRetrieval("turing", mem, mem2disk); }
@Test public void test_compare2() throws Exception { MemoryFieldsIndex mem = TestUtils.memoryFields(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); assertNotNull(mem2disk); TestUtils.compareIndices(mem, mem2disk); TestUtils.compareProperties(mem, mem2disk); TestUtils.compareRetrieval("curry", mem, mem2disk); TestUtils.compareRetrieval("church", mem, mem2disk); TestUtils.compareRetrieval("knuth", mem, mem2disk); TestUtils.compareRetrieval("turing", mem, mem2disk); }
@Test public void test_compare3() throws Exception { MemoryIndex mem = TestUtils.memory(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memory"); assertNotNull(mem2disk); Index disk = IndexTestUtils.makeIndex(docids, documents); assertNotNull(disk); TestUtils.compareIndices(disk, mem2disk); TestUtils.compareProperties(disk, mem2disk); TestUtils.compareRetrieval("curry", disk, mem2disk); TestUtils.compareRetrieval("church", disk, mem2disk); TestUtils.compareRetrieval("knuth", disk, mem2disk); TestUtils.compareRetrieval("turing", disk, mem2disk); }
@Test public void test_compare3() throws Exception { MemoryFieldsIndex mem = TestUtils.memoryFields(collection); assertNotNull(mem); mem.write(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); Index mem2disk = Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "memoryFields"); assertNotNull(mem2disk); Index disk = IndexTestUtils.makeIndex(docids, documents); assertNotNull(disk); TestUtils.compareIndices(disk, mem2disk); TestUtils.compareProperties(disk, mem2disk); TestUtils.compareRetrieval("curry", disk, mem2disk); TestUtils.compareRetrieval("church", disk, mem2disk); TestUtils.compareRetrieval("knuth", disk, mem2disk); TestUtils.compareRetrieval("turing", disk, mem2disk); }