diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index a5a303cb..abe800eb 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -115,14 +115,50 @@ socket.on('init_corpus_analysis', function(msg) { if (msg === 'Ready') {loadingModal.close();} }); + function decodeResults(resultsByteArray) { + console.log(resultsByteArray); + var decompressedData = pako.inflate(resultsByteArray); // decompresses the recieved ArrayBuffer holding the compressed Byte data + console.log(decompressedData); + utf8decoder = new TextDecoder(); // default is utf-8 + var decodedStrData = utf8decoder.decode(decompressedData); // decodes the decompressed Uint8Array as an utf-8 string + console.log(decodedStrData); + return decodedStrData + } + function getResultInfos(matchObject) { + for (var key in matchObject) { + var token = matchObject[key]; + for (var key in token) { + infos += token[key]['word'] + ' '; + } + var infos = infos; + } + return infos + } socket.on('query', function(results) { - queryResultsElement.innerHTML = ''; - console.log(results) - var decoder = new TextDecoder().decode(results) - console.log(results) - for (let key in results) { - console.log(results[key]); - queryResultsElement.innerHTML += '
' + results[key]['match_cpos_list'] + '
'; + console.log(results); + var decodedJSONStr = decodeResults(results); + var results = JSON.parse(decodedJSONStr); + if (results === null){ + M.toast({html: 'Query has no results!'}); + } + else { + console.log(results); + html_txt = 'Left context | Match | Right Context |
---|---|---|
' + l_text + ' | ' + m_text + ' | ' + r_text + ' |