mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
handle result ranges
This commit is contained in:
parent
b8a086f389
commit
89891da663
@ -121,17 +121,27 @@ 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, matchNrElement;
|
let values, cpos, token, matchRowElement, lcCellElement, hitCellElement, rcCellElement, textTitlesCellElement, matchNrElement, lc, c, rc;
|
||||||
// gather values from item
|
// gather values from item
|
||||||
values = item.values();
|
values = item.values();
|
||||||
|
if (chunk.cpos_ranges == true) {
|
||||||
|
// python range like function from MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Sequence_generator_(range)
|
||||||
|
const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
|
||||||
|
lc = range(values.lc[0], values.lc[1], 1)
|
||||||
|
c = range(values.c[0], values.c[1], 1)
|
||||||
|
rc = range(values.rc[0], values.rc[1], 1)
|
||||||
|
} else {
|
||||||
|
lc = values.lc;
|
||||||
|
c = values.c;
|
||||||
|
rc = values.rc;
|
||||||
|
}
|
||||||
// get infos for full match row
|
// get infos for full match row
|
||||||
matchRowElement = document.createElement("tr");
|
matchRowElement = document.createElement("tr");
|
||||||
matchRowElement.setAttribute("data-index", values["index"])
|
matchRowElement.setAttribute("data-index", values["index"])
|
||||||
lcCellElement = document.createElement("td");
|
lcCellElement = document.createElement("td");
|
||||||
lcCellElement.classList.add("left-context");
|
lcCellElement.classList.add("left-context");
|
||||||
matchRowElement.appendChild(lcCellElement);
|
matchRowElement.appendChild(lcCellElement);
|
||||||
for (cpos of values["lc"]) {
|
for (cpos of lc) {
|
||||||
token = chunk["cpos_lookup"][cpos];
|
token = chunk["cpos_lookup"][cpos];
|
||||||
lcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
lcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
||||||
}
|
}
|
||||||
@ -145,7 +155,7 @@ class ResultList extends List {
|
|||||||
matchNrElement = document.createElement("td");
|
matchNrElement = document.createElement("td");
|
||||||
matchNrElement.classList.add("match-nr");
|
matchNrElement.classList.add("match-nr");
|
||||||
matchRowElement.appendChild(hitCellElement);
|
matchRowElement.appendChild(hitCellElement);
|
||||||
for (cpos of values["c"]) {
|
for (cpos of c) {
|
||||||
token = chunk["cpos_lookup"][cpos];
|
token = chunk["cpos_lookup"][cpos];
|
||||||
hitCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
hitCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
|
||||||
// get text titles of every hit cpos token
|
// get text titles of every hit cpos token
|
||||||
@ -167,7 +177,7 @@ class ResultList extends List {
|
|||||||
rcCellElement = document.createElement("td");
|
rcCellElement = document.createElement("td");
|
||||||
rcCellElement.classList.add("right-context");
|
rcCellElement.classList.add("right-context");
|
||||||
matchRowElement.appendChild(rcCellElement);
|
matchRowElement.appendChild(rcCellElement);
|
||||||
for (cpos of values["rc"]) {
|
for (cpos of rc) {
|
||||||
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>`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user