/** * Returns sentences until the document is exhausted. Calls close() if the end of the document * is reached. Otherwise, the user is required to close the stream. * * @return An Iterator over sentences (each a List of word tokens). * Although the type is given as {@code List<HasWord>}, in practice you get a List of CoreLabel, * and you can cast down to that. (Someday we might manage to fix the generic typing....) */ @Override public Iterator<List<HasWord>> iterator() { // Add new document types here if (docType == DocType.Plain) { return new PlainTextIterator(); } else if (docType == DocType.XML) { return new XMLIterator(); } else { throw new IllegalStateException("Someone didn't add a handler for a new docType."); } }
@Override public List<HasWord> next() { if (nextSent == null) { throw new NoSuchElementException(); } List<HasWord> thisSentence = nextSent; primeNext(); return thisSentence; }
/** * Returns sentences until the document is exhausted. Calls close() if the end of the document * is reached. Otherwise, the user is required to close the stream. */ public Iterator<List<HasWord>> iterator() { try { if (inputReader == null) inputReader = getReaderFromPath(inputPath); //TODO: Add new document types here if (docType == DocType.Plain) { return new PlainTextIterator(); } else if (docType == DocType.XML) { return new XMLIterator(); } } catch (IOException e) { System.err.printf("%s: Could not open path %s\n", this.getClass().getName(), inputPath); } return new Iterator<List<HasWord>>() { public boolean hasNext() { return false; } public List<HasWord> next() { throw new NoSuchElementException(); } public void remove() {} }; }
/** * Returns sentences until the document is exhausted. Calls close() if the end of the document * is reached. Otherwise, the user is required to close the stream. * * @return An Iterator over sentences (each a List of word tokens). * Although the type is given as {@code List<HasWord>}, in practice you get a List of CoreLabel, * and you can cast down to that. (Someday we might manage to fix the generic typing....) */ @Override public Iterator<List<HasWord>> iterator() { // Add new document types here if (docType == DocType.Plain) { return new PlainTextIterator(); } else if (docType == DocType.XML) { return new XMLIterator(); } else { throw new IllegalStateException("Someone didn't add a handler for a new docType."); } }
/** * Returns sentences until the document is exhausted. Calls close() if the end of the document * is reached. Otherwise, the user is required to close the stream. * * @return An Iterator over sentences (each a List of word tokens). * Although the type is given as {@code List<HasWord>}, in practice you get a List of CoreLabel, * and you can cast down to that. (Someday we might manage to fix the generic typing....) */ @Override public Iterator<List<HasWord>> iterator() { // Add new document types here if (docType == DocType.Plain) { return new PlainTextIterator(); } else if (docType == DocType.XML) { return new XMLIterator(); } else { throw new IllegalStateException("Someone didn't add a handler for a new docType."); } }
/** * Returns sentences until the document is exhausted. Calls close() if the end of the document * is reached. Otherwise, the user is required to close the stream. */ @Override public Iterator<List<HasWord>> iterator() { // Add new document types here if (docType == DocType.Plain) { return new PlainTextIterator(); } else if (docType == DocType.XML) { return new XMLIterator(); } else { throw new IllegalStateException("Someone didn't add a handler for a new docType."); } }
public List<HasWord> next() { if (nextSent == null) { throw new NoSuchElementException(); } List<HasWord> thisSentence = nextSent; primeNext(); return thisSentence; }
public List<HasWord> next() { if (nextSent == null) { throw new NoSuchElementException(); } List<HasWord> thisSentence = nextSent; primeNext(); return thisSentence; }
public XMLIterator() { xmlItr = new XMLBeginEndIterator<String>(inputReader, elementDelimiter); originalDocReader = inputReader; primeNext(); }
public XMLIterator() { xmlItr = new XMLBeginEndIterator<String>(inputReader, elementDelimiter); originalDocReader = inputReader; primeNext(); }
public XMLIterator() { xmlItr = new XMLBeginEndIterator<>(inputReader, elementDelimiter); originalDocReader = inputReader; primeNext(); }
public XMLIterator() { xmlItr = new XMLBeginEndIterator<>(inputReader, elementDelimiter); originalDocReader = inputReader; primeNext(); }
@Override public List<HasWord> next() { if (nextSent == null) { throw new NoSuchElementException(); } List<HasWord> thisSentence = nextSent; primeNext(); return thisSentence; }
@Override public List<HasWord> next() { if (nextSent == null) { throw new NoSuchElementException(); } List<HasWord> thisSentence = nextSent; primeNext(); return thisSentence; }
public XMLIterator() { xmlItr = new XMLBeginEndIterator<>(inputReader, elementDelimiter); originalDocReader = inputReader; primeNext(); }