MCPcopy
hub / github.com/nltk/nltk / token

Method token

nltk/sem/logic.py:264–276  ·  view source on GitHub ↗

Get the next waiting token. If a location is given, then return the token at currentIndex+location without advancing currentIndex; setting it gives lookahead/lookback capability.

(self, location=None)

Source from the content-addressed store, hash-verified

262 return self._currentIndex + location < len(self._buffer)
263
264 def token(self, location=None):
265 """Get the next waiting token. If a location is given, then
266 return the token at currentIndex+location without advancing
267 currentIndex; setting it gives lookahead/lookback capability."""
268 try:
269 if location is None:
270 tok = self._buffer[self._currentIndex]
271 self._currentIndex += 1
272 else:
273 tok = self._buffer[self._currentIndex + location]
274 return tok
275 except IndexError as e:
276 raise ExpectedMoreTokensException(self._currentIndex + 1) from e
277
278 def isvariable(self, tok):
279 return tok not in Tokens.TOKENS

Callers 15

parseMethod · 0.95
handle_variableMethod · 0.95
handle_lambdaMethod · 0.95
handle_quantMethod · 0.95
assertNextTokenMethod · 0.95
__repr__Method · 0.95
handleMethod · 0.45

Calls 1

Tested by

no test coverage detected