mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Continue new list building for results
This commit is contained in:
parent
e95cc42a22
commit
21371efde6
@ -287,12 +287,14 @@ class CQiWrapper(CQiClient):
|
|||||||
first_cpos, last_cpos = match_cpos_list[0], match_cpos_list[-1]
|
first_cpos, last_cpos = match_cpos_list[0], match_cpos_list[-1]
|
||||||
context_sentences = {}
|
context_sentences = {}
|
||||||
s_ids = self.cl_cpos2struc(key, [first_cpos, last_cpos])
|
s_ids = self.cl_cpos2struc(key, [first_cpos, last_cpos])
|
||||||
|
logger.warning('s id match: {}'.format(s_ids))
|
||||||
for s_id in s_ids:
|
for s_id in s_ids:
|
||||||
s_start, s_end = self.cl_struc2cpos(key, s_id)
|
s_start, s_end = self.cl_struc2cpos(key, s_id)
|
||||||
s_cpos = list(range(s_start, s_end + 1))
|
s_cpos = list(range(s_start, s_end + 1))
|
||||||
context_sentences[s_id] = s_cpos
|
context_sentences[s_id] = s_cpos
|
||||||
if get_surrounding_s:
|
if get_surrounding_s:
|
||||||
max_s_id = self.cl_attribute_size(key)
|
max_s_id = self.cl_attribute_size(key) - 1
|
||||||
|
logger.warning('max sid: {}'.format(max_s_id))
|
||||||
additional_s_ids = []
|
additional_s_ids = []
|
||||||
additional_s = list(range(max(s_ids[0]
|
additional_s = list(range(max(s_ids[0]
|
||||||
- l_r_s_context_additional_len,
|
- l_r_s_context_additional_len,
|
||||||
@ -302,6 +304,7 @@ class CQiWrapper(CQiClient):
|
|||||||
max_s_id) + 1))
|
max_s_id) + 1))
|
||||||
additional_s_ids.extend(additional_s)
|
additional_s_ids.extend(additional_s)
|
||||||
for s_id in additional_s_ids:
|
for s_id in additional_s_ids:
|
||||||
|
logger.warning('s id additional: {}'.format(s_id))
|
||||||
s_start, s_end = self.cl_struc2cpos(key, s_id)
|
s_start, s_end = self.cl_struc2cpos(key, s_id)
|
||||||
s_cpos = list(range(s_start, s_end + 1))
|
s_cpos = list(range(s_start, s_end + 1))
|
||||||
context_sentences[s_id] = s_cpos
|
context_sentences[s_id] = s_cpos
|
||||||
|
@ -38,6 +38,11 @@ main {
|
|||||||
}
|
}
|
||||||
/* ### End sidenav-fixed offset ### */
|
/* ### End sidenav-fixed offset ### */
|
||||||
|
|
||||||
|
/* add custom bold class */
|
||||||
|
.bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
/* CSS for clickable th elements in tables. Needed for sortable table data with
|
/* CSS for clickable th elements in tables. Needed for sortable table data with
|
||||||
list js. On click on th header elements will be sorted accordingly. Also a caret
|
list js. On click on th header elements will be sorted accordingly. Also a caret
|
||||||
indicator will show up how the column is sorted right now.; */
|
indicator will show up how the column is sorted right now.; */
|
||||||
@ -87,6 +92,7 @@ indicator will show up how the column is sorted right now.; */
|
|||||||
z-index: 999; /* tmp fix */
|
z-index: 999; /* tmp fix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* styles for resource lists */
|
||||||
.service[data-service]:before {
|
.service[data-service]:before {
|
||||||
content: "help";
|
content: "help";
|
||||||
}
|
}
|
||||||
|
@ -93,66 +93,55 @@ RessourceList.options = {
|
|||||||
class ResultList extends List {
|
class ResultList extends List {
|
||||||
|
|
||||||
createResultRowElement(item, chunk) {
|
createResultRowElement(item, chunk) {
|
||||||
let values, cpos, matchRowElement, lcCellElement, lcTokenElement, token;
|
let values, cpos, token, matchRowElement, lcCellElement, hitCellElement, rcCellElement, textTitlesCellElement;
|
||||||
// gather values from item
|
// gather values from item
|
||||||
values = item.values();
|
values = item.values();
|
||||||
console.log("CHONK");
|
console.log("CHONK");
|
||||||
console.log(chunk);
|
console.log(chunk);
|
||||||
|
|
||||||
// get infos for full match row
|
// get infos for full match row
|
||||||
matchRowElement = document.createElement("tr");
|
matchRowElement = document.createElement("tr");
|
||||||
for (cpos of values["lc"]) {
|
matchRowElement.setAttribute("data-index", values["index"])
|
||||||
console.log(cpos);
|
lcCellElement = document.createElement("td");
|
||||||
lcCellElement = document.createElement("td");
|
lcCellElement.classList.add("left-context");
|
||||||
lcTokenElement = document.createElement("span");
|
|
||||||
lcTokenElement.classList.add("token");
|
|
||||||
lcTokenElement.dataset.cpos = cpos;
|
|
||||||
token = chunk["cpos_lookup"][cpos];
|
|
||||||
lcTokenElement.innerText = token["word"];
|
|
||||||
lcCellElement.appendChild(lcTokenElement);
|
|
||||||
// let hit_tokens = "";
|
|
||||||
}
|
|
||||||
matchRowElement.appendChild(lcCellElement);
|
matchRowElement.appendChild(lcCellElement);
|
||||||
// // get infos of match
|
for (cpos of values["lc"]) {
|
||||||
// let textTitles = new Set();
|
token = chunk["cpos_lookup"][cpos];
|
||||||
// for (cpos of match["hit"]) {
|
lcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
||||||
// tokenElement = document.createElement("span");
|
}
|
||||||
// tokenElement.classList.add("token");
|
|
||||||
// tokenElement.dataset.cpos = cpos;
|
// get infos for hit of match
|
||||||
// token = chunk["cpos_lookup"][cpos];
|
let textTitles = new Set();
|
||||||
// tokenElement.innerText = token["word"];
|
hitCellElement = document.createElement("td");
|
||||||
// hit_tokens += " " + tokenElement.outerHTML;
|
hitCellElement.classList.add("match-hit");
|
||||||
// // get text titles of every hit cpos token
|
textTitlesCellElement = document.createElement("td");
|
||||||
// textTitles.add(chunk["text_lookup"][token["text"]]["title"]);
|
textTitlesCellElement.classList.add("titles");
|
||||||
// }
|
matchRowElement.appendChild(hitCellElement);
|
||||||
// // add button to trigger more context to every match td
|
for (cpos of values["hit"]) {
|
||||||
// var inspectBtn = document.createElement("a");
|
token = chunk["cpos_lookup"][cpos];
|
||||||
// inspectBtn.setAttribute("class", "btn-floating btn-flat waves-effect waves-light grey right inspect");
|
hitCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
||||||
// inspectBtn.onclick = function() {inspect()};
|
// get text titles of every hit cpos token
|
||||||
// inspectBtn.innerHTML = '<i class="material-icons">search</i>';
|
textTitles.add(chunk["text_lookup"][token["text"]]["title"]);
|
||||||
// hit_tokens += "<p>" + inspectBtn.outerHTML + "</p>";
|
// add button to trigger more context to every match td
|
||||||
// // get infos for right context of match
|
var inspectBtn = document.createElement("a");
|
||||||
// let rc_tokens = "";
|
inspectBtn.setAttribute("class", "btn-floating btn-flat waves-effect waves-light grey right inspect");
|
||||||
// for (cpos of match["rc"]) {
|
inspectBtn.innerHTML = '<i class="material-icons">search</i>';
|
||||||
// tokenElement = document.createElement("span");
|
inspectBtn.onclick = function () {inspect(values["index"])};
|
||||||
// tokenElement.classList.add("token");
|
}
|
||||||
// tokenElement.dataset.cpos = cpos;
|
// add text titles at front as first td of one row
|
||||||
// token = chunk["cpos_lookup"][cpos];
|
hitCellElement.appendChild(inspectBtn);
|
||||||
// tokenElement.innerText = token["word"];
|
textTitlesCellElement.innerText = [...textTitles].join(", ");
|
||||||
// rc_tokens += " " + tokenElement.outerHTML;
|
matchRowElement.insertAdjacentHTML("afterbegin", textTitlesCellElement.outerHTML);
|
||||||
// }
|
|
||||||
// // put all infos into an javascribt object
|
// get infos for right context of match
|
||||||
// textTitleElement = document.createElement("span");
|
rcCellElement = document.createElement("td");
|
||||||
// textTitleElement.classList.add("text-titles");
|
rcCellElement.classList.add("right-context");
|
||||||
// textTitles = [...textTitles].join(",");
|
matchRowElement.appendChild(rcCellElement);
|
||||||
// textTitleElement.innerText = textTitles;
|
for (cpos of values["rc"]) {
|
||||||
//
|
token = chunk["cpos_lookup"][cpos];
|
||||||
// matchRowElement.appendChild(textTitleElement);
|
rcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
||||||
// // matchRowElement.appendChild(lc_tokens);
|
}
|
||||||
// // matchRowElement.appendChild(hit_tokens);
|
console.log(matchRowElement);
|
||||||
// // matchRowElement.appendChild(rc_tokens);
|
|
||||||
// // matchRowElement.appendChild(index);
|
|
||||||
// }
|
|
||||||
console.log(matchRowElement.outerHTML);
|
|
||||||
return matchRowElement
|
return matchRowElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,13 +378,16 @@
|
|||||||
resultList.add(resultItems, items => {
|
resultList.add(resultItems, items => {
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
item.elm = resultList.createResultRowElement(item, chunk);}
|
item.elm = resultList.createResultRowElement(item, chunk);}
|
||||||
|
resultList.update();
|
||||||
});
|
});
|
||||||
resultList.update();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// inspect match functions
|
// inspect match functions
|
||||||
function inspect() {
|
function inspect(dataIndex) {
|
||||||
console.log("Inspect!")
|
console.log("Inspect!");
|
||||||
|
console.log(result["matches"][dataIndex]["hit"]);
|
||||||
|
contextModal.open();
|
||||||
|
nopaque.socket.emit("inspect_match", {"cpos": result["matches"][dataIndex]["hit"]});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to download data to a file
|
// Function to download data to a file
|
||||||
@ -442,7 +445,7 @@
|
|||||||
"transitionMovement": 0});
|
"transitionMovement": 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get context of one match if inspected
|
||||||
nopaque.socket.on("match_context", function(message) {
|
nopaque.socket.on("match_context", function(message) {
|
||||||
console.log("### match_context ###");
|
console.log("### match_context ###");
|
||||||
console.log(message);
|
console.log(message);
|
||||||
@ -450,9 +453,7 @@
|
|||||||
document.getElementById("context-modal-loading").classList.add("hide");
|
document.getElementById("context-modal-loading").classList.add("hide");
|
||||||
document.getElementById("context-modal-ready").classList.remove("hide");
|
document.getElementById("context-modal-ready").classList.remove("hide");
|
||||||
|
|
||||||
var sentenceElement;
|
let sentenceElement, token, tokenElement;
|
||||||
var token;
|
|
||||||
var tokenElement;
|
|
||||||
|
|
||||||
lookup["cpos"] = {...lookup["cpos"], ...message["cpos_lookup"]};
|
lookup["cpos"] = {...lookup["cpos"], ...message["cpos_lookup"]};
|
||||||
lookup["s"] = message["context_s_cpos"];
|
lookup["s"] = message["context_s_cpos"];
|
||||||
@ -469,11 +470,11 @@
|
|||||||
}
|
}
|
||||||
tokenElement.dataset.cpos = cpos;
|
tokenElement.dataset.cpos = cpos;
|
||||||
tokenElement.innerText = token["word"];
|
tokenElement.innerText = token["word"];
|
||||||
if (expertModeSwitchElement.checked) {
|
// if (expertModeSwitchElement.checked) {
|
||||||
tokenElement.classList.add("chip");
|
// tokenElement.classList.add("chip");
|
||||||
addToolTipToTokenElement(tokenElement, token);
|
// addToolTipToTokenElement(tokenElement, token);
|
||||||
}
|
// }
|
||||||
tokenElements.add(tokenElement);
|
// tokenElements.add(tokenElement);
|
||||||
sentenceElement.append(tokenElement);
|
sentenceElement.append(tokenElement);
|
||||||
sentenceElement.append(document.createTextNode(" "));
|
sentenceElement.append(document.createTextNode(" "));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user