@@ -21,6 +21,10 @@ def unified_document_loader(uri: str) -> Dict:
2121 _LOGGER .error (f"Failed to fetch remote document: { response .status_code } - { response .text } " )
2222 return {}
2323 else :
24+ # Handle file:// URIs by converting to local path
25+ if uri .startswith ("file://" ):
26+ from urllib .parse import unquote , urlparse
27+ uri = unquote (urlparse (uri ).path )
2428 with open (uri , "r" ) as f :
2529 return json .load (f )
2630
@@ -144,7 +148,12 @@ def expanded(self) -> Any:
144148 preprocessed ["@context" ] = data ["@context" ]
145149
146150 # Expand the preprocessed data
147- return jsonld .expand (preprocessed , options = {"base" : self .uri })
151+ # Convert file paths to file:// URIs for pyld 3.0+ compatibility
152+ base_uri = self .uri
153+ if not base_uri .startswith (("http://" , "https://" , "file://" )):
154+ from pathlib import Path
155+ base_uri = Path (base_uri ).as_uri ()
156+ return jsonld .expand (preprocessed , options = {"base" : base_uri })
148157
149158 @cached_property
150159 def context (self ) -> Dict :
@@ -170,7 +179,12 @@ def context(self) -> Dict:
170179 def normalized (self ) -> str :
171180 """Normalize the JSON-LD data."""
172181 _LOGGER .info (f"Normalizing JSON-LD data for { self .uri } " )
173- return jsonld .normalize (self .uri , options = {"algorithm" : "URDNA2015" , "format" : "application/n-quads" })
182+ # Convert file paths to file:// URIs for pyld 3.0+ compatibility
183+ uri = self .uri
184+ if not uri .startswith (("http://" , "https://" , "file://" )):
185+ from pathlib import Path
186+ uri = Path (uri ).as_uri ()
187+ return jsonld .normalize (uri , options = {"algorithm" : "URDNA2015" , "format" : "application/n-quads" })
174188
175189 def _extract_model_key (self , uri : str ) -> Optional [str ]:
176190 """Extract a model key from the URI."""
0 commit comments