Search in sources :

Example 1 with NLP_PARALLELISM_OPT

use of org.icij.datashare.cli.DatashareCliOptions.NLP_PARALLELISM_OPT in project datashare by ICIJ.

the class NlpAppTest method runNlpApp.

private NlpApp runNlpApp(String parallelism, int nlpProcessDelayMillis) throws InterruptedException {
    Properties properties = new Properties();
    properties.setProperty(NLP_PARALLELISM_OPT, parallelism);
    properties.setProperty("messageBusAddress", "redis");
    CountDownLatch latch = new CountDownLatch(1);
    when(pipeline.process(any())).thenAnswer((Answer<List<NamedEntity>>) invocationOnMock -> {
        if (nlpProcessDelayMillis > 0)
            Thread.sleep(nlpProcessDelayMillis);
        return emptyList();
    });
    NlpApp nlpApp = new NlpApp(dataBus, indexer, pipeline, properties, latch::countDown, 1, true, local());
    executor.execute(nlpApp);
    latch.await(2, SECONDS);
    return nlpApp;
}
Also used : IntStream(java.util.stream.IntStream) MockitoAnnotations.initMocks(org.mockito.MockitoAnnotations.initMocks) Mock(org.mockito.Mock) INIT_MONITORING(org.icij.datashare.com.Message.Type.INIT_MONITORING) RunWith(org.junit.runner.RunWith) Matchers.anyString(org.mockito.Matchers.anyString) Answer(org.mockito.stubbing.Answer) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) Parameterized(org.junit.runners.Parameterized) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) NLP_PARALLELISM_OPT(org.icij.datashare.cli.DatashareCliOptions.NLP_PARALLELISM_OPT) Field(org.icij.datashare.com.Message.Field) AbstractPipeline(org.icij.datashare.text.nlp.AbstractPipeline) Properties(java.util.Properties) PropertiesProvider(org.icij.datashare.PropertiesProvider) Collections.emptyList(java.util.Collections.emptyList) EXTRACT_NLP(org.icij.datashare.com.Message.Type.EXTRACT_NLP) DocumentBuilder.createDoc(org.icij.datashare.text.DocumentBuilder.createDoc) org.icij.datashare.com(org.icij.datashare.com) Collection(java.util.Collection) Indexer(org.icij.datashare.text.indexing.Indexer) Test(org.junit.Test) OPENNLP(org.icij.datashare.text.nlp.Pipeline.Type.OPENNLP) Executors(java.util.concurrent.Executors) User.local(org.icij.datashare.user.User.local) Matchers.any(org.mockito.Matchers.any) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito(org.mockito.Mockito) List(java.util.List) Language(org.icij.datashare.text.Language) SECONDS(java.util.concurrent.TimeUnit.SECONDS) NamedEntity(org.icij.datashare.text.NamedEntity) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Properties(java.util.Properties) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Properties (java.util.Properties)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 SECONDS (java.util.concurrent.TimeUnit.SECONDS)1 IntStream (java.util.stream.IntStream)1 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)1 PropertiesProvider (org.icij.datashare.PropertiesProvider)1 NLP_PARALLELISM_OPT (org.icij.datashare.cli.DatashareCliOptions.NLP_PARALLELISM_OPT)1 org.icij.datashare.com (org.icij.datashare.com)1 Field (org.icij.datashare.com.Message.Field)1 EXTRACT_NLP (org.icij.datashare.com.Message.Type.EXTRACT_NLP)1 INIT_MONITORING (org.icij.datashare.com.Message.Type.INIT_MONITORING)1 DocumentBuilder.createDoc (org.icij.datashare.text.DocumentBuilder.createDoc)1 Language (org.icij.datashare.text.Language)1 NamedEntity (org.icij.datashare.text.NamedEntity)1