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

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

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

CAS.setDocumentLanguage介绍

[英]Sets the language for this document. This value sets the language feature of the special instance of DocumentAnnotation associated with this CAS.
[中]设置此文档的语言。此值设置与此CAS关联的DocumentAnnotation特殊实例的语言功能。

代码示例

代码示例来源:origin: Ailab403/ailab-mltk4j

@Override
 protected void setBestCategory(CAS cas, String bestCategory) {
  cas.setDocumentLanguage(bestCategory);
 }
}

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

@Override
 protected void setBestCategory(CAS cas, String bestCategory) {
  cas.setDocumentLanguage(bestCategory);
 }
}

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

/**
 * Inits the cas.
 */
private final void initCas() {
 this.cas.setDocumentLanguage(this.language);
 this.cas.setDocumentText(this.textArea.getText());
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor-ide

private InputStream getDocument(String fileName, String text, String language,
    SerialFormat format) {
 String failedToImportLine = "Failed to import: " + fileName + "\n\n";
 CAS cas = createEmtpyCAS();
 cas.setDocumentText(removeNonXmlChars(text));
 cas.setDocumentLanguage(language);
 ByteArrayOutputStream out = new ByteArrayOutputStream(40000);
 try {
  CasIOUtils.save(cas, out, format);
 } catch (IOException e) {
  throw new TaeError(failedToImportLine + e.getMessage(), e);
 }
 return new ByteArrayInputStream(out.toByteArray());
}

代码示例来源:origin: DigitalPebble/behemoth

protected void doProcess(BehemothDocument behemoth, Reporter reporter) throws AnalysisEngineProcessException {
  // does the input document have a some text?
  // if not - skip it
  if (behemoth.getText() == null) {
    LOG.debug(behemoth.getUrl().toString() + " has null text");
  } else {
    // detect language if specified by user
    String lang = this.config.get("uima.language", "en");
    cas.setDocumentLanguage(lang);
    cas.setDocumentText(behemoth.getText());
    // process it
    tae.process(cas);
    convertCASToBehemoth(cas, behemoth, reporter);
  }
}

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

@Override
public void getNext(CAS cas)
  throws IOException
{
  // Initialize CAS with document meta data
  initCas(cas, currentFileResource, null);
  if (!StringUtils.isWhitespace(language)) {
    cas.setDocumentLanguage(language);
  }
  // The buffer where document text is to be stored
  StringBuilder documentText = new StringBuilder();
  Node node = nodes.poll();
  if (node != null) {
    processNode(cas, node, documentText);
  }
  // Set document text in cas or error if nothing gets parsed out
  String documentTextString = documentText.toString();
  if (StringUtils.isWhitespace(documentTextString)) {
    cas.setDocumentText("[Parse error]");
  }
  else {
    cas.setDocumentText(documentTextString);
  }
}

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

public void runCPM(String text) {
 cas.setDocumentText(text);
 cas.setDocumentLanguage(langID);
 try {
  ae.process(cas);
 } catch (AnalysisEngineProcessException e) {
  e.printStackTrace();
 }
 processCAS(cas);
 cas.reset();
}

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

aCas.setDocumentLanguage(language);

代码示例来源:origin: org.apache.uima/uimaj-component-test-util

/**
* performs a test on the initialized annotator. The specified document is
* processed with the given language.
* 
* @param text
*           a document text
* @param language
*           the document text language
* @return CAS - results of the analysis
* @throws Exception passthru
*/
public CAS performTest(String text, String language) throws Exception {
 try {
   // Create a new CAS.
   CAS cas = this.ae.newCAS();
   // Set the document text on the CAS.
   cas.setDocumentText(text);
   cas.setDocumentLanguage(language);
   // Process the sample document.
   this.ae.process(cas);
   return cas;
 } catch (Exception ex) {
   JUnitExtension.handleException(ex);
 }
 return null;
}

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

/**
* performs a test on the initialized annotator. The specified document is
* processed with the given language.
* 
* @param text
*           a document text
* @param language
*           the document text language
* @return CAS - results of the analysis
* @throws Exception passthru
*/
public CAS performTest(String text, String language) throws Exception {
 try {
   // Create a new CAS.
   CAS cas = this.ae.newCAS();
   // Set the document text on the CAS.
   cas.setDocumentText(text);
   cas.setDocumentLanguage(language);
   // Process the sample document.
   this.ae.process(cas);
   return cas;
 } catch (Exception ex) {
   JUnitExtension.handleException(ex);
 }
 return null;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-xmi

@Override
  public void getNext(CAS aCAS)
    throws IOException, CollectionException
  {
    Resource res = nextFile();
    initCas(aCAS, res);

    InputStream is = null;
    try {
      is = CompressionUtils.getInputStream(res.getLocation(), res.getInputStream());
      XmiCasDeserializer.deserialize(is, aCAS, lenient);

      // Override language using PARAM_LANG if that is set
      if (getLanguage() != null) {
        aCAS.setDocumentLanguage(getLanguage());
      }
    }
    catch (SAXException e) {
      throw new IOException(e);
    }
    finally {
      closeQuietly(is);
    }
  }
}

代码示例来源: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: de.tudarmstadt.ukp.clarin.webanno/webanno-xmi

@Override
  public void getNext(CAS aCAS)
    throws IOException, CollectionException
  {
    Resource res = nextFile();
    initCas(aCAS, res);

    InputStream is = null;
    try {
      is = CompressionUtils.getInputStream(res.getLocation(), res.getInputStream());
      XmiCasDeserializer.deserialize(is, aCAS, lenient);
      
      // Override language using PARAM_LANG if that is set
      if (getLanguage() != null) {
        aCAS.setDocumentLanguage(getLanguage());
      }
    }
    catch (SAXException e) {
      throw new IOException(e);
    }
    finally {
      closeQuietly(is);
    }
  }
}

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

@Override
  public void getNext(CAS aCAS)
    throws IOException, CollectionException
  {
    Resource res = nextFile();
    initCas(aCAS, res);

    InputStream is = null;
    try {
      is = CompressionUtils.getInputStream(res.getLocation(), res.getInputStream());
      XmiCasDeserializer.deserialize(is, aCAS, lenient);

      // Override language using PARAM_LANG if that is set
      if (getLanguage() != null) {
        aCAS.setDocumentLanguage(getLanguage());
      }
    }
    catch (SAXException e) {
      throw new IOException(e);
    }
    finally {
      closeQuietly(is);
    }
  }
}

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

aCas.setDocumentLanguage(language);

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

aCas.setDocumentLanguage(language);

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

CAS cas = null;
cas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null);
cas.setDocumentLanguage("en");
if (inf != null) {
  text = inf.readLine();

代码示例来源:origin: org.apache.uima/uimaj-component-test-util

cas.setDocumentLanguage(language);

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

cas.setDocumentLanguage("en");

代码示例来源:origin: org.apache.uima/uimaj-component-test-util

cas.setDocumentLanguage("en");

相关文章