Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jiemingy project 4 draft #86

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Jiemingy
Copy link
Collaborator

@Jiemingy Jiemingy commented Apr 3, 2023

Dear John,

This is my submission of project 4.

Bests,
Jieming

Copy link
Owner

@johnbeve johnbeve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 38 points?

?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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "!" rather than "FILTER NOT EXISTS"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These OPTIONAL clauses operate as conditionals. So this should read more like "if the city is in the law firm's headquarter location"

@Jiemingy
Copy link
Collaborator Author

Hi John,

Thank you very much for the comments! I will work on the revision.
In addition, can I add one or two Katas this week to rise my points?

Bests,
Jieming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants