Add match_count for texts in results.data and results.fullResultsData.

This commit is contained in:
Stephan Porada 2020-10-02 15:32:03 +02:00
parent 370a002af3
commit f195b72ebd
5 changed files with 14 additions and 88 deletions

View File

@ -177,7 +177,6 @@ def corpus_analysis_get_match_with_full_context(payload):
i = 0 i = 0
# Send data one match at a time. # Send data one match at a time.
for index, f_cpos, l_cpos in zip(data_indexes, first_cpos, last_cpos): for index, f_cpos, l_cpos in zip(data_indexes, first_cpos, last_cpos):
logger.warning(index)
i += 1 i += 1
tmp_match = s.export(f_cpos, l_cpos, context=10) tmp_match = s.export(f_cpos, l_cpos, context=10)
payload['matches'].append(tmp_match['matches'][0]) payload['matches'].append(tmp_match['matches'][0])

View File

@ -200,6 +200,12 @@ class Client {
results[objectKey].match_count = matches.length; results[objectKey].match_count = matches.length;
results[objectKey].cpos_ranges = results.data.cpos_ranges; results[objectKey].cpos_ranges = results.data.cpos_ranges;
results[objectKey].fullContext = false; results[objectKey].fullContext = false;
if (objectKey === 'subResultsData') {
// Remove match_count from texts, because they are useless in sub results
for (let [key, value] of Object.entries(results[objectKey].text_lookup)) {
delete results[objectKey].text_lookup[key].match_count;
}
}
console.info('Results data without context has been saved.', results); console.info('Results data without context has been saved.', results);
this.isBusy = false; this.isBusy = false;
this.notifyView('results-data-recieved', {type: resultsType, this.notifyView('results-data-recieved', {type: resultsType,

View File

@ -111,8 +111,8 @@ function saveResultsData() {
} }
// Save incoming data. Data is incoming one match at a time. // Save incoming data. Data is incoming one match at a time.
results[objectKey].matches.push(...payload.matches); results[objectKey].matches.push(...payload.matches);
results[objectKey].addData(payload.cpos_lookup, "cpos_lookup"); results[objectKey].addData(payload.cpos_lookup, 'cpos_lookup');
results[objectKey].addData(payload.text_lookup, "text_lookup"); results[objectKey].addData(payload.text_lookup, 'text_lookup');
results[objectKey].addData(results.metaData); results[objectKey].addData(results.metaData);
results[objectKey].query = results.data.query; results[objectKey].query = results.data.query;
results[objectKey].corpus_type = type; results[objectKey].corpus_type = type;
@ -125,6 +125,10 @@ function saveResultsData() {
progress: payload.progress}) progress: payload.progress})
client.isBusy = false; client.isBusy = false;
if (payload.progress === 100) { if (payload.progress === 100) {
if (objectKey === 'fullResultsData') {
// Get match count per text from results.data only for fullResultsData
results[objectKey].text_lookup = results.data.text_lookup;
}
client.notifyView('results-data-recieved', {type: type, client.notifyView('results-data-recieved', {type: type,
results: results, results: results,
fullContext: true}); fullContext: true});

View File

@ -138,8 +138,8 @@ function createFullResults(resultsList, results) {
function createSubResults(resultsList, results) { function createSubResults(resultsList, results) {
resultsList.subResultsCreate.onclick = (event) => { resultsList.subResultsCreate.onclick = (event) => {
let dataIndexes = []; let dataIndexes = [];
resultsList.addToSubResultsIdsToShow.forEach((id) => { Object.keys(resultsList.subResultsIndexes).forEach((id) => {
dataIndexes.push(id - 1); dataIndexes.push(id);
}); });
resultsList.subResultsCreate.querySelector('i').classList.toggle('hide'); resultsList.subResultsCreate.querySelector('i').classList.toggle('hide');
resultsList.subResultsCreate.innerText = 'Creating...'; resultsList.subResultsCreate.innerText = 'Creating...';

View File

@ -1,83 +0,0 @@
/**
* HTML for showing infos about the current query or result. Also gives
* the user the abiltiy to access the meta data for the current query or
* result.
*/
const template = document.createElement('template');
template.innerHTML = `
<link rel="stylesheet" href="../../static/fonts/Material_design_icons/material-icons.css">
<link rel="stylesheet" href="../../static/css/Materialize/materialize.min.css">
<link rel="stylesheet" href="../../static/css/nopaque.css">
<div class="col">
<h6 style="margin-top: 0px;">Infos</h6>
<div class="divider" style="margin-bottom: 10px;"></div>
<div class="row">
<div class="col s12">
<button id="show-metadata"
class="waves-effect
waves-light
btn-flat
flat-interaction"
type="submit">Corpus Metadata
<i class="material-icons left">info_outline</i>
</button>
</div>
<div class="col s12">
<p>
<slot name="received-match-count">
0
</slot> of
<slot name="match-count">(to be determined)</slot>
matches loaded.
<br>
Matches occured in
<slot name="text-lookup-count">(to be determined)</slot>
corpus files:
<br>
<slot name=text-titles>(to be determined)</slot>
</p>
<p id="query-results-user-feedback">
<i class="material-icons">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>
<div class="progress" id="query-progress-bar">
<div class="determinate"></div>
</div>
</div>
</div>
</div>
`;
class InfoMenu extends HTMLElement {
constructor() {
super();
this.appendChild(template.content.cloneNode(true));
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
// methods that will be used in connectedCallback on eventListeners
showMetadata() {
console.log('Show metadata somehow');
}
connectedCallback() {
const showMetadataBtn = this.querySelector('#show-metadata');
showMetadataBtn.addEventListener('click', () => this.showMetadata());
}
disconnectedCallback() {
const showMetadataBtn = this.querySelector('#show-metadata');
showMetadataBtn.removeEventListener();
}
}
window.customElements.define('info-menu', InfoMenu);
export { InfoMenu };