<commit_before>/* Connects Fidus Writer citation system with citeproc */
import {CSLExporter} from "biblatex-csl-converter"

export class citeprocSys {
    constructor(bibDB, citationLocales) {
        this.bibDB = bibDB
        this.citationLocales = citationLocales
        this.abbreviations = {
            "default": {}
        }
        this.abbrevsname = "default"
        // We cache values retrieved once.
        this.items = {}
        this.missingItems = []

    }

    retrieveItem(id) {
        if (!this.items[id]) {
            if (this.bibDB.db[id]) {
                let cslGetter = new CSLExporter(this.bibDB.db, [id])
                Object.assign(this.items, cslGetter.output)
                console.log(this.items)
            } else {
                this.missingItems.push(id)
                this.items[id] = {author:{literal:''}, type: 'article', id}
            }
        }
        return this.items[id]
    }

    retrieveLocale(lang) {
        let langCode = lang.replace('-','')
        let locale = this.citationLocales.find(locale => locale.language_code===langCode)
        if (!locale) {
            locale = this.citationLocales.find(locale => locale.language_code==='enUS')
        }
        if (locale) {
            return locale.contents
        } else {
          console.error(`Missing locale: ${lang}`)
        }


    }
<commit_msg>remove console.log<commit_after>/* Connects Fidus Writer citation system with citeproc */
import {CSLExporter} from "biblatex-csl-converter"

export class citeprocSys {
    constructor(bibDB, citationLocales) {
        this.bibDB = bibDB
        this.citationLocales = citationLocales
        this.abbreviations = {
            "default": {}
        }
        this.abbrevsname = "default"
        // We cache values retrieved once.
        this.items = {}
        this.missingItems = []

    }

    retrieveItem(id) {
        if (!this.items[id]) {
            if (this.bibDB.db[id]) {
                let cslGetter = new CSLExporter(this.bibDB.db, [id])
                Object.assign(this.items, cslGetter.output)
            } else {
                this.missingItems.push(id)
                this.items[id] = {author:{literal:''}, type: 'article', id}
            }
        }
        return this.items[id]
    }

    retrieveLocale(lang) {
        let langCode = lang.replace('-','')
        let locale = this.citationLocales.find(locale => locale.language_code===langCode)
        if (!locale) {
            locale = this.citationLocales.find(locale => locale.language_code==='enUS')
        }
        if (locale) {
            return locale.contents
        } else {
          console.error(`Missing locale: ${lang}`)
        }


    }

{'fraction_non_alphanumeric': 0.12403386087596614, 'fraction_numerical': 0.0, 'mean_word_length': 1.837160751565762, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7054179', 'n_tokens_mistral': 833, 'n_tokens_neox': 791, 'n_words': 150}