-1

I'm new to python. Could anyone suggest what goes wrong with this input command. I'm running this code in python 3.7.0 from anaconda

def annotation_tool(path):
final_results = []
nlp = spacy.load("en_core_web_sm")
if path != '':
    file_text = open(path, "r").read()
    nlp_file_doc = nlp(file_text)
    sentences = list(nlp_file_doc.sents)
    for i in sentences:
        print("--------- Next sentence is %s ---------".format(i))
        print("--------- Possible candidates are %s ---------".format(apply_extraction(row,nlp))
        num_candidates = int(input("Enter number of candidates"))
        pair = []
        for x in range(0, num_candidates):
            candidates = input("--------- Enter candidates e.g. computer, good ---------")
            polarity = input("--------- Enter polarity of above candidates (pos/neg/neu) ---------")
            dict = {candidates: polarity}
            pair.append(dict)
        result = {"sentence": i, "candidates": pair}
        final_results.append(result)
        is_continue = input("--------- Continue with annotation y/n? ---------")
        if is_continue == 'n':
            break
return final_results

Here is syntax error:

File "test.py", line 128
num_candidates = int(input("Enter number of 
candidates"))
SyntaxError: invalid syntax
1
  • It's important to pay attention to when errors occur. This is not an error "when taking input"; it's an error in the code, before it runs. Commented Nov 10, 2024 at 16:46

1 Answer 1

4

The error is from the line above:

print("--------- Possible candidates are %s ---------".format(apply_extraction(row,nlp))

missing a closing parenthesis on the print statement

print("--------- Possible candidates are %s ---------".format(apply_extraction(row,nlp)))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.