2

I have written a simple piece of code to see exactly how the span_tokenize function works. Documentation for this can be found here: http://www.nltk.org/api/nltk.tokenize.html
Here is my piece of code

import nltk
from nltk.tokenize.api import StringTokenizer
sample = StringTokenizer()
sample.span_tokenize("Hulk is Boss")

The output is as follows:

<generator object StringTokenizer.span_tokenize at 0x113a7b258>

I can't understand why I am getting a generator object as an output when the expected output is tuple(int,int) as can be seen from nltk documentation

A nudge in the right direction is appreciated !!

  • Yes interesting! Why does `span_tokenize()` return a generator! That's not suppose to happen. – alvas Mar 15 '18 at 09:27
  • 1
    Thanks for catching that! Issue raised on https://github.com/nltk/nltk/issues/1980 – alvas Mar 15 '18 at 09:39

0 Answers0