Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
49311f58
Commit
49311f58
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add basic style for expert view
parent
54f3036d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/corpora/events.py
+4
-3
4 additions, 3 deletions
app/corpora/events.py
app/templates/corpora/analyse_corpus.html.j2
+57
-13
57 additions, 13 deletions
app/templates/corpora/analyse_corpus.html.j2
with
61 additions
and
16 deletions
app/corpora/events.py
+
4
−
3
View file @
49311f58
...
@@ -75,10 +75,11 @@ def corpus_analysis(message):
...
@@ -75,10 +75,11 @@ def corpus_analysis(message):
cpos_list
=
list
(
set
(
cpos_list
))
cpos_list
=
list
(
set
(
cpos_list
))
pos_list
=
client
.
cl_cpos2str
(
'
{}.pos
'
.
format
(
corpus
),
cpos_list
)
pos_list
=
client
.
cl_cpos2str
(
'
{}.pos
'
.
format
(
corpus
),
cpos_list
)
simple_pos_list
=
client
.
cl_cpos2str
(
'
{}.simple_pos
'
.
format
(
corpus
),
cpos_list
)
simple_pos_list
=
client
.
cl_cpos2str
(
'
{}.simple_pos
'
.
format
(
corpus
),
cpos_list
)
text_id_list
=
client
.
cl_cpos2struc
(
'
{}.text_title
'
.
format
(
corpus
),
cpos_list
)
s_id_list
=
client
.
cl_cpos2struc
(
'
{}.s
'
.
format
(
corpus
),
cpos_list
)
text_id_list
=
client
.
cl_cpos2struc
(
'
{}.text
'
.
format
(
corpus
),
cpos_list
)
word_list
=
client
.
cl_cpos2str
(
'
{}.word
'
.
format
(
corpus
),
cpos_list
)
word_list
=
client
.
cl_cpos2str
(
'
{}.word
'
.
format
(
corpus
),
cpos_list
)
for
cpos
,
pos
,
simple_pos
,
text_id
,
word
in
zip
(
cpos_list
,
pos_list
,
simple_pos_list
,
text_id_list
,
word_list
):
for
cpos
,
pos
,
simple_pos
,
s_id
,
text_id
,
word
in
zip
(
cpos_list
,
pos_list
,
simple_pos_list
,
s_id_list
,
text_id_list
,
word_list
):
data
[
'
cpos_lookup
'
][
cpos
]
=
{
'
pos
'
:
pos
,
'
simple_pos
'
:
simple_pos
,
'
text_id
'
:
text_id
,
'
word
'
:
word
}
data
[
'
cpos_lookup
'
][
cpos
]
=
{
'
pos
'
:
pos
,
'
simple_pos
'
:
simple_pos
,
'
s_id
'
:
s_id
,
'
text_id
'
:
text_id
,
'
word
'
:
word
}
text_author_list
=
client
.
cl_struc2str
(
'
{}.text_author
'
.
format
(
corpus
),
text_id_list
)
text_author_list
=
client
.
cl_struc2str
(
'
{}.text_author
'
.
format
(
corpus
),
text_id_list
)
text_publishing_year_list
=
client
.
cl_struc2str
(
'
{}.text_publishing_year
'
.
format
(
corpus
),
text_id_list
)
text_publishing_year_list
=
client
.
cl_struc2str
(
'
{}.text_publishing_year
'
.
format
(
corpus
),
text_id_list
)
text_title_list
=
client
.
cl_struc2str
(
'
{}.text_title
'
.
format
(
corpus
),
text_id_list
)
text_title_list
=
client
.
cl_struc2str
(
'
{}.text_title
'
.
format
(
corpus
),
text_id_list
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/analyse_corpus.html.j2
+
57
−
13
View file @
49311f58
{% extends "full_width.html.j2" %}
{% extends "full_width.html.j2" %}
{% block page_content %}
{% block page_content %}
<style>
.token-box {
padding: 5px;
margin: 2px 0;
border-radius: 5px;
background-color: #009688;
display: inline-block;
color: white;
}
.token-box:hover {
background-color: #00bfa5;
cursor: pointer;
}
</style>
<div class="col s12 m3 sticky">
<div class="col s12 m3 sticky">
<div class="card">
<div class="card">
<div class="card-content">
<div class="card-content">
...
@@ -36,6 +51,13 @@
...
@@ -36,6 +51,13 @@
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
<div class="switch">
<label>
Expert Mode
<input type="checkbox" id="expert-mode-switch">
<span class="lever"></span>
</label>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
...
@@ -69,10 +91,10 @@
...
@@ -69,10 +91,10 @@
<table class="highlight">
<table class="highlight">
<thead>
<thead>
<tr>
<tr>
<th>Title</th>
<th
style="width: 5%"
>Title</th>
<th>Left context</th>
<th
style="width: 25%"
>Left context</th>
<th>Match</th>
<th
style="width: 45%"
>Match</th>
<th>Right Context</th>
<th
style="width: 25%"
>Right Context</th>
</tr>
</tr>
</thead>
</thead>
<tbody id="query-results"></tbody>
<tbody id="query-results"></tbody>
...
@@ -103,7 +125,6 @@
...
@@ -103,7 +125,6 @@
<script>
<script>
var loadingModal;
var loadingModal;
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function() {
loadingModal = M.Modal.init(document.getElementById("loading-modal"),
loadingModal = M.Modal.init(document.getElementById("loading-modal"),
{"dismissible": false});
{"dismissible": false});
...
@@ -115,10 +136,23 @@
...
@@ -115,10 +136,23 @@
if (msg === "[201]: Created") {loadingModal.close();}
if (msg === "[201]: Created") {loadingModal.close();}
});
});
var expertModeSwitchElement = document.getElementById("expert-mode-switch");
var tokenElements = [];
expertModeSwitchElement.addEventListener('change', function(event) {
if (event.target.checked) {
tokenElements.forEach(function(tokenElement) {
tokenElement.classList.add("token-box");
});
} else {
tokenElements.forEach(function(tokenElement) {
tokenElement.classList.remove("token-box");
});
}
})
var queryFormElement = document.getElementById("query-form");
var queryFormElement = document.getElementById("query-form");
var queryFormSubmitElement = document.getElementById("query-form-submit");
var queryFormSubmitElement = document.getElementById("query-form-submit");
var queryResultsElement = document.getElementById("query-results");
var queryResultsElement = document.getElementById("query-results");
queryFormSubmitElement.addEventListener("click", function(event) {
queryFormSubmitElement.addEventListener("click", function(event) {
event.preventDefault();
event.preventDefault();
let formData = new FormData(queryFormElement);
let formData = new FormData(queryFormElement);
...
@@ -132,6 +166,7 @@
...
@@ -132,6 +166,7 @@
socket.on("corpus_analysis", function(result) {
socket.on("corpus_analysis", function(result) {
console.log(result);
console.log(result);
var htmlString = "";
var htmlString = "";
var textTitles;
var token;
var token;
if (result['matches'].length === 0) {
if (result['matches'].length === 0) {
...
@@ -140,25 +175,32 @@
...
@@ -140,25 +175,32 @@
for (let match of result['matches']) {
for (let match of result['matches']) {
htmlString += `<tr class="match">`;
htmlString += `<tr class="match">`;
htmlString += `<td class="title"></td>`
htmlString += `<td class="title">`;
textTitles = new Set();
for (cpos of match["hit"]) {
token = result["cpos_lookup"][cpos];
textTitles.add(result["text_loopup"][token["text_id"]]["title"]);
}
htmlString += [...textTitles].join(",");
htmlString += `</td>`;
htmlString += `<td class="left-context">`;
htmlString += `<td class="left-context">`;
for (cpos of match["lc"]) {
for (cpos of match["lc"]) {
token = result["cpos_lookup"][cpos];
token = result["cpos_lookup"][cpos];
htmlString +=
token["simple_pos"] != "PUNCT" ? " " :
"";
htmlString += "
";
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
}
}
htmlString += `</td>`;
htmlString += `</td>`;
htmlString += `<td class="hit">`;
htmlString += `<td class="hit">`;
for (cpos of match["hit"]) {
for (cpos of match["hit"]) {
token = result["cpos_lookup"][cpos];
token = result["cpos_lookup"][cpos];
htmlString +=
token["simple_pos"] != "PUNCT" ? " " :
"";
htmlString += "
";
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
}
}
htmlString += `</td>`;
htmlString += `</td>`;
htmlString += `<td class="right-context">`;
htmlString += `<td class="right-context">`;
for (cpos of match["rc"]) {
for (cpos of match["rc"]) {
token = result["cpos_lookup"][cpos];
token = result["cpos_lookup"][cpos];
htmlString +=
token["simple_pos"] != "PUNCT" ? " " :
"";
htmlString += "
";
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
}
}
htmlString += `</td>`;
htmlString += `</td>`;
...
@@ -167,10 +209,12 @@
...
@@ -167,10 +209,12 @@
queryResultsElement.innerHTML = htmlString;
queryResultsElement.innerHTML = htmlString;
queryResultsElement.querySelectorAll(".token").forEach(function(tokenElement) {
tokenElements = queryResultsElement.querySelectorAll(".token");
tokenElements.forEach(function(tokenElement) {
tokenElement.addEventListener("click", function(event) {
tokenElement.addEventListener("click", function(event) {
let token = result["cpos_lookup"][tokenElement.dataset.cpos];
if (!expertModeSwitchElement.checked) {return;}
let text = result["text_loopup"][token["text_id"]];
var token = result["cpos_lookup"][tokenElement.dataset.cpos];
var text = result["text_loopup"][token["text_id"]];
alert(`${token["word"]} // ${token["pos"]} // ${token["simple_pos"]} // ${text["title"]}`);
alert(`${token["word"]} // ${token["pos"]} // ${token["simple_pos"]} // ${text["title"]}`);
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment