mardi 7 juillet 2020

Is it possible to compare one variable to several other variables in a if statement in python? [duplicate]

I would like to improve this following if statement

#Extract ORG, GPE, LOC and FAC labels from phrases
for entity in doc.ents:
    if entity.label_ == "ORG" or entity.label_ == "GPE" or entity.label_ == "LOC" or entity.label_ == "FAC":
        print(entity.text, entity.label_)

Is it possible reduce the number of "entity.label_" variables to one?

Aucun commentaire:

Enregistrer un commentaire