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
5c134dd8
Commit
5c134dd8
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add interaactive context change
parent
db7ccb2b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/forms.py
+8
-3
8 additions, 3 deletions
app/corpora/forms.py
app/corpora/views.py
+1
-1
1 addition, 1 deletion
app/corpora/views.py
app/templates/corpora/analyse_corpus.html.j2
+44
-16
44 additions, 16 deletions
app/templates/corpora/analyse_corpus.html.j2
with
53 additions
and
20 deletions
app/corpora/forms.py
+
8
−
3
View file @
5c134dd8
...
...
@@ -68,11 +68,16 @@ class QueryForm(FlaskForm):
validators
=
[
DataRequired
()])
context
=
SelectField
(
'
Context
'
,
choices
=
[(
''
,
'
Words of context around hit
'
),
(
'
5
'
,
'
5
'
),
(
'
10
'
,
'
10
'
),
(
'
15
'
,
'
15
'
),
(
'
20
'
,
'
20
'
),
(
'
25
'
,
'
25
'
)],
(
'
30
'
,
'
30
'
),
(
'
40
'
,
'
40
'
),
(
'
50
'
,
'
50
'
),
(
'
60
'
,
'
60
'
),
(
'
70
'
,
'
70
'
),
(
'
80
'
,
'
80
'
),
(
'
90
'
,
'
90
'
),
(
'
100
'
,
'
100
'
)],
validators
=
[
DataRequired
()])
submit
=
SubmitField
(
'
Start Query
'
)
...
...
This diff is collapsed.
Click to expand it.
app/corpora/views.py
+
1
−
1
View file @
5c134dd8
...
...
@@ -56,7 +56,7 @@ def analyse_corpus(corpus_id):
corpus
.
status
=
'
start analysis
'
db
.
session
.
commit
()
query_download_form
=
QueryDownloadForm
()
query_form
=
QueryForm
(
context
=
request
.
args
.
get
(
'
context
'
,
1
0
),
query_form
=
QueryForm
(
context
=
request
.
args
.
get
(
'
context
'
,
2
0
),
hits_per_page
=
request
.
args
.
get
(
'
hits_per_page
'
,
30
),
query
=
request
.
args
.
get
(
'
query
'
))
return
render_template
(
'
corpora/analyse_corpus.html.j2
'
,
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/analyse_corpus.html.j2
+
44
−
16
View file @
5c134dd8
...
...
@@ -305,13 +305,11 @@
// live update of hits per page
var hitsPerPageInputElement = document.getElementById("hits-per-page");
hitsPerPageInputElement.
addEventListener("
change
",
change
ResultList)
;
hitsPerPageInputElement.
on
change
=
change
HitsPerPage
;
function changeResultList(event) {
let queryFormElement = document.getElementById("query-form");
queryData = getQueryData(queryFormElement);
function changeHitsPerPage(event) {
try {
resultList.page =
queryData["hits_per_page"]
;
resultList.page =
event.target.value
;
resultList.update();
nopaque.toast("Updated matches per page.")
} catch (e) {
...
...
@@ -319,19 +317,47 @@
}
}
// live update of lr context per item
// live update of lr context per item
if context value is changed
var contextPerItemElement = document.getElementById("context-per-item");
contextPerItemElement.addEventListener("change", changeContext);
contextPerItemElement.onchange = changeContext;
// eventListener if pagination is used to apply new context size to new page
var paginationElements = document.getElementsByClassName("pagination");
for (element of paginationElements) {
element.addEventListener("click", changeContext);
}
// event triggered on context select change and also if pagination is clicked
function changeContext(event) {
let queryFormElement = document.getElementById("query-form");
queryData = getQueryData(queryFormElement);
console.log(queryData);
try {
nopaque.toast("Loading more context.");
sendQuery(event);
} catch (e) {
console.log("No query given.");
// newValue = event.target.value; // cannot use this anymore due to reuse of this function in the above paginationElements eventListener
var contextPerItemElement = document.getElementById("context");
newValue = contextPerItemElement.value;
console.log(newValue);
var lc = document.getElementsByClassName("left-context");
var rc = document.getElementsByClassName("right-context");
// console.log("LC", lc);
// console.log("RC", rc);
for (let element of lc) {
// console.log(element.childNodes);
array = Array.from(element.childNodes);
// console.log(array);
for (let element of array.slice(newValue)) {
element.classList.add("hide");
}
for (let element of array.slice(0, newValue)) {
element.classList.remove("hide");
}
}
for (let element of rc) {
// console.log(element.childNodes);
array = Array.from(element.childNodes);
// console.log(array);
for (let element of array.slice(newValue)) {
element.classList.add("hide");
}
for (let element of array.slice(0, newValue)) {
element.classList.remove("hide");
}
}
}
...
...
@@ -392,8 +418,10 @@
}
resultList.add(resultItems, items => {
for (let item of items) {
item.elm = resultList.createResultRowElement(item, chunk);}
item.elm = resultList.createResultRowElement(item, chunk);
}
resultList.update();
changeContext(); // sets lr context to current/default value
});
result["loaded_match_count"] += Object.keys(chunk["matches"]).length;
console.log("After current match count", result["loaded_match_count"]);
...
...
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