nltk.str2tuple()

nltk.str2tuple(s, sep='/')[source]

Given the string representation of a tagged token, return the corresponding tuple representation. The rightmost occurrence of sep in s will be used to divide s into a word string and a tag string. If sep does not occur in s, return (s, None).

>>> from nltk.tag.util import str2tuple
>>> str2tuple('fly/NN')
('fly', 'NN')
Parameters:
  • s (str) – The string representation of a tagged token.
  • sep (str) – The separator string used to separate word strings from tags.