Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tenet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
tenet
Commits
746f7af1
Commit
746f7af1
authored
1 year ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
New Transduction Query Builder Method to select distinct row
parent
9374e4f8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tenet/transduction/query_builder.py
+39
-1
39 additions, 1 deletion
tenet/transduction/query_builder.py
with
39 additions
and
1 deletion
tenet/transduction/query_builder.py
+
39
−
1
View file @
746f7af1
...
...
@@ -108,6 +108,44 @@ def generate_select_query(graph, select_data_list, clause_list):
return
query_code
def
generate_select_distinct_query
(
graph
,
select_data_list
,
clause_list
):
"""
Generate a SELECT Sparql query with a select part (from select_data_list)
and a clause part (from clause_list).
Parameters
----------
graph : RDFLIB Graph
target graph of the query.
select_data_list : List
list of sparql variables for the select part.
clause_list : List
list of clauses (as rdf triples or string) for the clause part.
Returns
-------
query_code : SPARQL query (string)
SELECT Sparql query.
"""
prefix
=
get_prefix_def
()
first
=
True
select_data_part
=
''
for
data
in
select_data_list
:
if
not
first
:
select_data_part
+=
'
'
select_data_part
+=
f
'
{
data
}
'
first
=
False
clause_part
=
__define_clause_part
(
graph
,
clause_list
)
query_code
=
f
'
{
prefix
}
'
query_code
+=
f
'
\n
SELECT DISTINCT
{
select_data_part
}
'
query_code
+=
f
'
\n
WHERE {{
{
clause_part
}
\n
}}
'
return
query_code
#==============================================================================
# Method to generate a generic SPARQL ASK query
...
...
This diff is collapsed.
Click to expand it.
Aurélien Lamercerie
@alam
mentioned in issue
#163
·
1 year ago
mentioned in issue
#163
mentioned in issue #163
Toggle commit list
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