File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import requests
66
77from src .Normalizer import TTLNormalizer , JSONNormalizer
8- from src .WikidataLabel import WikidataLabel
8+ from src .WikidataLabel import WikidataLabel , LazyLabelFactory
99from src import utils
1010
1111# Start Fastapi app
@@ -89,6 +89,7 @@ async def get_textified_wd(
8989 filter_pids = [p .strip () for p in pid .split (',' )]
9090
9191 qids = [q .strip () for q in id .split (',' )]
92+ label_factory = LazyLabelFactory (lang = lang , fallback_lang = fallback_lang )
9293
9394 entities = {}
9495 if len (qids ) == 1 :
@@ -107,6 +108,7 @@ async def get_textified_wd(
107108 ttl_text = entity_data ,
108109 lang = lang ,
109110 fallback_lang = fallback_lang ,
111+ label_factory = label_factory ,
110112 debug = False ,
111113 )
112114
@@ -135,6 +137,7 @@ async def get_textified_wd(
135137 entity_json = entity_data [qid ],
136138 lang = lang ,
137139 fallback_lang = fallback_lang ,
140+ label_factory = label_factory ,
138141 debug = False ,
139142 ) if entity_data .get (qid ) else None
140143 for qid in qids
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def __init__(
2626 entity_json : Dict [str , Any ],
2727 lang : str = "en" ,
2828 fallback_lang : str = "en" ,
29+ label_factory : Optional [LazyLabelFactory ] = None ,
2930 debug : bool = False ,
3031 ):
3132 self .entity_id = entity_id
@@ -35,7 +36,8 @@ def __init__(
3536 self .fallback_lang = fallback_lang
3637 self .debug = debug
3738
38- self .label_factory = LazyLabelFactory (lang = lang , fallback_lang = fallback_lang )
39+
40+ self .label_factory = label_factory or LazyLabelFactory (lang = lang , fallback_lang = fallback_lang )
3941
4042 # -------------------------------------------------------------------------
4143 # Public API
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def __init__(
6060 ttl_text : str ,
6161 lang : str = "en" ,
6262 fallback_lang : str = "en" ,
63+ label_factory : Optional [LazyLabelFactory ] = None ,
6364 debug : bool = False ,
6465 ):
6566 self .entity_id = entity_id
@@ -70,7 +71,7 @@ def __init__(
7071 self .fallback_lang = fallback_lang
7172 self .debug = debug
7273
73- self .label_factory = LazyLabelFactory (lang = lang , fallback_lang = fallback_lang )
74+ self .label_factory = label_factory or LazyLabelFactory (lang = lang , fallback_lang = fallback_lang )
7475
7576 # -------------------------------------------------------------------------
7677 # Public API
You can’t perform that action at this time.
0 commit comments