Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug preventing files from being processed in SciBite ingest #299

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions kg_covid_19/transform_utils/scibite_cord/scibite_cord.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'WD': 'http://www.wikidata.org/entity/'
}


class ScibiteCordTransform(Transform):
"""
ScibiteCordTransform parses the SciBite annotations on CORD-19 dataset
Expand Down Expand Up @@ -94,14 +95,12 @@ def parse_annotations(self, node_handle: Any, edge_handle: Any,
subsets = ['pmc_json', 'pdf_json']
for subset in subsets:
subset_dir = os.path.join(self.input_base_dir, subset)
for data_dir in os.listdir(subset_dir):
if os.path.isdir(os.path.join(subset_dir, data_dir)):
for filename in os.listdir(os.path.join(subset_dir, data_dir)):
file = os.path.join(subset_dir, data_dir, filename)
doc = json.load(open(file))
self.parse_annotation_doc(node_handle, edge_handle, doc, subset)

def parse_annotation_doc(self, node_handle, edge_handle, doc: Dict, subset: str = None) -> None:
for filename in os.listdir(subset_dir):
file = os.path.join(subset_dir, filename)
doc = json.load(open(file))
self.parse_annotation_doc(node_handle, edge_handle, doc)

def parse_annotation_doc(self, node_handle, edge_handle, doc: Dict) -> None:
"""Parse a JSON document corresponding to a publication.

Args:
Expand Down