Skip to content

Commit

Permalink
Fix: Make sure add-ref adds lang as a property of the lemma
Browse files Browse the repository at this point in the history
It was previously adding the lang property to the reference.
  • Loading branch information
johannesdewit committed Feb 11, 2024
1 parent cff9322 commit 4efd86b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions index/heidegger-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,11 @@ Pindar:
- start: 108
- start: 110
type: p
Pizza:
lang: ita
references:
zz:
- start: 1
Plato:
metadata:
urn: urn:cts:greekLit:tlg0059
Expand Down
14 changes: 6 additions & 8 deletions index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def add_ref(
if isinstance(ref, list):
# Allow ref to be a list, call add_ref for each item and terminate function
for r in ref:
add_ref(lemma, work, r, lemma_type, ref_type, betacode)
add_ref(lemma, work, r, lemma_type, ref_type, lang, betacode)
return

try:
Expand All @@ -55,10 +55,6 @@ def add_ref(
m = REF_REGEX.search(str(ref).strip())
if not m and ref != "whole":
raise click.BadParameter(f"Reference '{ref}' is not recognized")

# Validation: lang
if lang:
validate_iso639_3_lang(lang)

if betacode:
lemma = beta_to_uni(lemma)
Expand All @@ -80,9 +76,6 @@ def add_ref(
if ref_type:
ref_dict["type"] = ref_type

if lang:
ref_dict["lang"] = lang

# Determine whether that lemma is already in the index
try:
lemma_entry = index[lemma]
Expand Down Expand Up @@ -150,6 +143,11 @@ def add_ref(

lemma_entry["references"] = refs

# Validation: lang
if lang:
validate_iso639_3_lang(lang)
lemma_entry["lang"] = lang

index[lemma] = lemma_entry

with open(INDEX_FILE, "w") as f:
Expand Down

0 comments on commit 4efd86b

Please sign in to comment.