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
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
0f23cbe2
Commit
0f23cbe2
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Plain Diff
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
parents
2fc09228
d23656ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/corpora/CQiWrapper/CQiWrapper.py
+15
-15
15 additions, 15 deletions
app/corpora/CQiWrapper/CQiWrapper.py
app/templates/corpora/analyse_corpus.html.j2
+23
-17
23 additions, 17 deletions
app/templates/corpora/analyse_corpus.html.j2
with
38 additions
and
32 deletions
app/corpora/CQiWrapper/CQiWrapper.py
+
15
−
15
View file @
0f23cbe2
...
@@ -144,28 +144,28 @@ class CQiWrapper(CQiClient):
...
@@ -144,28 +144,28 @@ class CQiWrapper(CQiClient):
# Save them as list into on match entry at serial number 'i'
# Save them as list into on match entry at serial number 'i'
ordered_matches
=
collections
.
OrderedDict
()
ordered_matches
=
collections
.
OrderedDict
()
for
i
,
match_pair
in
enumerate
(
match_boundaries
):
for
i
,
match_pair
in
enumerate
(
match_boundaries
):
ordered_matches
[
i
]
=
({
'
match_cpos
_list
'
:
ordered_matches
[
i
]
=
({
'
match_cpos
'
:
list
(
range
(
match_pair
[
0
],
list
(
range
(
match_pair
[
0
],
match_pair
[
1
]
+
1
))})
match_pair
[
1
]
+
1
))})
# Saves cpos form all match entries into one list
# Saves cpos form all match entries into one list
all_cpos_list
=
[]
all_cpos_list
=
[]
for
key
in
ordered_matches
.
keys
():
for
key
in
ordered_matches
.
keys
():
all_cpos_list
+=
ordered_matches
[
key
][
'
match_cpos
_list
'
]
all_cpos_list
+=
ordered_matches
[
key
][
'
match_cpos
'
]
# Saves all cpos from before and after context into the list:
# Saves all cpos from before and after context into the list:
# all_context_cpos_list
# all_context_cpos_list
all_context_cpos_list
=
[]
all_context_cpos_list
=
[]
for
key
in
ordered_matches
.
keys
():
for
key
in
ordered_matches
.
keys
():
cpos_list
=
ordered_matches
[
key
][
'
match_cpos
_list
'
]
cpos_list
=
ordered_matches
[
key
][
'
match_cpos
'
]
before_index
=
max
([
0
,
cpos_list
[
0
]
-
self
.
context_len
])
before_index
=
max
([
0
,
cpos_list
[
0
]
-
self
.
context_len
])
after_index
=
min
([
self
.
corpus_max_len
,
after_index
=
min
([
self
.
corpus_max_len
,
cpos_list
[
-
1
]
+
self
.
context_len
])
cpos_list
[
-
1
]
+
self
.
context_len
])
ordered_matches
[
key
][
'
context_
before_cpos_list
'
]
=
list
(
range
(
before_index
,
ordered_matches
[
key
][
'
left_
context_
cpos
'
]
=
list
(
range
(
before_index
,
cpos_list
[
0
]))
cpos_list
[
0
]))
ordered_matches
[
key
][
'
context_
after_cpos_list
'
]
=
list
(
range
(
cpos_list
[
-
1
]
+
1
,
ordered_matches
[
key
][
'
right_
context_
cpos
'
]
=
list
(
range
(
cpos_list
[
-
1
]
+
1
,
after_index
+
1
))
after_index
+
1
))
all_context_cpos_list
+=
ordered_matches
[
key
][
'
context_
before_cpos_list
'
]
all_context_cpos_list
+=
ordered_matches
[
key
][
'
left_
context_
cpos
'
]
all_context_cpos_list
+=
ordered_matches
[
key
][
'
context_
after_cpos_list
'
]
all_context_cpos_list
+=
ordered_matches
[
key
][
'
right_
context_
cpos
'
]
# Combines all_cpos_list with all_context_cpos_list as a sorted set
# Combines all_cpos_list with all_context_cpos_list as a sorted set
all_cpos_list
+=
all_context_cpos_list
all_cpos_list
+=
all_context_cpos_list
all_cpos_list
=
sorted
(
list
(
set
(
all_cpos_list
)))
all_cpos_list
=
sorted
(
list
(
set
(
all_cpos_list
)))
...
@@ -178,37 +178,37 @@ class CQiWrapper(CQiClient):
...
@@ -178,37 +178,37 @@ class CQiWrapper(CQiClient):
# loops over cpos in cpos_list which holds all match cpos
# loops over cpos in cpos_list which holds all match cpos
# Replaces one cpos with the corresponding cpos information created
# Replaces one cpos with the corresponding cpos information created
# by self.get_cpos_infos(all_cpos_list)
# by self.get_cpos_infos(all_cpos_list)
cpos_list
=
ordered_matches
[
key
][
'
match_cpos
_list
'
]
cpos_list
=
ordered_matches
[
key
][
'
match_cpos
'
]
infos
=
[]
infos
=
[]
for
cpos
in
cpos_list
:
for
cpos
in
cpos_list
:
info
=
{
cpos
:
all_cpos_infos
.
get
(
cpos
)}
info
=
{
cpos
:
all_cpos_infos
.
get
(
cpos
)}
infos
.
append
(
info
)
infos
.
append
(
info
)
ordered_matches
[
key
][
'
match_cpos
_list
'
]
=
infos
ordered_matches
[
key
][
'
match_cpos
'
]
=
infos
try
:
try
:
# loops over cpos in ordered_matches[key]['context_
before_cpos_list
']
# loops over cpos in ordered_matches[key]['
left_
context_
cpos
']
# which holds all cpos of the before context
# which holds all cpos of the before context
# Replaces one cpos with the corresponding cpos information created
# Replaces one cpos with the corresponding cpos information created
# by self.get_cpos_infos(all_cpos_list)
# by self.get_cpos_infos(all_cpos_list)
before_context_infos
=
[]
before_context_infos
=
[]
for
context_before_cpos
in
ordered_matches
[
key
][
'
context_
before_cpos_list
'
]:
for
context_before_cpos
in
ordered_matches
[
key
][
'
left_
context_
cpos
'
]:
before_context_info
=
{
context_before_cpos
:
before_context_info
=
{
context_before_cpos
:
all_cpos_infos
.
get
(
context_before_cpos
)}
all_cpos_infos
.
get
(
context_before_cpos
)}
before_context_infos
.
append
(
before_context_info
)
before_context_infos
.
append
(
before_context_info
)
ordered_matches
[
key
][
'
context_
before_cpos_list
'
]
=
before_context_infos
ordered_matches
[
key
][
'
left_
context_
cpos
'
]
=
before_context_infos
except
UnboundLocalError
:
except
UnboundLocalError
:
logger
.
warning
(
'
Context before cpos list is empty.
'
)
logger
.
warning
(
'
Context before cpos list is empty.
'
)
pass
pass
try
:
try
:
# loops over cpos in ordered_matches[key]['context_
after_cpos_list
']
# loops over cpos in ordered_matches[key]['
right_
context_
cpos
']
# which holds all cpos of the before context
# which holds all cpos of the before context
# Replaces one cpos with the corresponding cpos information created
# Replaces one cpos with the corresponding cpos information created
# by self.get_cpos_infos(all_cpos_list)
# by self.get_cpos_infos(all_cpos_list)
after_context_infos
=
[]
after_context_infos
=
[]
for
context_after_cpos
in
ordered_matches
[
key
][
'
context_
after_cpos_list
'
]:
for
context_after_cpos
in
ordered_matches
[
key
][
'
right_
context_
cpos
'
]:
after_context_info
=
{
context_after_cpos
:
after_context_info
=
{
context_after_cpos
:
all_cpos_infos
.
get
(
context_after_cpos
)}
all_cpos_infos
.
get
(
context_after_cpos
)}
after_context_infos
.
append
(
after_context_info
)
after_context_infos
.
append
(
after_context_info
)
ordered_matches
[
key
][
'
context_
after_cpos_list
'
]
=
after_context_infos
ordered_matches
[
key
][
'
right_
context_
cpos
'
]
=
after_context_infos
except
UnboundLocalError
:
except
UnboundLocalError
:
logger
.
warning
(
'
Context after cpos list is empty.
'
)
logger
.
warning
(
'
Context after cpos list is empty.
'
)
pass
pass
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/analyse_corpus.html.j2
+
23
−
17
View file @
0f23cbe2
...
@@ -119,33 +119,39 @@
...
@@ -119,33 +119,39 @@
if (results === null) {
if (results === null) {
M.toast({html: 'Query has no results!'});
M.toast({html: 'Query has no results!'});
} else {
} else {
html_txt = '<table class="highlight"> <thead><tr><th>Left context</th><th>Match</th><th>Right Context</th></tr></thead>';
console.log(results);
html_txt = '<table class="highlight"> <thead><tr><th>Title</th><th>Left context</th><th>Match</th><th>Right Context</th></tr></thead>';
for (let [key, hit] of Object.entries(results)) {
for (let [key, hit] of Object.entries(results)) {
var left_context = hit['context_before_cpos_list']
var left_context = hit['left_context_cpos']
var match = hit['match_cpos_list']
var match = hit['match_cpos']
var right_context = hit['context_after_cpos_list']
var right_context = hit['right_context_cpos']
var l_text = getResultInfos(left_context)
var l_text = getResultInfos(left_context, 'word')
var m_text = getResultInfos(match)
var m_text = getResultInfos(match, 'word')
var r_text = getResultInfos(right_context)
var r_text = getResultInfos(right_context, 'word')
html_txt += '<tr><td>' + l_text + '</td><td>' + m_text + '</td><td>' + r_text + '</td></tr>';
var match_source = getResultInfos(match, 'text_title', 1)
html_txt += '<tr> <td>' + match_source + '</td><td>' + l_text + '</td><td>' + m_text + '</td><td>' + r_text + '</td></tr>';
l_text = '';
l_text = '';
m_text = '';
m_text = '';
}
}
html_txt += '</table>';
html_txt += '</table>';
console.log(html_txt);
queryResultsElement.innerHTML = html_txt;
queryResultsElement.innerHTML = html_txt;
}
}
});
});
function getResultInfos(matchObject) {
function getResultInfos(matchObject
, info_key, slice
) {
infos =
''
;
var
infos =
[]
;
for (
var k
ey in
matchObject) {
for (
let [infoK
ey
,
in
foValue] of Object.entries(
matchObject)
)
{
var token =
matchObject[key]
;
var token =
infoValue
;
for (
var
key in token) {
for (
let
key in token) {
infos
+=
token[key][
'word'] + ' '
;
infos
.push(
token[key][
info_key])
;
}
}
var infos = infos;
}
}
return infos
if (slice) {
console.log(infos);
var infos = infos[slice];
return infos;
} else {
return infos;
}
}
}
</script>
</script>
{% endblock %}
{% endblock %}
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