mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Add match nr
This commit is contained in:
		@@ -93,11 +93,9 @@ RessourceList.options = {
 | 
				
			|||||||
class ResultList extends List {
 | 
					class ResultList extends List {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  createResultRowElement(item, chunk) {
 | 
					  createResultRowElement(item, chunk) {
 | 
				
			||||||
    let values, cpos, token, matchRowElement, lcCellElement, hitCellElement, rcCellElement, textTitlesCellElement;
 | 
					    let values, cpos, token, matchRowElement, lcCellElement, hitCellElement, rcCellElement, textTitlesCellElement, matchNrElement;
 | 
				
			||||||
    // gather values from item
 | 
					    // gather values from item
 | 
				
			||||||
    values = item.values();
 | 
					    values = item.values();
 | 
				
			||||||
    console.log("CHONK");
 | 
					 | 
				
			||||||
    console.log(chunk);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // get infos for full match row
 | 
					    // get infos for full match row
 | 
				
			||||||
    matchRowElement = document.createElement("tr");
 | 
					    matchRowElement = document.createElement("tr");
 | 
				
			||||||
@@ -116,6 +114,8 @@ class ResultList extends List {
 | 
				
			|||||||
    hitCellElement.classList.add("match-hit");
 | 
					    hitCellElement.classList.add("match-hit");
 | 
				
			||||||
    textTitlesCellElement = document.createElement("td");
 | 
					    textTitlesCellElement = document.createElement("td");
 | 
				
			||||||
    textTitlesCellElement.classList.add("titles");
 | 
					    textTitlesCellElement.classList.add("titles");
 | 
				
			||||||
 | 
					    matchNrElement = document.createElement("td");
 | 
				
			||||||
 | 
					    matchNrElement.classList.add("match-nr");
 | 
				
			||||||
    matchRowElement.appendChild(hitCellElement);
 | 
					    matchRowElement.appendChild(hitCellElement);
 | 
				
			||||||
    for (cpos of values["hit"]) {
 | 
					    for (cpos of values["hit"]) {
 | 
				
			||||||
      token = chunk["cpos_lookup"][cpos];
 | 
					      token = chunk["cpos_lookup"][cpos];
 | 
				
			||||||
@@ -132,6 +132,8 @@ class ResultList extends List {
 | 
				
			|||||||
    hitCellElement.appendChild(inspectBtn);
 | 
					    hitCellElement.appendChild(inspectBtn);
 | 
				
			||||||
    textTitlesCellElement.innerText = [...textTitles].join(", ");
 | 
					    textTitlesCellElement.innerText = [...textTitles].join(", ");
 | 
				
			||||||
    matchRowElement.insertAdjacentHTML("afterbegin", textTitlesCellElement.outerHTML);
 | 
					    matchRowElement.insertAdjacentHTML("afterbegin", textTitlesCellElement.outerHTML);
 | 
				
			||||||
 | 
					    matchNrElement.innerText = values["index"] + 1;
 | 
				
			||||||
 | 
					    matchRowElement.insertAdjacentHTML("afterbegin", matchNrElement.outerHTML);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // get infos for right context of match
 | 
					    // get infos for right context of match
 | 
				
			||||||
    rcCellElement = document.createElement("td");
 | 
					    rcCellElement = document.createElement("td");
 | 
				
			||||||
@@ -141,7 +143,6 @@ class ResultList extends List {
 | 
				
			|||||||
      token = chunk["cpos_lookup"][cpos];
 | 
					      token = chunk["cpos_lookup"][cpos];
 | 
				
			||||||
      rcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
 | 
					      rcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    console.log(matchRowElement);
 | 
					 | 
				
			||||||
    return matchRowElement
 | 
					    return matchRowElement
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,7 +163,8 @@
 | 
				
			|||||||
        <table class="responsive-table highlight">
 | 
					        <table class="responsive-table highlight">
 | 
				
			||||||
          <thead>
 | 
					          <thead>
 | 
				
			||||||
            <tr>
 | 
					            <tr>
 | 
				
			||||||
              <th style="width: 5%">Title</th>
 | 
					              <th style="width: 2%">Nr.</th>
 | 
				
			||||||
 | 
					              <th style="width: 3%">Title</th>
 | 
				
			||||||
              <th style="width: 25%">Left context</th>
 | 
					              <th style="width: 25%">Left context</th>
 | 
				
			||||||
              <th style="width: 45%">Match</th>
 | 
					              <th style="width: 45%">Match</th>
 | 
				
			||||||
              <th style="width: 25%">Right Context</th>
 | 
					              <th style="width: 25%">Right Context</th>
 | 
				
			||||||
@@ -313,6 +314,7 @@
 | 
				
			|||||||
      valueNames: ["titles", "lc", "hit", "rc", {data: ["index"]}],
 | 
					      valueNames: ["titles", "lc", "hit", "rc", {data: ["index"]}],
 | 
				
			||||||
      item: `<span class="hidden"></span>`};
 | 
					      item: `<span class="hidden"></span>`};
 | 
				
			||||||
      resultList = new ResultList('result-list', options);
 | 
					      resultList = new ResultList('result-list', options);
 | 
				
			||||||
 | 
					      resultList.clear(); // empty list for new query
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -336,6 +338,7 @@
 | 
				
			|||||||
      return; // no further code execution of this code block
 | 
					      return; // no further code execution of this code block
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // logs the current recieved chunk
 | 
					    // logs the current recieved chunk
 | 
				
			||||||
 | 
					    chunk = {};
 | 
				
			||||||
    chunk = response["result"];
 | 
					    chunk = response["result"];
 | 
				
			||||||
    console.log("### corpus_analysis chunk ###");
 | 
					    console.log("### corpus_analysis chunk ###");
 | 
				
			||||||
    console.log(chunk);
 | 
					    console.log(chunk);
 | 
				
			||||||
@@ -363,7 +366,6 @@
 | 
				
			|||||||
    // List building/appending the chunks when query had results
 | 
					    // List building/appending the chunks when query had results
 | 
				
			||||||
    // write metadata query information into HTML elements
 | 
					    // write metadata query information into HTML elements
 | 
				
			||||||
    // like nr. of all matches in how many files etc.
 | 
					    // like nr. of all matches in how many files etc.
 | 
				
			||||||
    // TODO: count_corpus_files müssen aus full results genommen werden. Ist am Ende richtig aber dazwischen zählt es hoch
 | 
					 | 
				
			||||||
    match_count = chunk["match_count"];
 | 
					    match_count = chunk["match_count"];
 | 
				
			||||||
    let count_corpus_files = Object.keys(result["text_lookup"]).length;
 | 
					    let count_corpus_files = Object.keys(result["text_lookup"]).length;
 | 
				
			||||||
    queryResultsMetadataElement.innerHTML = chunk["match_count"] + " matches in " + count_corpus_files + " corpus files.";
 | 
					    queryResultsMetadataElement.innerHTML = chunk["match_count"] + " matches in " + count_corpus_files + " corpus files.";
 | 
				
			||||||
@@ -406,7 +408,7 @@
 | 
				
			|||||||
    var currentTime = today.getUTCHours() + ":" + today.getUTCMinutes() + ":" + today.getUTCSeconds();
 | 
					    var currentTime = today.getUTCHours() + ":" + today.getUTCMinutes() + ":" + today.getUTCSeconds();
 | 
				
			||||||
    var safeFilename = message['query'].replace(/[^a-z0-9_-]/gi, "_");
 | 
					    var safeFilename = message['query'].replace(/[^a-z0-9_-]/gi, "_");
 | 
				
			||||||
    var resultFilename = "UTC-" + currentDate + "_" + currentTime + "_" + safeFilename + ".json";
 | 
					    var resultFilename = "UTC-" + currentDate + "_" + currentTime + "_" + safeFilename + ".json";
 | 
				
			||||||
    // get a where download is served
 | 
					    // get <a> where download is served
 | 
				
			||||||
    var downloadResults = document.getElementById("download-results");
 | 
					    var downloadResults = document.getElementById("download-results");
 | 
				
			||||||
    // stringify JSON object for json download
 | 
					    // stringify JSON object for json download
 | 
				
			||||||
    var dataStr = JSON.stringify(message, undefined, 2);
 | 
					    var dataStr = JSON.stringify(message, undefined, 2);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user