@Override protected void setBestCategory(CAS cas, String bestCategory) { cas.setDocumentLanguage(bestCategory); } }
@Override protected void setBestCategory(CAS cas, String bestCategory) { cas.setDocumentLanguage(bestCategory); } }
/** * Inits the cas. */ private final void initCas() { this.cas.setDocumentLanguage(this.language); this.cas.setDocumentText(this.textArea.getText()); }
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()); }
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); } }
@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); } }
public void runCPM(String text) { cas.setDocumentText(text); cas.setDocumentLanguage(langID); try { ae.process(cas); } catch (AnalysisEngineProcessException e) { e.printStackTrace(); } processCAS(cas); cas.reset(); }
aCas.setDocumentLanguage(language);
/** * 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; }
/** * 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; }
@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); } } }
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); } }
@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); } } }
@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); } } }
aCas.setDocumentLanguage(language);
aCas.setDocumentLanguage(language);
CAS cas = null; cas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null); cas.setDocumentLanguage("en"); if (inf != null) { text = inf.readLine();
cas.setDocumentLanguage("en");