本文整理汇总了Java中org.apache.uima.UimaContext类的典型用法代码示例。如果您正苦于以下问题:Java UimaContext类的具体用法?Java UimaContext怎么用?Java UimaContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UimaContext类属于org.apache.uima包,在下文中一共展示了UimaContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.uima.UimaContext; //导入依赖的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: initialize
import org.apache.uima.UimaContext; //导入依赖的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);
}
}
示例3: initialize
import org.apache.uima.UimaContext; //导入依赖的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);
}
}
示例4: initialize
import org.apache.uima.UimaContext; //导入依赖的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);
}
}
示例5: initialize
import org.apache.uima.UimaContext; //导入依赖的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");
}
示例6: initialize
import org.apache.uima.UimaContext; //导入依赖的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");
}
示例7: initialize
import org.apache.uima.UimaContext; //导入依赖的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);
}
}
}
示例8: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
model = ModelFactory.createOntologyModel();
InputStream in = null;
try {
in = new FileInputStream(outputFileName);
model.read(in, "http://github.com/quadrama/metadata/ontology.owl");
in.close();
} catch (IOException e) {
Ontology o = model.createOntology("http://github.com/quadrama/metadata/ontology.owl");
o.setRDFType(OWL2.Ontology);
model.setNsPrefix("gndo", "http://d-nb.info/standards/elementset/gnd#");
model.setNsPrefix("gnd", "http://d-nb.info/gnd/");
model.setNsPrefix("dc", "http://purl.org/dc/elements/1.1/");
model.setNsPrefix("oa", "http://www.w3.org/ns/oa#");
model.setNsPrefix("dbo", "http://dbpedia.org/ontology/");
model.setNsPrefix("qd", QD.NS);
} finally {
IOUtils.closeQuietly(in);
}
}
示例9: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String quantityQuestionWordsPath = UimaContextHelper.getConfigParameterStringValue(context,
"quantity-question-words-path");
try {
quantityQuestionPhrases = Resources
.readLines(getClass().getResource(quantityQuestionWordsPath), Charsets.UTF_8).stream()
.map(line -> Arrays.asList(line.split(" "))).collect(toList());
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
atGslabelFile = UimaContextHelper.getConfigParameterStringValue(context, "at-gslabel-file");
batchSize = UimaContextHelper.getConfigParameterIntValue(context, "batch-size", 1);
completeQats = new ArrayList<>();
pendingQats = new ArrayList<>();
}
示例10: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException {
super.initialize(aContext);
String activeMqUrl = (String) aContext.getConfigParameterValue(PARAM_ACTIVE_MQ_URL);
LOGGER.info("Starting connection to ActiveMQ server: {}", activeMqUrl);
String queueName = (String) aContext.getConfigParameterValue(PARAM_ACTIVE_MQ_QUEUE_NAME);
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(
activeMqUrl);
try {
connection = activeMQConnectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(queueName);
messageProducer = session.createProducer(queue);
} catch (JMSException e) {
throw new ResourceInitializationException(e);
}
}
示例11: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String conceptProviderName = UimaContextHelper.getConfigParameterStringValue(context,
"concept-provider");
conceptProvider = ProviderCache.getProvider(conceptProviderName, ConceptProvider.class);
viewNamePrefix = UimaContextHelper.getConfigParameterStringValue(context, "view-name-prefix");
String allowedConceptTypesFile = UimaContextHelper.getConfigParameterStringValue(context,
"allowed-concept-types", null);
try {
allowedConceptTypes = Resources
.readLines(getClass().getResource(allowedConceptTypesFile), Charsets.UTF_8).stream()
.collect(toSet());
checkConceptTypes = true;
} catch (Exception e) {
checkConceptTypes = false;
}
}
示例12: initialize
import org.apache.uima.UimaContext; //导入依赖的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);
}
}
示例13: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
dlinaDirectory = new File(dlinaDirectoryName);
if (!dlinaDirectory.isDirectory())
throw new ResourceInitializationException();
for (File f : dlinaDirectory.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xml");
}
})) {
try {
Builder parser = new Builder();
Document doc = parser.build(new FileInputStream(f));
String sourceUrl = doc.getRootElement().getFirstChildElement("header", namespaceUri)
.getFirstChildElement("source", namespaceUri).getValue();
String sourceId = sourceUrl.substring(56).replace("/data", "");
fileIndex.put(sourceId, doc);
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
}
示例14: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100);
// query constructor
constructor = UimaContextHelper.createObjectFromConfigParameter(context,
"query-string-constructor", "query-string-constructor-params",
BooleanBagOfPhraseQueryStringConstructor.class, QueryStringConstructor.class);
// lucene
Analyzer analyzer = UimaContextHelper.createObjectFromConfigParameter(context, "query-analyzer",
"query-analyzer-params", StandardAnalyzer.class, Analyzer.class);
String[] fields = UimaContextHelper.getConfigParameterStringArrayValue(context, "fields");
parser = new MultiFieldQueryParser(fields, analyzer);
String index = UimaContextHelper.getConfigParameterStringValue(context, "index");
try {
reader = DirectoryReader.open(FSDirectory.open(Paths.get(index)));
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
searcher = new IndexSearcher(reader);
idFieldName = UimaContextHelper.getConfigParameterStringValue(context, "id-field", null);
titleFieldName = UimaContextHelper.getConfigParameterStringValue(context, "title-field", null);
textFieldName = UimaContextHelper.getConfigParameterStringValue(context, "text-field", null);
uriPrefix = UimaContextHelper.getConfigParameterStringValue(context, "uri-prefix", null);
}
示例15: initialize
import org.apache.uima.UimaContext; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100);
analyzer = UimaContextHelper.createObjectFromConfigParameter(context, "query-analyzer",
"query-analyzer-params", StandardAnalyzer.class, Analyzer.class);
queryStringConstructor = UimaContextHelper.createObjectFromConfigParameter(context,
"query-string-constructor", "query-string-constructor-params",
LuceneQueryStringConstructor.class, QueryStringConstructor.class);
parser = new QueryParser("text", analyzer);
// load parameters
String param = UimaContextHelper.getConfigParameterStringValue(context, "doc-logreg-params");
try {
docFeatWeights = Resources.readLines(getClass().getResource(param), UTF_8).stream().limit(1)
.map(line -> line.split("\t")).flatMap(Arrays::stream)
.mapToDouble(Double::parseDouble).toArray();
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
}