Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TextToscQLDataset
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
TDDE19-2022-1
TextToscQLDataset
Commits
0ec34295
Commit
0ec34295
authored
1 year ago
by
Cyrille Berger
Browse files
Options
Downloads
Patches
Plain Diff
update script to include the model in the dataset
parent
392503ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generate.py
+41
-4
41 additions, 4 deletions
generate.py
with
41 additions
and
4 deletions
generate.py
+
41
−
4
View file @
0ec34295
#!/usr/bin/python3
import
itertools
import
sys
#
# ./generate.py [options]
# --validate indicates that you want to validate and show the model for the queries generated by the script
# --localhost indicates that you want to use a scql_analyser server located on this computer (default is to use terra8 webserver)
# --no-model indicates that you want to generate dataset without generating models
validate
=
'
--validate
'
in
sys
.
argv
localhost
=
'
--localhost
'
in
sys
.
argv
nomodel
=
'
--no-model
'
in
sys
.
argv
if
localhost
:
WEBSERVER_URI
=
'
http://localhost:8181/api/get_model
'
WEBSERVER_AUTH
=
None
else
:
WEBSERVER_URI
=
'
http://terra8.ida.liu.se/scql_analyser/api/get_model
'
WEBSERVER_AUTH
=
(
'
TDDE19
'
,
'
TDDE19
'
)
class
select_query
:
def
__init__
(
self
,
variables
,
constraints
,
restrictions
):
...
...
@@ -50,13 +71,23 @@ def add_query(queries, sentence_fragments, query_def):
for
s
in
sentences
:
queries
.
append
([
s
,
query_def
])
return
queries
def
generate_scql
(
queries
):
# Take a list of queries and generate the scQL query
for
s
,
q
in
queries
:
print
(
s
)
print
(
q
.
to_scql
())
def
generate_model_scql
(
queries
):
import
requests
# Take a list of queries and generate the scQL query
for
s
,
q
in
queries
:
print
(
s
)
print
(
q
.
to_scql
())
payload
=
{
'
query
'
:
q
.
to_scql
()}
r
=
requests
.
post
(
WEBSERVER_URI
,
data
=
payload
,
auth
=
WEBSERVER_AUTH
).
json
()
print
(
r
[
"
model
"
][
"
models
"
])
def
validate_scql
(
queries
):
import
requests
from
termcolor
import
colored
...
...
@@ -64,7 +95,8 @@ def validate_scql(queries):
results
=
[]
for
s
,
q
in
queries
:
payload
=
{
'
query
'
:
q
.
to_scql
()}
r
=
requests
.
post
(
'
http://localhost:8181/api/get_model
'
,
data
=
payload
).
json
()
r
=
requests
.
post
(
WEBSERVER_URI
,
data
=
payload
,
auth
=
WEBSERVER_AUTH
).
json
()
# print(r)
if
not
r
[
'
model
'
][
'
parse
'
]:
print
(
f
"
Failed to parse:
'
{
colored
(
q
.
to_scql
(),
'
blue
'
)
}
'
with error
'
{
colored
(
r
[
'
model
'
][
'
message
'
],
'
red
'
)
}
'"
)
...
...
@@ -160,5 +192,10 @@ for bbd in human_sick_injured_statuses:
queries
=
add_query
(
queries
,
[
desire_perf
,
human_in_need_statuses
],
select_query
([[
mu
(
"
scql_types:salient_point
"
),
"
human
"
]],
[[
"
human.klass
"
,
"
=
"
,
mu
(
"
ex:human
"
)],
[
"
human.status
"
,
"
in
"
,
all_human_bad_statuses
]],
[]))
generate_scql
(
queries
)
# validate_scql(queries)
if
validate
:
validate_scql
(
queries
)
elif
nomodel
:
generate_scql
(
queries
)
else
:
generate_model_scql
(
queries
)
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