All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.it.unimi.di.archive4j.tool.DirectScanTest Maven / Gradle / Ivy

Go to download

Archive4J is a suite of tools to store compactly term/count information of a document collection.

There is a newer version: 1.3.3
Show newest version
package it.unimi.di.archive4j.tool;

/*		 
 * Copyright (C) 2008-2013 Alessio Orlandi and Sebastiano Vigna 
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */


import it.unimi.di.archive4j.ArchiveLoader;
import it.unimi.di.archive4j.ArrayDocumentSummary;
import it.unimi.di.archive4j.SequentialBitstreamArchive;
import it.unimi.di.archive4j.tool.ArchiveBuilder;
import junit.framework.TestCase;
import it.unimi.di.archive4j.TestCollection;




public class DirectScanTest extends TestCase {

	protected String seqname;

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		seqname = TestCollection.buildDocumentSequence( TestCollection.testParseDocSources );
	}

	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testSingle() throws Exception {
		ArchiveBuilder.main( ("-I text -S " + seqname + " " + seqname + "-archive" ).split( " " ) );

		final SequentialBitstreamArchive archive = (SequentialBitstreamArchive)ArchiveLoader.getInstance( seqname + "-archive" );

		assertEquals( TestCollection.testParse.length, archive.numberOfDocuments() );
		assertEquals( TestCollection.testTerms.length, archive.numberOfTerms() );

		int i = 0;
		for ( ArrayDocumentSummary summary : archive ) {
			assertEquals( Integer.toString( i ), TestCollection.testParse[ i++ ], summary );
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy