This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def get_gnd_id(name: str, type: str) -> str: | |
"""Get the GND ID for a given name and type. | |
Args: | |
name (str): Name of the entity. | |
type (str): Type of the entity. | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Check if a profession is in the GND | |
def check_profession(profession: str) -> bool: | |
"""Check if a profession is in the GND. | |
Args: | |
profession (str): Profession to check. | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_viaf_id(gnd_id: str) -> str: | |
""" | |
Get the VIAF ID for a given GND ID. | |
Args: gnd_id (str): GND ID of the entity. | |
Returns: str: VIAF ID of the entity. | |
""" | |
try: | |
request = requests.get( | |
"https://lobid.org/gnd/" + gnd_id + ".json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compress_ttl(file_name): | |
""" | |
Compress the ttl file. | |
returns: compressed ttl file. | |
""" | |
# compress the ttl file | |
try: | |
with open(file_name, 'rb') as f_in: | |
with gzip.open(file_name + '.gz', 'wb') as f_out: | |
shutil.copyfileobj(f_in, f_out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_hash_UUID(name): | |
""" | |
Generate a UUID based on the hashed string | |
Args: name (str): Name of the entity. | |
Returns: str: UUID of the entity. | |
""" | |
# Hash the string using a hashing algorithm (e.g., SHA-256) | |
hashed_string = hashlib.sha256(name.encode()).hexdigest() | |
# Generate a UUID based on the hashed string | |
uuid_from_hash = uuid.uuid5(uuid.NAMESPACE_OID, hashed_string) |