Python 如何解决这个问题?定义创建频率表(文本字符串)->;dict:^SyntaxError:无效语法
这是代码的一部分:Python 如何解决这个问题?定义创建频率表(文本字符串)->;dict:^SyntaxError:无效语法,python,atom-editor,Python,Atom Editor,这是代码的一部分: ''' Don’t leave your dreams to chance. ''' def _create_frequency_table(text_string) -> dict: """ we create a dictionary for the word frequency table. For this, we should only use the words that are not part of the stopWords
'''
Don’t leave your dreams to chance.
'''
def _create_frequency_table(text_string) -> dict:
"""
we create a dictionary for the word frequency table.
For this, we should only use the words that are not part of the stopWords array.
Removing stop words and making frequency table
Stemmer - an algorithm to bring words to its root word.
:rtype: dict
"""
stopWords = set(stopwords.words("english"))
words = word_tokenize(text_string)
ps = PorterStemmer()
这是我试图理解的代码部分。。
下面是错误
line 29
def _create_frequency_table(text_string) -> dict:
^
SyntaxError: invalid syntax
非常感谢您的帮助,您使用的是什么python版本?我使用的是python 3.5中引入的python 2.7类型提示(即,
->dict
函数定义的一部分),python 2.7不会理解它们并给出语法错误。这是否回答了您的问题?Guido van Rossum说蟒蛇会死: