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
7dd55c47
Commit
7dd55c47
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Code update to new request system
parent
baf06d31
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/events.py
+23
-19
23 additions, 19 deletions
app/corpora/events.py
app/templates/corpora/corpus_analysis.html.j2
+1
-1
1 addition, 1 deletion
app/templates/corpora/corpus_analysis.html.j2
with
24 additions
and
20 deletions
app/corpora/events.py
+
23
−
19
View file @
7dd55c47
...
@@ -29,8 +29,10 @@ def init_corpus_analysis(corpus_id):
...
@@ -29,8 +29,10 @@ def init_corpus_analysis(corpus_id):
if
not
(
corpus
.
creator
==
current_user
or
current_user
.
is_administrator
()):
if
not
(
corpus
.
creator
==
current_user
or
current_user
.
is_administrator
()):
socketio
.
emit
(
'
init_corpus_analysis
'
,
'
[ERROR 403]: Forbidden
'
,
socketio
.
emit
(
'
init_corpus_analysis
'
,
'
[ERROR 403]: Forbidden
'
,
room
=
request
.
sid
)
room
=
request
.
sid
)
if
str
(
corpus_id
)
not
in
analysis_sessions
:
if
corpus_id
not
in
analysis_sessions
:
analysis_sessions
[
str
(
corpus_id
)]
=
[
request
.
sid
]
analysis_sessions
[
corpus_id
]
=
[
request
.
sid
]
else
:
analysis_sessions
[
corpus_id
].
append
(
request
.
sid
)
socketio
.
start_background_task
(
observe_corpus_analysis_connection
,
socketio
.
start_background_task
(
observe_corpus_analysis_connection
,
current_app
.
_get_current_object
(),
current_app
.
_get_current_object
(),
corpus_id
,
request
.
sid
)
corpus_id
,
request
.
sid
)
...
@@ -48,8 +50,8 @@ def recv_query(message):
...
@@ -48,8 +50,8 @@ def recv_query(message):
analysis_client
.
cqp_query
(
corpus
,
query_subcorpus
,
query
)
analysis_client
.
cqp_query
(
corpus
,
query_subcorpus
,
query
)
"""
Evaluate query results
"""
"""
Evaluate query results
"""
match_corpus
=
'
{}:{}
'
.
format
(
corpus
,
query_subcorpus
)
match_corpus
=
'
{}:{}
'
.
format
(
corpus
,
query_subcorpus
)
match_num
=
analysis_client
.
cqp_subcorpus_size
(
match_corpus
)
match_num
=
min
(
int
(
message
[
'
hits_per_page
'
])
-
1
,
match_num
=
min
(
int
(
message
[
'
hits_per_page
'
])
-
1
,
match_num
)
analysis_client
.
cqp_subcorpus_size
(
match_corpus
)
)
if
match_num
==
0
:
if
match_num
==
0
:
print
(
'
No matches found.
'
)
print
(
'
No matches found.
'
)
exit
()
exit
()
...
@@ -63,9 +65,20 @@ def recv_query(message):
...
@@ -63,9 +65,20 @@ def recv_query(message):
analysis_client
.
cqp_dump_subcorpus
(
match_corpus
,
CONST_FIELD_MATCHEND
,
0
,
match_num
-
1
))
analysis_client
.
cqp_dump_subcorpus
(
match_corpus
,
CONST_FIELD_MATCHEND
,
0
,
match_num
-
1
))
matches
=
[]
matches
=
[]
for
match_start
,
match_end
in
match_boundaries
:
for
match_start
,
match_end
in
match_boundaries
:
tokens
=
analysis_client
.
cl_cpos2str
(
'
{}.word
'
.
format
(
corpus
),
range
(
match_start
,
match_end
+
1
))
matches
.
append
({
'
cpos_list
'
:
list
(
range
(
match_start
,
match_end
+
1
))})
pos
=
analysis_client
.
cl_cpos2str
(
'
{}.pos
'
.
format
(
corpus
),
range
(
match_start
,
match_end
+
1
))
cpos_list
=
[]
matches
.
append
({
'
tokens
'
:
tokens
,
'
pos
'
:
pos
})
for
match
in
matches
:
cpos_list
=
cpos_list
+
match
[
'
cpos_list
'
]
cpos_list
=
list
(
set
(
cpos_list
))
pos_list
=
analysis_client
.
cl_cpos2str
(
'
{}.pos
'
.
format
(
corpus
),
cpos_list
)
word_list
=
analysis_client
.
cl_cpos2str
(
'
{}.word
'
.
format
(
corpus
),
cpos_list
)
foo
=
{}
for
cpos
,
pos
,
word
in
zip
(
cpos_list
,
pos_list
,
word_list
):
foo
[
cpos
]
=
{
'
pos
'
:
pos
,
'
word
'
:
word
}
for
match
in
matches
:
match
[
'
pos_list
'
]
=
[
foo
[
cpos
][
'
pos
'
]
for
cpos
in
match
[
'
cpos_list
'
]]
match
[
'
word_list
'
]
=
[
foo
[
cpos
][
'
word
'
]
for
cpos
in
match
[
'
cpos_list
'
]]
match
.
pop
(
'
cpos_list
'
,
None
)
logger
.
warning
(
matches
)
logger
.
warning
(
matches
)
socketio
.
emit
(
'
query_results
'
,
matches
,
room
=
request
.
sid
)
socketio
.
emit
(
'
query_results
'
,
matches
,
room
=
request
.
sid
)
...
@@ -81,20 +94,11 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
...
@@ -81,20 +94,11 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
analysis_clients
[
session_id
]
=
analysis_client
analysis_clients
[
session_id
]
=
analysis_client
socketio
.
emit
(
'
init_corpus_analysis
'
,
'
Ready
'
,
room
=
session_id
)
socketio
.
emit
(
'
init_corpus_analysis
'
,
'
Ready
'
,
room
=
session_id
)
while
session_id
in
connected_sessions
:
while
session_id
in
connected_sessions
:
'''
try:
analysis_client.ctrl_ping()
except Exception as err:
logger.warning(
'
[Exception]: {}
'
.format(err))
break
else:
socketio.sleep(3)
'''
socketio
.
sleep
(
3
)
socketio
.
sleep
(
3
)
analysis_client
.
ctrl_bye
()
analysis_client
.
ctrl_bye
()
analysis_clients
.
pop
(
session_id
,
None
)
analysis_clients
.
pop
(
session_id
,
None
)
analysis_sessions
[
str
(
corpus_id
)
].
remove
(
session_id
)
analysis_sessions
[
corpus_id
].
remove
(
session_id
)
if
not
analysis_sessions
[
str
(
corpus_id
)
]:
if
not
analysis_sessions
[
corpus_id
]:
analysis_sessions
.
pop
(
str
(
corpus_id
)
,
None
)
analysis_sessions
.
pop
(
corpus_id
,
None
)
corpus
.
status
=
'
stop analysis
'
corpus
.
status
=
'
stop analysis
'
db
.
session
.
commit
()
db
.
session
.
commit
()
This diff is collapsed.
Click to expand it.
app/templates/corpora/corpus_analysis.html.j2
+
1
−
1
View file @
7dd55c47
...
@@ -78,7 +78,7 @@ socket.on('query_results', function(json_results) {
...
@@ -78,7 +78,7 @@ socket.on('query_results', function(json_results) {
console.log(json_results)
console.log(json_results)
var queryResultsElement = document.getElementById("query-results");
var queryResultsElement = document.getElementById("query-results");
for (let json_result of json_results) {
for (let json_result of json_results) {
queryResultsElement.innerHTML += json_result['
tokens
'] + '<br>';
queryResultsElement.innerHTML += json_result['
word_list
'] + '<br>';
}
}
});
});
</script>
</script>
...
...
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