Refactor HNLoaderComponent load method to update document metadata
This commit is contained in:
parent
69f2f51161
commit
64bcb971ad
1 changed files with 8 additions and 4 deletions
|
|
@ -27,7 +27,11 @@ class HNLoaderComponent(CustomComponent):
|
||||||
web_path: str,
|
web_path: str,
|
||||||
metadata: Optional[Dict] = None,
|
metadata: Optional[Dict] = None,
|
||||||
) -> HNLoader:
|
) -> HNLoader:
|
||||||
# Assuming that there's a specific loader for Hacker News
|
documents = HNLoader(web_path=web_path).load()
|
||||||
# as HNloader does not take a web_path argument
|
if(metadata):
|
||||||
# The HackerNewsLoader needs to be defined somewhere in the actual implementation
|
for document in documents:
|
||||||
return HNLoader(metadata=metadata, web_path=web_path)
|
if not document.metadata:
|
||||||
|
document.metadata = metadata
|
||||||
|
else:
|
||||||
|
document.metadata.update(metadata)
|
||||||
|
return documents
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue