Skip to content

IndentationError: unindent does not match any outer indentation level #4

Description

@abdzrahim

I have a problem that I run this code to get word tuples. I got an error below. The code get_words are on below. Can anyone help to solve this problem?

File "chat-med-2.py", line 39 puncRegexp = re.compile('[%s]' % re.escape(string.punctuation) ) ^ IndentationError: unindent does not match any outer indentation level

`def get_words(text):
"""Retrieve the words present in a given string of text.
The return value is a list of tuples where the first member is a lowercase word,
and the second member the number of time it is present in the text. Example:
IN: "Did the cow jump over the moon?"
OUT: dict_items([('cow', 1), ('jump', 1), ('moon', 1), ('?', 1),
('over', 1), ('the', 2), ('did', 1)])
"""
puncRegexp = re.compile('[%s]' % re.escape(string.punctuation))
text = puncRegexp.sub('',text)

wordsRegexpString = '\w+'
wordsRegexp = re.compile(wordsRegexpString)
wordList = wordsRegexp.findall(text.lower())

return Counter(wordsList).items()`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions