Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/comproscanner/comproscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@

class ComProScanner:
def __init__(self, main_property_keyword: str = None):
self.main_property_keyword = main_property_keyword
if self.main_property_keyword is None:
if main_property_keyword is None:
raise ValueErrorHandler(
"Please provide a main property keyword to proceed."
)

self.main_property_keyword = main_property_keyword.replace(" ", "_")
self.main_property_search_keyword = self.main_property_keyword.replace("_", " ")

def collect_metadata(
self,
base_queries: Optional[list] = None,
Expand Down Expand Up @@ -501,7 +503,7 @@ def extract_composition_property_data(
f"results/extracted_data/{self.main_property_keyword}/related_figures"
)
if materials_data_identifier_query is None:
materials_data_identifier_query = f"Is there any material chemical composition and corresponding {self.main_property_keyword} value mentioned in the paper? Give one word answer. Either yes or no."
materials_data_identifier_query = f"Is there any material chemical composition and corresponding {self.main_property_search_keyword} value mentioned in the paper? Give one word answer. Either yes or no."
preparator = MatPropDataPreparator(
main_property_keyword=self.main_property_keyword,
main_extraction_keyword=main_extraction_keyword,
Expand Down
12 changes: 10 additions & 2 deletions src/comproscanner/metadata_extractor/fetch_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ def _construct_url(self, cursor, year, query, special_query):
Returns:
str: The constructed URL
"""
base = f"{self.base_url}PUBYEAR+%3D+{year}+{query}"
url = base + (f"+{special_query}" if special_query else "") + "&count=200"
search_query = query.replace("_", " ")
encoded_query = urllib.parse.quote(search_query.replace(" ", " AND "))
encoded_special_query = (
urllib.parse.quote(special_query.replace("_", " ").replace(" ", " AND "))
if special_query
else ""
)

base = f"{self.base_url}PUBYEAR+%3D+{year}+{encoded_query}"
url = base + (f"+{encoded_special_query}" if encoded_special_query else "") + "&count=200"
url += f"&cursor={cursor}"
return url

Expand Down
Loading