CJVT updates August and September 2026
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user