Skip to content

Jiemingy project 4 draft#86

Open
Jiemingy wants to merge 11 commits into
johnbeve:mainfrom
Jiemingy:Jiemingy-project-4-draft
Open

Jiemingy project 4 draft#86
Jiemingy wants to merge 11 commits into
johnbeve:mainfrom
Jiemingy:Jiemingy-project-4-draft

Conversation

@Jiemingy
Copy link
Copy Markdown
Collaborator

@Jiemingy Jiemingy commented Apr 3, 2023

Dear John,

This is my submission of project 4.

Bests,
Jieming

Copy link
Copy Markdown
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?

Comment thread Project 4/README.md Outdated
?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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread Project 4/README.md Outdated
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
Copy Markdown
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/

Comment thread Project 4/README.md Outdated
?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
Copy Markdown
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
Copy Markdown
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

Comment thread Project 4/README.md

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
Copy Markdown
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
Copy Markdown
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