Skip to content

Commit

Permalink
Fix for collection readers that don't init cas / type system.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanfinan committed Aug 23, 2024
1 parent 5df171e commit 7370cf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ public AbstractFileTreeReader() {
// Workaround https://github.com/apache/uima-uimaj/issues/234
// https://github.com/ClearTK/cleartk/issues/470
try {
LOGGER.info( "Creating empty CAS to make certain that the typesystem is initialized ..." );
LOGGER.debug( "Creating empty CAS to make certain that the typesystem is initialized ..." );
CasCreationUtils.createCas();
} catch ( ResourceInitializationException riE ) {
LOGGER.error( "Could not create base CAS for initialization.\n" + riE.getMessage() );
LOGGER.error( "Could not create base CAS for initialization.\n{}", riE.getMessage() );
LOGGER.error( Arrays.stream( riE.getStackTrace() )
.map( StackTraceElement::toString )
.collect( Collectors.joining("\n" ) ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import com.lexicalscope.jewel.cli.CliFactory;
import org.apache.ctakes.core.config.ConfigParameterConstants;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.util.CasCreationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.uima.UIMAException;
Expand All @@ -11,6 +13,8 @@
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
* @author SPF , chip-nlp
Expand Down Expand Up @@ -79,6 +83,17 @@ public static boolean run( final String... args ) {
builder.writeHtml( htmlOutDir );
}
}
// Workaround https://github.com/apache/uima-uimaj/issues/234
// https://github.com/ClearTK/cleartk/issues/470
try {
LOGGER.debug( "Creating empty CAS to make certain that the typesystem is initialized ..." );
CasCreationUtils.createCas();
} catch ( ResourceInitializationException riE ) {
LOGGER.error( "Could not create base CAS for initialization.\n{}", riE.getMessage() );
LOGGER.error( Arrays.stream( riE.getStackTrace() )
.map( StackTraceElement::toString )
.collect( Collectors.joining("\n" ) ) );
}
// run the pipeline
builder.run();
} catch ( UIMAException | IOException multE ) {
Expand Down

0 comments on commit 7370cf5

Please sign in to comment.