/** * @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); }
singularTargetStream = CompressionUtils.getOutputStream(outputFile); CompressionUtils.getOutputStream(outputFile));
singularTargetStream = CompressionUtils.getOutputStream(outputFile); CompressionUtils.getOutputStream(outputFile));
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; } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
/** * Read an embeddings file in text format. * <p> * If hasHeader is set to true, the first line is expected to contain the size and * dimensionality of the vectors. This is typically true for files generated by Word2Vec (in * text format). * * @param file * the input file * @param hasHeader * if true, read size and dimensionality from the first line * @return a {@code Map<String, float[]>} mapping each token to a vector. * @throws IOException * if the input file cannot be read * @see #readEmbeddingFileTxt(InputStream, boolean) */ public static Map<String, float[]> readEmbeddingFileTxt(File file, boolean hasHeader) throws IOException { LOG.info("Reading embeddings from file " + file); InputStream is = CompressionUtils .getInputStream(file.getAbsolutePath(), new FileInputStream(file)); return readEmbeddingFileTxt(is, hasHeader); }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
@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); } }
OutputStream outputStream = CompressionUtils.getOutputStream(targetFile); PrintWriter printWriter = new PrintWriter(outputStream); matrix.write(printWriter);
@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); } }