Jiemingy project 4 draft#86
Conversation
| ?item wdt:P31 wd:Q5. #instance of human. | ||
| ?item wdt:P27 wd:Q148. # a citizen of PR of China. | ||
| ?item wdt:P106 wd:Q82955. # politician. | ||
| {?item wdt:P22 ?father. |
There was a problem hiding this comment.
Use the VALUES keyword instead of UNION here. UNION increases the computational complexity of the query significantly, VALUES doesn't.
Otherwise, I'm liking this kata :)
There was a problem hiding this comment.
Hi John,
Can VALUES keywords work for predicate? I plan to make the object as constant, such as wd:Q82955, and the predicate a variable. For example, ?item ?relation wd:Q82955 #as politician, and then use VALUES keywords for ?relation, qualifying the relations by father, mother, spouse, etc. But I tried, and it does not work.
Bests,
Jieming
There was a problem hiding this comment.
@Jiemingy Yep! For example, instead of:
UNION {?item wdt:P25 ?mother.
?mother wdt:P106 wd:Q82955.}
UNION {?item wdt:P8810 ?parent.
?parent wdt:P106 wd:Q82955.}
You can write:
VALUES ?predicate (wdt:P25 wdt:P8810)
SELECT...WHERE...
?item ?predicate ?momordad .
?momordad wdt:P106 wd:Q82955.
There was a problem hiding this comment.
Great! Thank you!
_Jieming
| FILTER (?dob >= "1949-10-01"^^xsd:dateTime). # item is borned later than Jan.1, 1949. | ||
|
|
||
|
|
||
| SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], zh". } # Helps get the label in your language, if not, then zh language |
There was a problem hiding this comment.
Folks now recommend not to use "zh" alone, but instead specify the region or dialect, etc. See here: https://www.w3.org/International/articles/language-tags/
| ?item wdt:P31 wd:Q613142. #item is an instance of law firm. | ||
| ?item wdt:P17 wd:Q30. #item is a US company. | ||
|
|
||
| FILTER (!{?item wdt:P31 wd:Q163740.} UNION {?item wdt:P31 wd:Q613142}). #exclude an institute which is both a law firm and a nonprofit orginzation. |
There was a problem hiding this comment.
Why "!" rather than "FILTER NOT EXISTS"?
There was a problem hiding this comment.
Hi John,
Thank you for the good idea! I didn't think about that.
Bests,
Jieming
|
|
||
| FILTER (!{?item wdt:P31 wd:Q163740.} UNION {?item wdt:P31 wd:Q613142}). #exclude an institute which is both a law firm and a nonprofit orginzation. | ||
|
|
||
| OPTIONAL { |
There was a problem hiding this comment.
These OPTIONAL clauses operate as conditionals. So this should read more like "if the city is in the law firm's headquarter location"
|
Hi John, Thank you very much for the comments! I will work on the revision. Bests, |
Dear John,
This is my submission of project 4.
Bests,
Jieming