Skip to content

Commit

Permalink
Migrate to pyoxigraph 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Sep 23, 2024
1 parent bb3710a commit 2def628
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/proficiency/extract_dbnary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
from shutil import which

from pyoxigraph import Store
from pyoxigraph import RdfFormat, Store

from .database import create_indexes_then_close, init_db, wiktionary_db_path
from .util import (
Expand Down Expand Up @@ -238,13 +238,15 @@ def insert_senses(
def init_oxigraph_store(gloss_lang: str) -> tuple[Store, bool]:
gloss_lang = convert_lang_code(gloss_lang)
store = Store(f"build/ttl/{gloss_lang}_store")
store.bulk_load(f"build/ttl/{gloss_lang}_dbnary_ontolex.ttl", "text/turtle")
store.bulk_load(
path=f"build/ttl/{gloss_lang}_dbnary_ontolex.ttl", format=RdfFormat.TURTLE
)
exolex_path = Path(f"build/ttl/{gloss_lang}_dbnary_exolex_ontolex.ttl")
if exolex_path.exists():
store.bulk_load(str(exolex_path), "text/turtle")
store.bulk_load(path=exolex_path, format=RdfFormat.TURTLE)
morphology_path = Path(f"build/ttl/{gloss_lang}_dbnary_morphology.ttl")
if morphology_path.exists():
store.bulk_load(str(morphology_path), "text/turtle")
store.bulk_load(path=morphology_path, format=RdfFormat.TURTLE)
store.optimize()

return store, morphology_path.exists()
Expand Down Expand Up @@ -292,7 +294,9 @@ def convert_lang_code(code: str) -> str:
gloss_lang = "fr"
store = Store()
# store.bulk_load(f"ttl/test.ttl", "text/turtle")
store.bulk_load(f"build/ttl/{gloss_lang}_dbnary_ontolex.ttl", "text/turtle")
store.bulk_load(
path=f"build/ttl/{gloss_lang}_dbnary_ontolex.ttl", format=RdfFormat.TURTLE
)
# store.bulk_load(f"ttl/{gloss_lang}_dbnary_morphology.ttl", "text/turtle")
# store.bulk_load(f"ttl/{gloss_lang}_dbnary_exolex_ontolex.ttl", "text/turtle")
store.optimize()
Expand Down

0 comments on commit 2def628

Please sign in to comment.