|
|
|
@ -33,13 +33,28 @@ function showArticle(article) {
|
|
|
|
|
document.getElementById('title').innerHTML = article.title
|
|
|
|
|
document.getElementById('link').innerHTML = `[ <a href='${article.url}'>Original Article</a> ]`
|
|
|
|
|
let output = ''
|
|
|
|
|
let spaceBefore = false
|
|
|
|
|
const noSpaceBeforeTags = new Set(['.', ',', ')', ';', ':', '!', '?', "''", 'POS'])
|
|
|
|
|
const noSpaceBeforeTokens = new Set(["n't", ']'])
|
|
|
|
|
const noSpaceAfterTags = new Set(['(', '``'])
|
|
|
|
|
const noSpaceAfterTokens = new Set(['['])
|
|
|
|
|
article.tokens.forEach(function(token) {
|
|
|
|
|
let adlib_input = document.getElementById(`token_${token.id}`);
|
|
|
|
|
if(adlib_input && adlib_input.value) {
|
|
|
|
|
output += `<strong>${adlib_input.value}</strong> `
|
|
|
|
|
|
|
|
|
|
if(spaceBefore && !noSpaceBeforeTags.has(token.tag) && !noSpaceBeforeTokens.has(token.token)) {
|
|
|
|
|
output += ' '
|
|
|
|
|
}
|
|
|
|
|
spaceBefore = true
|
|
|
|
|
|
|
|
|
|
let adlibInput = document.getElementById(`token_${token.id}`);
|
|
|
|
|
if(adlibInput && adlibInput.value) {
|
|
|
|
|
output += `<strong>${adlibInput.value}</strong>`
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
output += `${token.token} `
|
|
|
|
|
output += `${token.token}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(noSpaceAfterTags.has(token.tag) || noSpaceAfterTokens.has(token.token)) {
|
|
|
|
|
spaceBefore = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
document.getElementById('summary').innerHTML = output
|
|
|
|
|