diff --git a/app/corpora/CQiWrapper/CQiWrapper.py b/app/corpora/CQiWrapper/CQiWrapper.py index cc35879a..d96c5ed9 100644 --- a/app/corpora/CQiWrapper/CQiWrapper.py +++ b/app/corpora/CQiWrapper/CQiWrapper.py @@ -233,20 +233,26 @@ class CQiWrapper(CQiClient): tmp_info[struct_attr_key].append(id) else: structs_to_check.append({key: struct_attr_key}) + logger.warning('Structs to check: {}'.format(structs_to_check)) struct_attr_values = list(tmp_info.values()) + # logger.warning('Struct attr value list: {}'.format(struct_attr_values)) struct_attr_keys = list(tmp_info.keys()) + # logger.warning('Struct attr key list: {}'.format(struct_attr_keys)) # Build textlookup dictionary - text_lookup_ids = list(set(struct_attr_values[0])) # First is always one text - text_lookup = {} + text_lookup_ids = list(set(struct_attr_values[0])) # every CPOS is associated with one text id. A set is build to only gather text_lookup informations for every unique text id + text_lookup = {} # final dict containing all info of one text identified by its id for d in structs_to_check: s_key, s_value = zip(*d.items()) - s_value = s_value[0].split('_', 1)[1] + logger.warning('dict entries: {}: {}'.format(s_key, s_value)) + s_value = s_value[0].split('_', 1)[-1] + logger.warning('S_VALUE: {}'.format(s_value)) struct_values = self.cl_struc2str(s_key[0], text_lookup_ids) + logger.warning('Extracted Value with key {}: {}'.format(s_key[0],struct_values)) zipped = dict(zip(text_lookup_ids, struct_values)) for zip_key, zip_value in zipped.items(): - logger.warning('key: {}'.format(zip_key)) - logger.warning('value: {}'.format(zip_value)) + logger.warning('Text id as key is: {}'.format(zip_key)) + logger.warning('Value of this text is: {}'.format(zip_value)) check = text_lookup.get(zip_key) logger.warning('check: {}'.format(check)) if check is None: diff --git a/app/static/js/ResultList.js b/app/static/js/ResultList.js deleted file mode 100644 index c08e7624..00000000 --- a/app/static/js/ResultList.js +++ /dev/null @@ -1,3 +0,0 @@ -class JobList extends List { - -} diff --git a/app/static/js/nopaque.lists.js b/app/static/js/nopaque.lists.js index a7058f97..d3210160 100644 --- a/app/static/js/nopaque.lists.js +++ b/app/static/js/nopaque.lists.js @@ -243,6 +243,74 @@ class JobList extends List { return rowElement; } } + + +class ResultList extends List { + + createResultRowElement(item) { + let values, cpos, matchRowElement, lcCellElement, lcTokenElement, token; + // gather values from item + values = item.values(); + + // get infos for full match row + matchRowElement = document.createElement("tr"); + for (cpos of values["lc"]) { + console.log(cpos); + lcCellElement = document.createElement("td"); + lcTokenElement = document.createElement("span"); + lcTokenElement.classList.add("token"); + lcTokenElement.dataset.cpos = cpos; + token = chunk["cpos_lookup"][cpos]; + lcTokenElement = token["word"]; + console.log(lcTokenElement.outerHTML); + // let hit_tokens = ""; + } + // // get infos of match + // let textTitles = new Set(); + // for (cpos of match["hit"]) { + // tokenElement = document.createElement("span"); + // tokenElement.classList.add("token"); + // tokenElement.dataset.cpos = cpos; + // token = chunk["cpos_lookup"][cpos]; + // tokenElement.innerText = token["word"]; + // hit_tokens += " " + tokenElement.outerHTML; + // // get text titles of every hit cpos token + // textTitles.add(chunk["text_lookup"][token["text"]]["title"]); + // } + // // add button to trigger more context to every match td + // var inspectBtn = document.createElement("a"); + // inspectBtn.setAttribute("class", "btn-floating btn-flat waves-effect waves-light grey right inspect"); + // inspectBtn.onclick = function() {inspect()}; + // inspectBtn.innerHTML = 'search'; + // hit_tokens += "
" + inspectBtn.outerHTML + "
"; + // // get infos for right context of match + // let rc_tokens = ""; + // for (cpos of match["rc"]) { + // tokenElement = document.createElement("span"); + // tokenElement.classList.add("token"); + // tokenElement.dataset.cpos = cpos; + // token = chunk["cpos_lookup"][cpos]; + // tokenElement.innerText = token["word"]; + // rc_tokens += " " + tokenElement.outerHTML; + // } + // // put all infos into an javascribt object + // textTitleElement = document.createElement("span"); + // textTitleElement.classList.add("text-titles"); + // textTitles = [...textTitles].join(","); + // textTitleElement.innerText = textTitles; + // + // matchRowElement.appendChild(textTitleElement); + // // matchRowElement.appendChild(lc_tokens); + // // matchRowElement.appendChild(hit_tokens); + // // matchRowElement.appendChild(rc_tokens); + // // matchRowElement.appendChild(index); + // } + // return matchRowElement + } +} + + + JobList.DEFAULT_OPTIONS = {item: "