LocationBasedServices/smartguide/pipeline/head There was a failure building this commit
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import re
|
|
|
|
|
|
author_id_pattern = re.compile(r"https://openalex\.org/A\d+", re.IGNORECASE)
|
|
work_id_pattern = re.compile(r"https://openalex\.org/W\d+", re.IGNORECASE)
|
|
|
|
|
|
def extract_raw_author_id(author_id: str) -> str:
|
|
match = author_id_pattern.search(author_id)
|
|
if match:
|
|
return match.group().split("/")[-1]
|
|
raise ValueError("Invalid author ID format")
|
|
|
|
|
|
def extract_raw_work_id(work_id: str) -> str:
|
|
match = work_id_pattern.search(work_id)
|
|
if match:
|
|
return match.group().split("/")[-1]
|
|
raise ValueError("Invalid work ID format")
|
|
|
|
|
|
def extract_raw_institution_id(institution_id: str) -> str:
|
|
match = re.search(r"https://openalex\.org/I\d+", institution_id, re.IGNORECASE)
|
|
if match:
|
|
return match.group().split("/")[-1]
|
|
raise ValueError("Invalid institution ID format")
|
|
|
|
|
|
def extract_raw_topic_id(topic_id: str) -> str:
|
|
match = re.search(r"https://openalex\.org/T\d+", topic_id, re.IGNORECASE)
|
|
if match:
|
|
return match.group().split("/")[-1]
|
|
raise ValueError("Invalid topic ID format")
|