Skip to content

Instantly share code, notes, and snippets.

View bsesic's full-sized avatar
🏠
Working from home

Benjamin Schnabel bsesic

🏠
Working from home
View GitHub Profile
@bsesic
bsesic / generate_hash_UUID.py
Last active April 18, 2024 19:39
Generate Hash UUID
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)
@bsesic
bsesic / compress_ttl.py
Last active April 18, 2024 19:37
zip ttl file
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)
@bsesic
bsesic / get_viaf_id.py
Created December 1, 2023 10:35
Get VIAF ID
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"
@bsesic
bsesic / check_profession.py
Last active April 18, 2024 19:45
check profession
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:
@bsesic
bsesic / get_gnd_id.py
Last active April 18, 2024 19:14
Get GND ID
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: