Skip to content

Commit

Permalink
APA
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Feb 14, 2024
1 parent 867cc0d commit ae97c90
Show file tree
Hide file tree
Showing 4 changed files with 13,421 additions and 284 deletions.
31 changes: 31 additions & 0 deletions modify-csl-json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json


file_path = "tests/bbt/bib/biblatex-apa-test-references.json"

with open(file_path) as f:
items = json.load(f)


for item in items:
if item["type"] == "article-journal" and "container-title-short" in item:
item["journalAbbreviation"] = item["container-title-short"]
item.pop("container-title-short")

if "journalAbbreviation" in item:
journalAbbreviation = item["journalAbbreviation"]
container_title = item["container-title"]

full_words = container_title.split()
abbrev_words = []
for word in journalAbbreviation.split():
word = word.replace("..", ".")
if word in full_words or word.endswith("."):
abbrev_words.append(word)
else:
abbrev_words.append(word + ".")
item["journalAbbreviation"] = " ".join(abbrev_words)


with open(file_path, "w") as f:
json.dump(items, f, ensure_ascii=False, indent="\t")
Loading

0 comments on commit ae97c90

Please sign in to comment.