osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Synax error in string assignment


I am not sure what the issue is with the 2nd file that assigns string to text variable.

Here is the code:
# -*- coding: utf-8 -*-
text = ?this?s a sent tokenize test. this is sent two. is this sent three? sent 4 is cool! Now it?s your turn.?
from nltk.tokenize import sent_tokenize
sent_tokenize_list = sent_tokenize(text)
len(sent_tokenize_list)
sent_tokenize_list

Here is the error:
 text = ?this?s a sent tokenize test. this is sent two. is this sent three? sent 4 is cool! Now it?s your turn.?
           ^
SyntaxError: invalid syntax 

BTW, the ^ operator pointing to the error is at text = and not for cool word. This is due to formatting issue in google group.