CJVT updates August and September 2026

This commit is contained in:
Luka Romih
2026-10-01 00:49:26 +02:00
parent fd02e25719
commit 83f73aeb58
135 changed files with 6146 additions and 1970 deletions
@@ -193,7 +193,10 @@ function handleEntryXml(
) {
debug(`TOTAL ENTRIES: ${progress.totalCount}`)
debug(`VALID ENTRIES: ${progress.validCount}`)
resolve()
resolve({
totalCount: progress.totalCount,
validCount: progress.validCount
})
}
}
}
@@ -0,0 +1,26 @@
const { readFile } = require('fs/promises')
const { insertSuggestionEntry } = require('./index')
// Import given JSON export of extraction term candidates into given dictionary.
exports.readJsonFileIntoDb = async (
userId,
dictionaryId,
importFilePath,
dbClient
) => {
const fileContent = await readFile(importFilePath, 'utf8')
const { terminoloski_kandidati: termCandidates } = JSON.parse(fileContent)
if (!Array.isArray(termCandidates)) {
throw Error('Invalid term candidates JSON: terminoloski_kandidati is not an array')
}
for (const {
kanonicnaoblika: term,
definicija: other
} of termCandidates) {
await insertSuggestionEntry(dbClient, dictionaryId, userId, term, other)
}
return { totalCount: termCandidates.length, validCount: 0 }
}
@@ -1,4 +1,5 @@
const xss = require('xss')
const db = require('../../db')
const { removeHtmlTags } = require('../../helpers')
const { searchEngineClient, ENTRY_INDEX } = require('../../search-engine')
const { DATA_FILES_PATH } = require('../../../config/settings')
@@ -353,3 +354,35 @@ exports.sanitizeField = {
return sanitize(string, markupFilter.mixedOther)
}
}
// Insert a single 'suggestion' status entry (as produced by extraction term
// candidates, whether imported directly or from a JSON export of them).
exports.insertSuggestionEntry = async (dbClient, dictionaryId, userId, term, other) => {
term = term ? exports.sanitizeField.toText(term) : null
other = other ? exports.sanitizeField.toText(other) : null
const values = [
dictionaryId,
false,
'suggestion',
term || null,
userId,
null,
null,
null,
null,
[],
null,
null,
null,
[],
other || null,
[],
null,
null,
null
]
const text = `SELECT entry_new (${db.genParamStr(values)})`
await dbClient.query(text, values)
}