Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndentationError: expected an indented block #40

Open
anxin16 opened this issue Oct 26, 2017 · 3 comments
Open

IndentationError: expected an indented block #40

anxin16 opened this issue Oct 26, 2017 · 3 comments

Comments

@anxin16
Copy link

anxin16 commented Oct 26, 2017

When I run the code in python3,

from pattern3.en import tag
from nltk.corpus import wordnet as wn

# Annotate text tokens with POS tags
def pos_tag_text(text):

def penn_to_wn_tags(pos_tag):
        if pos_tag.startswith('J'):
            return wn.ADJ
        elif pos_tag.startswith('V'):
            return wn.VERB
        elif pos_tag.startswith('N'):
            return wn.NOUN
        elif pos_tag.startswith('R'):
            return wn.ADV
        else:
            return None

tagged_text = tag(text)
    tagged_lower_text = [(word.lower(), penn_to_wn_tags(pos_tag))
                         for word, pos_tag in
                         tagged_text]
    return tagged_lower_text

I got the error message:
File "/Anaconda3/lib/python3.6/site-packages/pattern3/text/tree.py", line 37
except:
^
IndentationError: expected an indented block

@anxin16
Copy link
Author

anxin16 commented Oct 26, 2017

Please check tree.py

@barliant
Copy link

There is an empty line after try: in line 36 tree.py, followed by except:

@barliant
Copy link

Checking the code of tree.py from pattern, it might look something like this

try:
    from itertools import chain
    from itertools import izip
except:
    izip = zip  # Python 3

Instead of

from itertools import chain
try:
    
except:
    izip = zip  # Python 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants