mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Add neww result recieving
This commit is contained in:
parent
94e71b41df
commit
ac14bedc62
@ -59,9 +59,9 @@ class Subcorpus:
|
||||
for match_start, match_end in match_boundaries:
|
||||
left_start = max(0, match_start - context)
|
||||
right_end = min(self.parent_corpus.size, (match_end + 1 + context))
|
||||
matches.append({'left': list(range(left_start, match_start)),
|
||||
matches.append({'lc': list(range(left_start, match_start)),
|
||||
'hit': list(range(match_start, match_end + 1)),
|
||||
'right': list(range(match_end + 1, right_end))})
|
||||
'rc': list(range(match_end + 1, right_end))})
|
||||
cpos_list = []
|
||||
for match in matches:
|
||||
cpos_list += match['lc'] + match['hit'] + match['rc']
|
||||
|
@ -50,14 +50,21 @@ def corpus_analysis_query(query):
|
||||
context = 100
|
||||
progress = 0
|
||||
while chunk_start <= results.size:
|
||||
logger.warning("test")
|
||||
chunk = results.dump_values(context=context,
|
||||
first_result=chunk_start,
|
||||
num_results=chunk_size)
|
||||
progress = ((chunk_start + chunk_size) / results.size) * 100
|
||||
progress = min(100, int(math.ceil(progress)))
|
||||
logger.warning(chunk)
|
||||
if (results.size == 0):
|
||||
progress = 100
|
||||
else:
|
||||
progress = ((chunk_start + chunk_size) / results.size) * 100
|
||||
progress = min(100, int(math.ceil(progress)))
|
||||
socketio.emit('corpus_analysis_query',
|
||||
{'chunk': chunk, 'progress': progress,
|
||||
'num_matches_total': results.size},
|
||||
{'chunk': chunk,
|
||||
'progress': progress,
|
||||
'num_matches_total': results.size,
|
||||
'code': 0},
|
||||
room=request.sid)
|
||||
chunk_start += chunk_size
|
||||
|
||||
|
@ -32,13 +32,13 @@ function sendQuery(event) {
|
||||
// full results object declaration, global declaration!
|
||||
// will always be reset if a query is sent, so that only the chunks of the
|
||||
// current query will be saved in it
|
||||
result = {};
|
||||
result["matches"] = [];
|
||||
result["cpos_lookup"] = {};
|
||||
result["text_lookup"] = {};
|
||||
result["loaded_match_count"] = 0;
|
||||
result["match_count"] = 0;
|
||||
result["query"] = "";
|
||||
result = {}; // full JSON object holding match results
|
||||
result["matches"] = []; // list of all amtches with lc and rc
|
||||
result["cpos_lookup"] = {}; // object contains all cpos as key value pair
|
||||
result["text_lookup"] = {}; // same as above for all text ids
|
||||
result["loaded_match_count"] = 0; // how many matches have been recieved
|
||||
result["num_matches_total"]; // how many should have been recieved/total nr
|
||||
result["query"] = ""; // the query as a string
|
||||
// some hiding/showing for loading animation
|
||||
queryLoadingElement.classList.remove("hide");
|
||||
queryResultsTableElement.classList.add("hide");
|
||||
@ -97,7 +97,7 @@ function recieveResults(response) {
|
||||
return; // no further code execution of this code block
|
||||
}
|
||||
// logs the current recieved chunk
|
||||
chunk = response["result"];
|
||||
chunk = response["chunk"];
|
||||
//chunk = response["chunk"];
|
||||
console.log("### corpus_analysis chunk ###");
|
||||
console.log(chunk);
|
||||
@ -107,7 +107,7 @@ function recieveResults(response) {
|
||||
result["matches"].push(...chunk["matches"]);
|
||||
Object.assign(result["cpos_lookup"], chunk["cpos_lookup"]);
|
||||
Object.assign(result["text_lookup"], chunk["text_lookup"]);
|
||||
result["match_count"] = chunk["match_count"];
|
||||
result["num_matches_total"] = response["num_matches_total"];
|
||||
//result["match_count"] = response["match_count"];
|
||||
console.log("Before Current match count", result["loaded_match_count"]);
|
||||
queryData = getQueryData(queryFormElement);
|
||||
@ -120,6 +120,7 @@ function recieveResults(response) {
|
||||
queryResultsElement.innerHTML = "";
|
||||
|
||||
// check if query has any results
|
||||
console.log("CHUNKLENGTH", chunk["matches"].length);
|
||||
if (chunk["matches"].length === 0) {
|
||||
queryResultsTableElement.classList.add("hide");
|
||||
nopaque.toast("No results for this query!");
|
||||
@ -144,13 +145,13 @@ function recieveResults(response) {
|
||||
result["loaded_match_count"] += Object.keys(chunk["matches"]).length;
|
||||
console.log("After current match count", result["loaded_match_count"]);
|
||||
queryResultsMetadataElement = document.getElementById("query-results-metadata");
|
||||
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${chunk["match_count"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["match_count"]} matches in ${countCorpusFiles} corpus files have been loaded.</p><p><i class="material-icons" id="tooltip-info">help</i>The Server is still sending your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.</p>`;
|
||||
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${result["num_matches_total"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["num_matches_total"]} matches in ${countCorpusFiles} corpus files have been loaded.</p><p><i class="material-icons" id="tooltip-info">help</i>The Server is still sending your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.</p>`;
|
||||
queryResultsInteractionElement = document.getElementById("interaction-elements");
|
||||
queryResultsInteractionElement.appendChild(exportQueryResultsElement);
|
||||
queryResultsHeadElement = document.getElementById("query-results-head");
|
||||
queryResultsHeadElement.classList.remove("hide");
|
||||
queryStatus = result["loaded_match_count"] / result["match_count"] * 100;
|
||||
console.log(queryStatus);
|
||||
queryStatus = response["progress"];
|
||||
console.log("QUERY STATUS:", queryStatus);
|
||||
queryResultsDeterminateElement.style["width"] = `${queryStatus}%`;
|
||||
console.log(queryResultsDeterminateElement.style["width"]);
|
||||
|
||||
@ -160,7 +161,7 @@ function recieveResults(response) {
|
||||
queryFinished = true; // global declaration to set downlaod button and inspects buttons back to disabled for new queries
|
||||
queryResultsDeterminateElement.parentNode.parentNode.classList.add("hide");
|
||||
exportQueryResultsElement.classList.remove("disabled");
|
||||
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${chunk["match_count"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["match_count"]} matches in ${countCorpusFiles} corpus files have been loaded.<i class="material-icons">check_circle</i></p>`;
|
||||
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${result["num_matches_total"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["num_matches_total"]} matches in ${countCorpusFiles} corpus files have been loaded.<i class="material-icons">check_circle</i></p>`;
|
||||
activateInspect();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user