package org.voyanttools.trombone.tool; import java.io.IOException; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.TextField; import org.junit.Test; import org.voyanttools.trombone.lucene.LuceneManager; import org.voyanttools.trombone.storage.Storage; import org.voyanttools.trombone.storage.memory.MemoryStorage; import org.voyanttools.trombone.tool.corpus.CorpusCreator; import org.voyanttools.trombone.tool.corpus.DocumentContexts; import org.voyanttools.trombone.util.FlexibleParameters; public class KwicsTest { @Test public void test() throws IOException { Storage storage = new MemoryStorage(); Document document; LuceneManager luceneManager = storage.getLuceneManager(); document = new Document(); document.add(new TextField("lexical", "dark and stormy night in document one", Field.Store.YES)); luceneManager.addDocument(document); FlexibleParameters parameters; parameters = new FlexibleParameters(); parameters.addParameter("string", "It was a dark and stormy night."); parameters.addParameter("string", "It was the best of times it was the worst of times."); parameters.addParameter("tool", "StepEnabledIndexedCorpusCreator"); CorpusCreator creator = new CorpusCreator(storage, parameters); creator.run(); parameters.setParameter("corpus", creator.getStoredId()); DocumentContexts kwics; parameters.setParameter("tool", "Kwics"); parameters.setParameter("query", "it was"); kwics = new DocumentContexts(storage, parameters); kwics.run(); } }