@After public void closeReader() { try { bufferedReader.close(); } catch (final Exception e) { // ignore } try { reversedLinesFileReader.close(); } catch (final Exception e) { // ignore } }
@After public void closeReader() { try { reversedLinesFileReader.close(); } catch(final Exception e) { // ignore } }
@After public void closeReader() { try { reversedLinesFileReader.close(); } catch (final Exception e) { // ignore } }
@Test(expected = UnsupportedEncodingException.class) public void testUnsupportedEncodingBig5() throws URISyntaxException, IOException { final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); new ReversedLinesFileReader(testFileEncodingBig5, testParamBlockSize, "Big5").close(); }
@Test(expected = UnsupportedEncodingException.class) public void testUnsupportedEncodingUTF16() throws URISyntaxException, IOException { final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, "UTF-16").close(); }
@Test(expected=UnsupportedEncodingException.class) public void testUnsupportedEncodingUTF16() throws URISyntaxException, IOException { final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); new ReversedLinesFileReader(testFileEmpty, 4096, "UTF-16").close(); }
@Test(expected=UnsupportedEncodingException.class) public void testUnsupportedEncodingBig5() throws URISyntaxException, IOException { final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); new ReversedLinesFileReader(testFileEncodingBig5, 4096, "Big5").close(); }
@Override public void close() throws IOException { journal.close(); } }
private void closeReversedReader(ReversedLinesFileReader reversedReader) { if (reversedReader != null) { try { reversedReader.close(); } catch (IOException ex) { logger.warning("Cloud not close ReversedLinesFileReader: " + ex); } } }
@Override public void close() { LOGGER.trace("Closing stream reader"); try { reader.close(); } catch (final IOException ex) { throw new UncheckedIOException(ex); } }
public static HashMap<Sequence, Double> readLastEMStepSequences(final File logFile) throws IOException { final HashMap<Sequence, Double> sequences = new HashMap<>(); final ReversedLinesFileReader reader = new ReversedLinesFileReader(logFile); String line = reader.readLine(); while (line != null) { if (line.contains("Parameter Optimal Sequences:")) { final Matcher m = Pattern .compile( "\\[((?:[0-9]|,| )+?)\\]=\\(((?:(?:[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|,)+?)\\)") .matcher(line); while (m.find()) { final Sequence sequence = new Sequence(); final String[] items = m.group(1).split(", "); for (final String item : items) sequence.add(Integer.parseInt(item)); final double prob = 1 - Double.parseDouble(m.group(2).split(",")[0]); sequences.put(sequence, prob); } break; } line = reader.readLine(); } reader.close(); return sequences; }
public static HashMap<Sequence, Double> readLastEMStepSequences(final File logFile) throws IOException { final HashMap<Sequence, Double> sequences = new HashMap<>(); final ReversedLinesFileReader reader = new ReversedLinesFileReader(logFile); String line = reader.readLine(); while (line != null) { if (line.contains("Parameter Optimal Sequences:")) { final Matcher m = Pattern .compile( "\\[((?:[0-9]|,| )+?)\\](?:\\^\\(([0-9]+)\\))?=([-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)") .matcher(line); while (m.find()) { final Sequence sequence = new Sequence(); final String[] items = m.group(1).split(", "); for (final String item : items) sequence.add(Integer.parseInt(item)); if (m.group(2) != null) { // has occurrence for (int i = 0; i < Integer.parseInt(m.group(2)) - 1; i++) sequence.incrementOccurence(); } final double prob = Double.parseDouble(m.group(3)); sequences.put(sequence, prob); } break; } line = reader.readLine(); } reader.close(); return sequences; }