当前位置: 首页>>代码示例>>Java>>正文


Java UimaContext类代码示例

本文整理汇总了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));
    }
}
 
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:19,代码来源:NERAnnotator.java

示例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);
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:17,代码来源:CompressedXmiReader.java

示例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);
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:23,代码来源:CompressedXmiWriter.java

示例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);
    }

}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:19,代码来源:ArgumentsToHTMLExporter.java

示例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");
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:22,代码来源:ConceptMapMining.java

示例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");
}
 
开发者ID:UKPLab,项目名称:emnlp2017-cmapsum-corpus,代码行数:22,代码来源:ConceptMapMining.java

示例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);
    }
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:21,代码来源:AnswerTypeClassifierPredictor.java

示例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);
	}

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:25,代码来源:MetaDataExport.java

示例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<>();
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:18,代码来源:GSAnswerTypeLabeler.java

示例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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:21,代码来源:ActiveMqXmiWriter.java

示例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;
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:19,代码来源:PassageConceptRecognizer.java

示例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);
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:18,代码来源:WeightingSearchIdConceptReranker.java

示例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);
		}
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:26,代码来源:ReadDlinaMetadata.java

示例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);
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:26,代码来源:LuceneDocumentRetrievalExecutor.java

示例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);
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:21,代码来源:LogRegDocumentReranker.java


注:本文中的org.apache.uima.UimaContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。