def do_query query SELECT WHERE cc rdf type http dbpedia org class yag

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def do_query():
query = """
SELECT * WHERE {
{
?cc rdf:type <http://dbpedia.org/class/yago/State108168978>.
OPTIONAL {
?cc dbpedia2:abstract ?abstract_en.
FILTER ( lang(?abstract_en) = 'en' )
}
OPTIONAL {
?cc dbpedia2:abstract ?abstract_ru.
FILTER ( lang(?abstract_ru) = 'ru' )
}
}
UNION {
?cc dbpedia2:cctld ?tld.
?tld dbpedia2:name ?tld_name.
FILTER ( lang(?tld_name) = 'en' )
OPTIONAL {
?cc dbpedia2:abstract ?abstract_en.
FILTER ( lang(?abstract_en) = 'en' )
}
OPTIONAL {
?cc dbpedia2:abstract ?abstract_ru.
FILTER ( lang(?abstract_ru) = 'ru' )
}
}
}
ORDER BY ?cc
"""
return util.sparql_query_all(query, debug=False)