mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-27 00:10:35 +00:00
Visualization Testing Corpus Analysis
This commit is contained in:
97
app/static/js/ResourceLists/CorpusTextInfoList.js
Normal file
97
app/static/js/ResourceLists/CorpusTextInfoList.js
Normal file
@ -0,0 +1,97 @@
|
||||
class CorpusTextInfoList extends ResourceList {
|
||||
|
||||
static autoInit() {
|
||||
for (let corpusTextInfoListElement of document.querySelectorAll('.corpus-text-info-list:not(.no-autoinit)')) {
|
||||
new CorpusTextInfoList(corpusTextInfoListElement);
|
||||
}
|
||||
}
|
||||
|
||||
static defaultOptions = {
|
||||
page: 4
|
||||
};
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
let _options = Utils.mergeObjectsDeep(
|
||||
CorpusTextInfoList.defaultOptions,
|
||||
options
|
||||
);
|
||||
super(listContainerElement, _options);
|
||||
this.isInitialized = false;
|
||||
}
|
||||
|
||||
get item() {
|
||||
return (values) => {
|
||||
return `
|
||||
<tr class="list-item clickable hoverable">
|
||||
<td><span class="title"></span> (<span class="publishing_year"></span>)</td>
|
||||
<td><span class="num_tokens"></span></td>
|
||||
<td><span class="num_unique_words"></span></td>
|
||||
<td><span class="num_unique_lemmas"></span></td>
|
||||
<td><span class="num_sentences"></span></td>
|
||||
<td><span class="average_sentence_length"></span></td>
|
||||
<td><span class="num_ent_types"></span></td>
|
||||
<td><span class="num_unique_ent_types"></span></td>
|
||||
</tr>
|
||||
`.trim();
|
||||
}
|
||||
}
|
||||
|
||||
get valueNames() {
|
||||
return [
|
||||
'title',
|
||||
'publishing_year',
|
||||
'num_tokens',
|
||||
'num_unique_words',
|
||||
'num_unique_lemmas',
|
||||
'num_sentences',
|
||||
'average_sentence_length',
|
||||
'num_ent_types',
|
||||
'num_unique_ent_types'
|
||||
];
|
||||
}
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-file-list-');
|
||||
}
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
<input id="${listSearchElementId}" class="search" type="text"></input>
|
||||
<label for="${listSearchElementId}">Search corpus file</label>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Text</th>
|
||||
<th>Number of tokens</th>
|
||||
<th>Number of unique words</th>
|
||||
<th>Number of unique lemmas</th>
|
||||
<th>Number of sentences</th>
|
||||
<th>Average sentence length</th>
|
||||
<th>Number of entity types</th>
|
||||
<th>Number of unique entity types</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list"></tbody>
|
||||
</table>
|
||||
<ul class="pagination"></ul>
|
||||
`.trim();
|
||||
}
|
||||
|
||||
mapResourceToValue(corpusTextData) {
|
||||
console.log(corpusTextData);
|
||||
return {
|
||||
title: corpusTextData.title,
|
||||
publishing_year: corpusTextData.publishing_year,
|
||||
num_tokens: corpusTextData.num_tokens,
|
||||
num_unique_words: corpusTextData.num_unique_words,
|
||||
num_unique_lemmas: corpusTextData.num_unique_lemmas,
|
||||
num_sentences: corpusTextData.num_sentences,
|
||||
average_sentence_length: corpusTextData.average_sentence_length,
|
||||
num_ent_types: corpusTextData.num_ent_types,
|
||||
num_unique_ent_types: corpusTextData.num_unique_ent_types
|
||||
};
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ class ResourceList {
|
||||
UserList.autoInit();
|
||||
AdminUserList.autoInit();
|
||||
CorpusFollowerList.autoInit();
|
||||
CorpusTextInfoList.autoInit();
|
||||
}
|
||||
|
||||
static defaultOptions = {
|
||||
|
Reference in New Issue
Block a user