More examples
Last updated
Last updated
Here are some examples of PyQL program.
Question
Is the ship with the largest payload among Cristóbal Colón, HMS Good Hope, and SMS Scharnhorst the slowest one?
Program
a=PyQL()
a.add_assignment(['Q1140473','Q1032039','Q533999'],'x2')
a.add_quantity('x2','P2109','x0')
a.add_max('x0')
sparql generated by the program above
SELECT ?x0 {
{
SELECT DISTINCT * {
Values ?x1 {wd:Q1140473 wd:Q1032039 wd:Q533999}
?x1 p:P2109 ?x2.
?x2 psv:P2109 ?x3.
Question
How many times does the difference in the longest span of Dardanelles Bridge and Morandi Bridge of that of Millau Viaduct?
Program
a=PyQL()
a.add_quantity('Q8077503','P2787','x4')
a.add_quantity('Q3907993','P2787','x3')
a.add_quantity('Q99236','P2787','x5')
a.add_bind(sub('x4','x3'),'x1')
a.add_bind(abs('x1'),'x2')
a.add_bind(div('x2','x5'),'x0')
print(a.sparql)
sparql generated by the program above
SELECT DISTINCT ?x0 {
wd:Q8077503 p:P2787 ?x1.
?x1 psv:P2787 ?x2.
?x2 wikibase:quantityAmount ?x3.
wd:Q3907993 p:P2787 ?x4.
?x4 psv:P2787 ?x5.
?x5 wikibase:quantityAmount ?x6.
wd:Q99236 p:P2787 ?x7.
?x7 psv:P2787 ?x8.
?x8 wikibase:quantityAmount ?x9.
BIND( ((?x3 - ?x6)) AS ?x10 )
BIND( (ABS(?x10)) AS ?x11 )
BIND( (?x11 / ?x9) AS ?x0 )
}