Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何解决这个问题?定义创建频率表(文本字符串)->;dict:^SyntaxError:无效语法_Python_Atom Editor - Fatal编程技术网

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说蟒蛇会死: