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.
484211
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() {}
    };
  }
388292
@Override
    public void close() throws IOException {
        if (!closed) {
            try {
                if (!eof && state != CHUNK_INVALID) {
                    // read and discard the remainder of the message
                    final byte[] buff = new byte[BUFFER_SIZE];
                    try {
                        while (read(buff) >= 0) {
                           continue;
                        }
                    } catch (ConnectionClosedException e) {
                        // just ignore
                    } catch (TruncatedChunkException e) {
                        // just ignore
                    }
                }
            } finally {
                eof = true;
                closed = true;
            }
        }
    }
1172790
def closed(self):
        """"""
        closed = self._closing or self._closed
        if not closed and self._reader and self._reader.at_eof():
            self._closing = closed = True
            self._loop.call_soon(self._do_close, None)
        return closed
91488
def next(self):
        """"""
        _LOGGER.debug("reading next")
        if self.closed:
            _LOGGER.debug("stream is closed")
            raise StopIteration()

        line = self.readline()
        if not line:
            _LOGGER.debug("nothing more to read")
            raise StopIteration()

        return line
623044
def has_end(self, stream):
        
        for token in self.end_tokens:
            if not self.has_next(token, stream):
                continue

            offset = len(token)

            if self.has_eof(stream, offset):
                return True

            if self.has_whitespace(stream, offset):
                return True

            if self.has_comment(stream, offset):
                return True

            if self.has_next(self.statement_delimiter, stream, offset):
                return True

        return self.has_eof(stream)
1224940
def next(self):
        """"""
        # Block until a document is returnable.
        while self.alive:
            doc = self._try_next(True)
            if doc is not None:
                return doc

        raise StopIteration
1036784
def close(self):
        
        if self.leave:
            if self.last_print_n < self.n:
                cur_t = time.time()
                self.sp.print_status(format_meter(self.n, self.total, cur_t-self.start_t, self.ncols, self.prefix, self.unit, self.unit_format, self.ascii))
            self.file.write('\n')
        else:
            self.sp.print_status('')
            self.file.write('\r')
812828
public function closeWriteAndReadAll()
    {
        $this->closeWrite();
        $response = $this->read();
        while (!is_null($response)) {
            yield $response;
            $response = $this->read();
        }
    }
134785
def end_state(self):
        

        # Make sure we append any trailing text
        if self.str_begin != len(self.format):
            if len(self.state) > 1 or self.state[-1] != 'string':
                self.fmt.append_text(
                    "(Bad format string; ended in state %r)" % self.state[-1])
            else:
                self.fmt.append_text(self.format[self.str_begin:])

        # Convenience return
        return self.fmt
337905
def end_output (self, **kwargs):
        """"""
        self.stats.downloaded_bytes = kwargs.get("downloaded_bytes")
        self.stats.num_urls = kwargs.get("num_urls")
        if self.has_part('stats'):
            self.write_stats()
        if self.has_part('outro'):
            self.write_outro(interrupt=kwargs.get("interrupt"))
        self.close_fileoutput()
800714
def finish(self):
        
        assert self._request, "Request closed"
        self._request_finished = True
        if self.m2req.should_close() or self.no_keep_alive:
            self._send("")
        self._request = None
1289722
public void end() {
		// if (((ArrayList) this.featureCollection).size() == 0) {
		this.endNewElement();
		// }
		contentHandler.endFeatureCollection(this.featureCollection);
		if (writerContentHandler != null)
			geoJSON = writerContentHandler.endFeatureCollection(geoJSON);
	}
628506
def end_of_paragraph(self, count=1, after=False):
        
        def match_func(text):
            return not text or text.isspace()

        line_index = self.find_next_matching_line(match_func=match_func, count=count)

        if line_index:
            add = 0 if after else 1
            return max(0, self.get_cursor_down_position(count=line_index) - add)
        else:
            return len(self.text_after_cursor)
715160
def end_output (self, **kwargs):
        
        self.xml_endtag(u"linkchecker")
        self.xml_end_output()
        self.close_fileoutput()
410276
def next(self):
        
        if self._has_finished:
            raise StopIteration

        if not len(self._buffer):
                    
            results = self.fetch_next_block()
            self._buffer.extend(results)
            
        if not len(self._buffer):
            raise StopIteration
            
        return self._buffer.popleft()
1159667
def end(self):
        
        self.send_headers()
        self.write()
        self.write_eof()
        self.has_ended = True
1043904
def end_of_line(event):
    "  "
    buff = event.current_buffer
    buff.cursor_position += buff.document.get_end_of_line_position()