MCPcopy
hub / github.com/nltk/nltk / read

Method read

nltk/data.py:1300–1318  ·  view source on GitHub ↗

Read up to ``size`` bytes, decode them using this reader's encoding, and return the resulting unicode string. :param size: The maximum number of bytes to read. If not specified, then read as many bytes as possible. :type size: int :rtype: unicod

(self, size=None)

Source from the content-addressed store, hash-verified

1298 # /////////////////////////////////////////////////////////////////
1299
1300 def read(self, size=None):
1301 """
1302 Read up to ``size`` bytes, decode them using this reader's
1303 encoding, and return the resulting unicode string.
1304
1305 :param size: The maximum number of bytes to read. If not
1306 specified, then read as many bytes as possible.
1307 :type size: int
1308 :rtype: unicode
1309 """
1310 chars = self._read(size)
1311
1312 # If linebuffer is not empty, then include it in the result
1313 if self.linebuffer:
1314 chars = "".join(self.linebuffer) + chars
1315 self.linebuffer = None
1316 self._rewind_numchars = None
1317
1318 return chars
1319
1320 def discard_line(self):
1321 if self.linebuffer and len(self.linebuffer) > 1:

Callers 2

readlinesMethod · 0.95
check_readerFunction · 0.95

Calls 2

_readMethod · 0.95
joinMethod · 0.45

Tested by 1

check_readerFunction · 0.76