...
Code Block |
---|
|
/* O/P format: "gemini(brand),100 grams(quantity) */
let entities = _.get(annotations, "[0].value.annotations.entities", _.get(annotations, "annotations.entities", []))
if (entities.length > 0) {
entities.sort((a,b) => a.start_offset - b.start_offset)
var requiredOp = entities.reduce((accumulator, currentValue) => accumulator + `${currentValue.text}(${currentValue.entity_type}),`, "")
if(requiredOp[requiredOp.length - 1] == ","){
requiredOp = requiredOp.slice(0, requiredOp.length-1)
}
this.changeFormValue("tagged_output", requiredOp) |
11. Convert SRT to Taskmonk JSON and load pre-annotation for audio transcription.
Code Block |
---|
function time2sec(dateTime) {
let ms = dateTime.split(',')[1]
let hh = dateTime.split(':')[0]
let mm = dateTime.split(':')[1]
let ss = dateTime.split(':')[2].split(',')[0]
let ts = (parseInt(hh) * 3600) + (parseInt(mm) * 60) + parseInt(ss) + (parseInt(ms) / 1000)
return ts
}
let finalValues = []
let inputArray = inputValues["TEXT"].split(/\n\s*\n/)
let i=0
while(i < inputArray.length) {
i = i + 1
if(inputArray[i]) {
let startTime = time2sec(inputArray[i].split('\n')[1].split('-->')[0])
let endTime = time2sec(inputArray[i].split('\n')[1].split('-->')[1])
finalValues.push( {
"id": i,
"curTime": 0,
"endTime": endTime,
"startTime": startTime ,
"UIstartTime": startTime,
"UIendTime": endTime,
"split": 0,
"audiourl": "",
"pos": 0,
"transliterationData": inputArray[i].split('\n')[2].split(" ").map(w => ({
"word": w,
"tags": [],
"languageTag": "",
"editedText": ""
}))
})
}
}
let x = JSON.stringify(finalValues)
this.updateAnnotations(x) |