/** * @param encoding input encoding or {@code null} to use the platform default */ public TabBitextReader(String filename, String encoding) { try { if (encoding == null) { in = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); } else { in = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); } nextLine = in.readLine(); prevLine = ""; nextPair = tab2StringPair(nextLine); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public StringPair next() { try { StringPair result = nextPair; sentencePos = nextPair.getSource().length() + 1; if (nextLine != null) { prevLine = nextLine; nextLine = in.readLine(); nextPair = tab2StringPair(nextLine); lineCount++; if (nextLine == null) { in.close(); } } return result; } catch (IOException e) { throw new RuntimeException(e); } }
/** * @param encoding input encoding or {@code null} to use the platform default */ public TabBitextReader(String filename, String encoding) { try { if (encoding == null) { in = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); } else { in = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); } nextLine = in.readLine(); prevLine = ""; nextPair = tab2StringPair(nextLine); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public StringPair next() { try { StringPair result = nextPair; sentencePos = nextPair.getSource().length() + 1; if (nextLine != null) { prevLine = nextLine; nextLine = in.readLine(); nextPair = tab2StringPair(nextLine); lineCount++; if (nextLine == null) { in.close(); } } return result; } catch (IOException e) { throw new RuntimeException(e); } }