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