本文整理汇总了Java中org.apache.uima.resource.ResourceInitializationException类的典型用法代码示例。如果您正苦于以下问题:Java ResourceInitializationException类的具体用法?Java ResourceInitializationException怎么用?Java ResourceInitializationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceInitializationException类属于org.apache.uima.resource包,在下文中一共展示了ResourceInitializationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
// instantiate and add feature extractors
if (featureExtractionFile == null) {
try {
featureExtractors = FeatureExtractorFactory.createAllFeatureExtractors();
} catch (IOException e) {
e.printStackTrace();
}
} else {
// load the settings from a file
// initialize the XStream if a xml file is given:
XStream xstream = XStreamFactory.createXStream();
featureExtractors = (List<FeatureExtractor1<Token>>) xstream.fromXML(new File(featureExtractionFile));
}
}
示例2: classifyTestFile
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
public static void classifyTestFile(String modelDirectory, File testPosFile, String language)
throws ResourceInitializationException, UIMAException, IOException {
CollectionReader testPosFileReader = FilesCollectionReader.getCollectionReaderWithSuffixes(testPosFile.getAbsolutePath(),
NERReader.CONLL_VIEW, testPosFile.getName());
AnalysisEngine nerReader = createEngine(NERReader.class);
AnalysisEngine snowballStemmer = createEngine(SnowballStemmer.class, SnowballStemmer.PARAM_LANGUAGE, language);
AnalysisEngine nerAnnotator = createEngine(NERAnnotator.class,
NERAnnotator.PARAM_FEATURE_EXTRACTION_FILE, "src/main/resources/feature/features.xml",
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, modelDirectory + "model.jar");
AnalysisEngine nerWriter = createEngine(NERWriter.class,
NERWriter.PARAM_NULL_TYPE, "O",
NERWriter.PARAM_EXPECTED_ENTITY_TYPE_NUM, 9,
NERWriter.PARAM_FILENAME, "src/test/resources/evaluation/eval.txt",
NERWriter.PARAM_VERBOSE, true);
runPipeline(
testPosFileReader,
nerReader,
snowballStemmer,
nerAnnotator,
nerWriter);
}
示例3: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
throws ResourceInitializationException
{
super.initialize(context);
try {
tarArchiveInputStream = new TarArchiveInputStream(
new GZIPInputStream(new FileInputStream(sourceLocation)));
fastForwardToNextValidEntry();
}
catch (IOException ex) {
throw new ResourceInitializationException(ex);
}
}
示例4: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext aContext)
throws ResourceInitializationException
{
super.initialize(aContext);
// some param check
if (!outputFile.getName().endsWith(".tar.gz")) {
throw new ResourceInitializationException(
new IllegalArgumentException("Output file must have .tar.gz extension"));
}
typeSystemWritten = false;
try {
outputStream = new TarArchiveOutputStream(new GzipCompressorOutputStream(
new BufferedOutputStream(new FileOutputStream(outputFile))));
}
catch (IOException ex) {
throw new ResourceInitializationException(ex);
}
}
示例5: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
throws ResourceInitializationException
{
super.initialize(context);
try {
out = new PrintWriter(
new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"));
// print header
printHeader(out);
}
catch (IOException e) {
throw new ResourceInitializationException(e);
}
}
示例6: getPipeline
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
/**
* Creates a tokenizing pipeline
*
* @throws IOException exception
*/
private static AnalysisEngineDescription getPipeline()
throws IOException
{
if (pipelineSingleton == null) {
try {
pipelineSingleton = AnalysisEngineFactory.createEngineDescription(
AnalysisEngineFactory.createEngineDescription(ParagraphSplitter.class,
ParagraphSplitter.PARAM_SPLIT_PATTERN,
ParagraphSplitter.SINGLE_LINE_BREAKS_PATTERN),
AnalysisEngineFactory.createEngineDescription(ArkTweetTokenizerFixed.class),
AnalysisEngineFactory.createEngineDescription(StanfordSegmenter.class,
StanfordSegmenter.PARAM_WRITE_TOKEN, false,
StanfordSegmenter.PARAM_ZONE_TYPES,
Paragraph.class.getCanonicalName()));
}
catch (ResourceInitializationException e) {
throw new IOException();
}
}
return pipelineSingleton;
}
示例7: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
this.tokMap = new HashMap<String, PToken>();
this.components = new ArrayList<CmmComponent>(this.componentNames.length);
for (String componentName : this.componentNames) {
if (componentName != null) {
Class<?> classDefinition;
CmmComponent component = null;
try {
classDefinition = Class.forName(componentName);
component = (CmmComponent) classDefinition.newInstance();
component.setParent(this);
} catch (Exception e) {
e.printStackTrace();
}
this.components.add(component);
}
}
this.log("initialized");
}
示例8: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
this.tokMap = new HashMap<String, PToken>();
this.components = new ArrayList<CmmComponent>(this.componentNames.length);
for (String componentName : this.componentNames) {
if (componentName != null) {
Class<?> classDefinition;
CmmComponent component = null;
try {
classDefinition = Class.forName(componentPackage + componentName);
component = (CmmComponent) classDefinition.newInstance();
component.setParent(this);
} catch (Exception e) {
e.printStackTrace();
}
this.components.add(component);
}
}
this.log("initialized");
}
示例9: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String featureConstructorName = UimaContextHelper.getConfigParameterStringValue(context,
"feature-constructor");
featureConstructor = ProviderCache.getProvider(featureConstructorName,
FeatureConstructorProvider.class);
String classifierName = UimaContextHelper.getConfigParameterStringValue(context, "classifier");
classifier = ProviderCache.getProvider(classifierName, ClassifierProvider.class);
String predictFilename = UimaContextHelper.getConfigParameterStringValue(context,
"predict-file", null);
limit = UimaContextHelper.getConfigParameterIntValue(context, "limit", 1);
if (predictFilename != null) {
try {
predictFileWriter = Files.newWriter(new File(predictFilename), Charsets.UTF_8);
} catch (FileNotFoundException e) {
throw new ResourceInitializationException(e);
}
}
}
示例10: testInlinePrinter_SimpleCase
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
/**
* Tests the InlinePrinter using a very simple case of two annotations (no overlaps) within the
* document text.
*
* @throws ResourceInitializationException
* if an error occurs during {@link AnalysisEngine} initialization
* @throws IOException
* @throws AnalysisEngineProcessException
*/
@Test
public void testInlinePrinter_SimpleCase() throws ResourceInitializationException, IOException,
AnalysisEngineProcessException {
addSimpleSampleAnnotations();
String expectedOutput = String
.format("The <%s>cow</%s> jumped over the <%s>moon</%s> & the nai\u0308ve stars, but the cd2 and cd5 receptors were not blocked.",
ANIMAL_CLASS, ANIMAL_CLASS, CELESTIAL_BODY_CLASS, CELESTIAL_BODY_CLASS);
AnalysisEngine inlinePrinterAe = InlinePrinter.createAnalysisEngine(TSD, outputDirectory,
CAS.NAME_DEFAULT_SOFA, CcpDocumentMetadataHandler.class, SimpleInlineAnnotationExtractor.class);
inlinePrinterAe.process(jcas);
File expectedOutputFile = new File(outputDirectory, SAMPLE_DOCUMENT_ID + InlinePrinter.OUTPUT_FILE_SUFFIX);
assertTrue("output file should exist", expectedOutputFile.exists());
String inlinedAnnotationOutput = FileUtil.copyToString(expectedOutputFile, SAMPLE_DOCUMENT_ENCODING);
assertEquals(String.format("Inlined output should be as expected"), expectedOutput, inlinedAnnotationOutput);
}
示例11: getEngineDescription
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
public static AnalysisEngineDescription getEngineDescription(String genderModelUrl)
throws ResourceInitializationException {
String tmpView = "tmp:Dramatis Personae";
AggregateBuilder b = new AggregateBuilder();
b.add(AnalysisEngineFactory.createEngineDescription(PrepareClearTk.class, PrepareClearTk.PARAM_VIEW_NAME,
tmpView, PrepareClearTk.PARAM_ANNOTATION_TYPE, DramatisPersonae.class,
PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class, FigureType.class)));
b.add(AnalysisEngineFactory.createEngineDescription(BreakIteratorSegmenter.class,
BreakIteratorSegmenter.PARAM_WRITE_SENTENCE, false), CAS.NAME_DEFAULT_SOFA, tmpView);
b.add(AnalysisEngineFactory.createEngineDescription(ClearTkGenderAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, genderModelUrl), CAS.NAME_DEFAULT_SOFA, tmpView);
b.add(AnalysisEngineFactory.createEngineDescription(MapBackFeature.class, MapBackFeature.PARAM_ANNOTATION_TYPE,
Figure.class, MapBackFeature.PARAM_VIEW_NAME, tmpView, MapBackFeature.PARAM_FEATURE_NAME, "Gender"));
return b.createAggregateDescription();
}
示例12: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
throws ResourceInitializationException {
super.initialize(aSpecifier, aAdditionalParams);
hits = Integer.class.cast(getParameterValue("hits"));
// query constructor
String stoplistPath = String.class.cast(getParameterValue("stoplist-path"));
try {
stoplist = Resources.readLines(getClass().getResource(stoplistPath), UTF_8).stream()
.map(String::trim).collect(toSet());
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
analyzer = new StandardAnalyzer();
parser = new QueryParser("text", analyzer);
return true;
}
示例13: getPreprocessing
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
/**
* Gets the current pre-processing set up
* @return Pre-processing pipeline
* @throws ResourceInitializationException
* for erroneous configurations
*/
public AnalysisEngineDescription getPreprocessing()
throws ResourceInitializationException
{
List<AnalysisEngineDescription> preprocessing = new ArrayList<>();
if (userPreprocessing != null) {
preprocessing.addAll(Arrays.asList(userPreprocessing));
}
preprocessing.add(AnalysisEngineFactory.createEngineDescription(TcPosTaggingWrapper.class,
TcPosTaggingWrapper.PARAM_USE_COARSE_GRAINED, useCoarse));
return AnalysisEngineFactory
.createEngineDescription(preprocessing.toArray(new AnalysisEngineDescription[0]));
}
示例14: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String param = UimaContextHelper.getConfigParameterStringValue(context, "weights-path");
weights = new HashMap<>();
try (BufferedReader bw = new BufferedReader(
new InputStreamReader(getClass().getResourceAsStream(param)))) {
String line;
while ((line = bw.readLine()) != null) {
String[] segs = line.split("\t");
weights.put(segs[0],
new double[] { Double.parseDouble(segs[1]), Double.parseDouble(segs[2]) });
}
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
}
示例15: initialize
import org.apache.uima.resource.ResourceInitializationException; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException{
AnalysisEngineDescription aggregate = createEngineDescription(
// At this point the lemmatizer and segment should have been called
createEngineDescription(ClearNlpDependencyParser.class,
ClearNlpDependencyParser.PARAM_VARIANT,
"mayo")
,createEngineDescription(ClearNlpSemanticRoleLabeler.class,
ClearNlpSemanticRoleLabeler.PARAM_VARIANT,
"mayo")
);
mEngine = createEngine(aggregate);
long threadId = Thread.currentThread().getId();
logger.info(String.format("Created an engine, thread # %d",threadId));
}