org.apache.uima.cas.CAS.getDocumentLanguage()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.uima.cas.CAS.getDocumentLanguage()方法的一些代码示例,展示了CAS.getDocumentLanguage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.getDocumentLanguage()方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:getDocumentLanguage

CAS.getDocumentLanguage介绍

[英]Gets the language code for this document from the language feature of the special instance of the DocumentationAnnotation associated with this CAS.
[中]从与此CAS关联的DocumentationAnnotation特殊实例的语言功能获取此文档的语言代码。

代码示例

代码示例来源:origin: apache/opennlp

String language = tcas.getDocumentLanguage();

代码示例来源:origin: dkpro/dkpro-core

public void configure(CAS aCas)
  throws AnalysisEngineProcessException
{
  try {
    language = aCas.getDocumentLanguage();
    super.configure();
  }
  catch (IOException e) {
    throw new AnalysisEngineProcessException(e);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.uima-asl

if (tokens.get(0).getCAS().getDocumentLanguage().equals("en")) {
  wordnet = uby.getLexiconByName("WordNet");
} else if (tokens.get(0).getCAS().getDocumentLanguage().equals("de")) {
  wordnet = uby.getLexiconByName("GermaNet");

代码示例来源:origin: org.apache.uima/uimaj-tools

public void process(CAS aCAS) throws AnalysisEngineProcessException {
 // get handle to CAS view containing XML document
 CAS xmlCas = aCAS.getView("xmlDocument");
 InputStream xmlStream = xmlCas.getSofa().getSofaDataStream();
 // parse with detag handler
 DetagHandler handler = new DetagHandler();
 try {
  SAXParser parser = parserFactory.newSAXParser();
  parser.parse(xmlStream, handler);
 } catch (Exception e) {
  throw new AnalysisEngineProcessException(e);
 }
 // create the plain text view and set its document text
 CAS plainTextView = aCAS.createView("plainTextDocument");
 plainTextView.setDocumentText(handler.getDetaggedText());
 plainTextView.setDocumentLanguage(aCAS.getView("_InitialView").getDocumentLanguage());
 // Index the SourceDocumentInformation object, if there is one, in the new sofa.
 // This is needed by the SemanticSearchCasIndexer
 Iterator iter = xmlCas.getAnnotationIndex(sourceDocInfoType).iterator();
 if (iter.hasNext()) {
  FeatureStructure sourceDocInfoFs = (FeatureStructure) iter.next();
  plainTextView.getIndexRepository().addFS(sourceDocInfoFs);
 }
}

代码示例来源:origin: apache/uima-uimaj

public void process(AbstractCas aCAS) throws AnalysisEngineProcessException {
 if (!mCasInterface.isAssignableFrom(aCAS.getClass())) {
  throw new AnalysisEngineProcessException(
      AnalysisEngineProcessException.INCORRECT_CAS_INTERFACE, new Object[] { mCasInterface,
        aCAS.getClass() });
 }
 // check if type system changed; if so, notify Annotator
 checkTypeSystemChange(aCAS);
 // do proper typecasts and call process method
 try {
  if (mAnnotator instanceof TextAnnotator) {
   CAS cas = (CAS) aCAS;
   ResultSpecification rs = getResultSpecForLanguage(cas.getDocumentLanguage());
   rs.setTypeSystem(cas.getTypeSystem());
   ((TextAnnotator) mAnnotator).process(cas, rs);
  } else if (mAnnotator instanceof JTextAnnotator) {
   JCas jcas = (JCas) aCAS;
   ResultSpecification rs = getResultSpecForLanguage(jcas.getDocumentLanguage());
   rs.setTypeSystem(jcas.getTypeSystem());
   ((JTextAnnotator) mAnnotator).process(jcas, rs);
  } else if (mAnnotator instanceof GenericAnnotator) {
   mDefaultResultSpecification.setTypeSystem(((CAS) aCAS).getTypeSystem());
   ((GenericAnnotator) mAnnotator).process((CAS) aCAS, mDefaultResultSpecification);
  }
 } catch (AnnotatorProcessException e) {
  throw new AnalysisEngineProcessException(e);
 }
}

代码示例来源:origin: org.apache.uima/ruta-core

Class<?> type = env.getVariableType(var);
NumberFormat nf = null;
String locale = annotation.getCAS().getDocumentLanguage();
if (localeExpr != null) {
 locale = localeExpr.getStringValue(context, stream);

代码示例来源:origin: apache/uima-uimaj

String documentLanguage = Language.normalize(cas.getDocumentLanguage());

代码示例来源:origin: webanno/webanno

public void read()
  throws Exception
{
  CollectionReader xmiReader = CollectionReaderFactory.createReader(XmiReader.class,
      ResourceCollectionReaderBase.PARAM_SOURCE_LOCATION, testFolder.getRoot().getPath(),
      ResourceCollectionReaderBase.PARAM_PATTERNS,
      new String[] { ResourceCollectionReaderBase.INCLUDE_PREFIX + "*.xmi" });
  CAS cas = CasCreationUtils.createCas(createTypeSystemDescription(), null, null);
  xmiReader.getNext(cas);
  String refText = readFileToString(new File("src/test/resources/texts/latin.txt"));
  assertEquals(refText, cas.getDocumentText());
  assertEquals("latin", cas.getDocumentLanguage());
}

代码示例来源:origin: org.apache.opennlp/opennlp-uima

String language = tcas.getDocumentLanguage();

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.xmi-asl

language = aCAS.getDocumentLanguage();

代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.uima-asl

if (token.getCAS().getDocumentLanguage().equals("en")) {
  wordnet = uby.getLexiconByName("WordNet");
} else if (language.equals("en")) {
  wordnet = uby.getLexiconByName("WordNet");
} else if (token.getCAS().getDocumentLanguage().equals("de")) {
  wordnet = uby.getLexiconByName("GermaNet");
} else if (language.equals("de")) {

相关文章