Skip to content

Commit

Permalink
updated +- to pr480
Browse files Browse the repository at this point in the history
  • Loading branch information
huberrob committed Sep 25, 2024
1 parent b22f08f commit 196336a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions fuji_server/helper/linked_vocab_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
#
# SPDX-License-Identifier: MIT

import json
import os
import logging
import re
from pathlib import Path

from tldextract import extract

import yaml

logger = logging.getLogger(__name__)


class LinkedVocabHelper:
fuji_server_dir = os.path.dirname(os.path.dirname(__file__)) # project_root
fuji_server_dir = Path(__file__).parent.parent # project_root
linked_vocabs_dir = fuji_server_dir / "data/linked_vocabs"

def __init__(self, linked_vocab_index={}):
self.linked_vocab_index = linked_vocab_index
Expand All @@ -20,16 +25,13 @@ def __init__(self, linked_vocab_index={}):
self.ignore_domain = ["orcid.org", "doi.org", "ror.org", "zenodo.org", "isni.org", "github.com", "arxiv.org"]

def set_linked_vocab_dict(self):
print("Setting up the vocab dict.........................")
logger.info("Setting up the vocab dict.........................")
# a new implementation based on bioportal etc..

for ont_reg_file in os.listdir(os.path.join(self.fuji_server_dir, "data", "linked_vocabs")):
if ont_reg_file.endswith(".json"): # and ont_reg_file not in ['fuji_ontologies.json', 'bioregistry.json']:
with open(
os.path.join(self.fuji_server_dir, "data", "linked_vocabs", ont_reg_file), encoding="utf-8"
) as reg_file:
reg_ontologies = json.load(reg_file)
self.linked_vocab_dict.update(reg_ontologies)
for ont_reg_file in self.linked_vocabs_dir.glob("*.yaml"):
with open(ont_reg_file, encoding="utf-8") as reg_file:
reg_ontologies = yaml.safe_load(reg_file)
self.linked_vocab_dict.update(reg_ontologies)

def split_iri(self, iri):
ret = {}
Expand Down

0 comments on commit 196336a

Please sign in to comment.