Files
smartguide/service/src/main/inse/utils.py
T
Mats Paul Tončik 92d4cd446f
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit
Added experimental filtering by min/max collaborations as well as institution and topic
2026-05-31 11:14:08 +02:00

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")