From f322a6f47f1c13e3adc7437a9f96fc33ffd7d7fe Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 9 Oct 2019 16:25:17 +0100 Subject: [PATCH] New function to get English label for entity --- depicts/wikibase.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/depicts/wikibase.py b/depicts/wikibase.py index 9690e91..0cd846c 100644 --- a/depicts/wikibase.py +++ b/depicts/wikibase.py @@ -9,3 +9,7 @@ def get_entity_label(entity): label_values = {l['value'] for l in entity['labels'].values()} if len(label_values) == 1: return list(label_values)[0] + +def get_en_label(entity): + if 'en' in entity['labels']: + return entity['labels']['en']['value']