Lambda-3 / PyCobalt

Coreference Resolution in Python
8 stars 3 forks source link

List object creation Syntax Error #2

Closed swathimithran closed 7 years ago

swathimithran commented 7 years ago

I have installed all the dependencies using pip3 and when I try to run the program i get the following syntax error :

Traceback (most recent call last): File "service.py", line 8, in from pycobalt import resolve, substitute File "./pycobalt/init.py", line 1, in from .resolving import resolve, get_entity_links, get_passages_and_linked_entities File "./pycobalt/resolving.py", line 48 substitutions: List[Substitution] = [] ^ SyntaxError: invalid syntax the code is as follows:

def resolve(text: str, entity_uri: str = '') -> Tuple[List[Sentence], List[Substitution]]:

substitutions: List[Substitution] = []

sentences: List[Sentence] = annotate_text(text)

if len(sentences) < 1: return [], []

if len(entity_uri) > 0 and 'lookup' in types: types['lookup'] = __load_types() else: __types['lookup'] = None

if 'lookup' not in types or types['lookup'] is None: types = [] else: types = __types['lookup'].type(entity_uri).split(' ')

name_refs, pronominal_refs, nominal_refs = __collect_references_and_coreferences( sentences=sentences, types=types)

first_name_mention = __first_name_mention( name_references=name_refs, predominant_gender=__predominant_gender(pronominal_refs), sentences=sentences)

__resolve_name_coreferences( first_name_mention=first_name_mention, name_references=name_refs, substitutions=substitutions)

__resolve_pronominal_coreferences( first_name_mention=first_name_mention, name_references=name_refs, pronominal_references=pronominal_refs, substitutions=substitutions)

__resolve_nominal_coreferences( first_name_mention=first_name_mention, nominal_references=nominal_refs, substitutions=substitutions)

return sentences, substitutions

bermeitinger-b commented 7 years ago

Are you using Python 3.4? The new type hinting feature was introduced in Python 3.6.

swathimithran commented 7 years ago

No i have both python 3.5 and 3.6, I installed uswgi using pip3 install uswgi

bermeitinger-b commented 7 years ago

Python 3.5 doesn't support variable type annotations/hinting, you must use Python 3.6 for this. I will update the README to reflect this.

swathimithran commented 7 years ago

ohh, then I guess by default it is calling python3.5 in my system and I am getting the error.

Can also remove "cd src" from readme and add pip3 instead of pip

Thanks for the information

bermeitinger-b commented 7 years ago

Thank you for pointing out that leftover line.

We have pip there instead of pip3 because we assume that it is running inside a virtual environment or using the docker image.

swathimithran commented 7 years ago

ohk then its fine.

Thanks Bye