/** * @param is * An {@link InputStream}. * @param filename * The filename this stream was created from. * @return A resolved {@link InputStream} * @throws IOException * if something went wrong during resolving the input stream * @deprecated Use {@link CompressionUtils#getInputStream(String, InputStream)} */ @Deprecated public static InputStream resolveCompressedInputStream(InputStream is, String filename) throws IOException { return CompressionUtils.getInputStream(filename, is); }
private BufferedReader getReader() throws FileNotFoundException, IOException { BufferedReader r = null; if (!fileQueue.isEmpty()) { currentResource = fileQueue.poll(); InputStream resolvedStream = CompressionUtils.getInputStream(currentResource.getPath(), currentResource.getInputStream()); r = new BufferedReader(new InputStreamReader(resolvedStream, encoding)); } return r; } }
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); documentsTotal = 0; idxOriginName = new HashMap<String, String>(); try { // Detect if the file is compressed InputStream fileStream = new FileInputStream(inputFile); InputStream resolvedStream = CompressionUtils.getInputStream(inputFile.getName(), fileStream); br = new BufferedReader(new InputStreamReader(resolvedStream, sourceEncoding)); readHeaders(); sentenceCount = 0; documentCount = 0; } catch (IOException e) { throw new ResourceInitializationException(e); } posMappingProvider = MappingProviderFactory.createPosMappingProvider(mappingPosLocation, posTagset, language); }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), encoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(CAS aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); try (InputStream is = new BufferedInputStream( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()))) { String text; if (ENCODING_AUTO.equals(sourceEncoding)) { CharsetDetector detector = new CharsetDetector(); text = IOUtils.toString(detector.getReader(is, null)); } else { text = IOUtils.toString(is, sourceEncoding); } aJCas.setDocumentText(text); } } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { try { if (namedEntityEnabled) { namedEntityMappingProvider.configure(aJCas.getCas()); } } catch (AnalysisEngineProcessException e) { throw new IOException(e); } Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@Override public void getNext(JCas aJCas) throws IOException, CollectionException { try { if (posEnabled) { posMappingProvider.configure(aJCas.getCas()); } if (chunkEnabled) { chunkMappingProvider.configure(aJCas.getCas()); } } catch (AnalysisEngineProcessException e) { throw new IOException(e); } Resource res = nextFile(); initCas(aJCas, res); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()), sourceEncoding)); convert(aJCas, reader); } finally { closeQuietly(reader); } }
@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); } } }
@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); } } }