User:Data Gamer/Queries
given name
editHello. I want two queries.
1) A list for all persons that country of citizenship (P27) -> Cyprus (Q229), without given name (P735)
2) A list with all values of given name (P735) for persons that country of citizenship (P27) -> Cyprus (Q229)
Data Gamer play 12:20, 10 July 2020 (UTC)
- @Data Gamer: For the first:
- Try it!
SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5; wdt:P27 wd:Q229 . FILTER NOT EXISTS { ?item wdt:P735 [] } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
- And the second:
- Try it!
SELECT ?givenName ?givenNameLabel (COUNT(DISTINCT ?item) AS ?count) WHERE { ?item wdt:P31 wd:Q5; wdt:P27 wd:Q229 . ?item wdt:P735 ?givenName . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?givenName ?givenNameLabel ORDER BY DESC(?count)
- (That's ordered by how common they are). --Oravrattas (talk) 12:51, 10 July 2020 (UTC)
Thanks!! Data Gamer play 12:57, 10 July 2020 (UTC)
SELECT ?gn ?gnLabel ?gnDescription ?ws ?nl (COUNT(?item) as ?count) (SAMPLE(?item) as ?sample) (SAMPLE(?itemLabel) as ?sampleLabel)
{
?item wdt:P27 wd:Q229 .
?item wdt:P31 wd:Q5 .
?item wdt:P735 ?gn .
OPTIONAL { ?gn wdt:P1705 ?nl }
OPTIONAL { ?gn wdt:P282 / wdt:P506 ?ws }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?gn ?gnLabel ?gnDescription ?ws ?nl
ORDER BY DESC(?count) ?gn ?ws
@Data Gamer: Supposedly most if not all people with that nationality should have a given name with writing system Greek alphabet (Q8216).
At Wikidata, this should be a separate item from items for names with Latin script, e.g. Q19826474 and Q64698701, I just had to unmerge now.
The second query highlights that
- some people's item use the wrong give name item
- some given name items still need to be corrected or separate items to be created for Greek alphabet names.
Hope that helps. --- Jura 13:03, 10 July 2020 (UTC)
Humans
editHard to explain...
Example 1
- Municipal Council of Paphos Municipality Elections (Q93558099) -> subclass of (P279) -> Cypriot Municipal Councils Elections (Q92282921)
- 1991 Municipal Council of Paphos Municipality Elections (Q93928618) -> instance of (P31) -> Municipal Council of Paphos Municipality Elections (Q93558099)
- 1991 Municipal Council of Paphos Municipality Elections (Q93928618) -> participant (P710) -> Georgios Achilleos (Q93929496)
- Georgios Achilleos (Q93929496) -> instance of (P31) -> human (Q5)
Example 2
- Municipal Council of Latsia Municipality Elections (Q94553400) -> subclass of (P279) -> Cypriot Municipal Councils Elections (Q92282921)
- 1996 Municipal Council of Latsia Municipality Elections (Q94559707) -> instance of (P31) -> Municipal Council of Latsia Municipality Elections (Q94553400)
- 1996 Municipal Council of Latsia Municipality Elections (Q94559707) -> participant (P710) -> F. Michael (Q94563356)
- F. Michael (Q94563356) -> instance of (P31) -> human (Q5)
I want to search all items that they have subclass of (P279) an item that it has instance of (P31) -> Cypriot Municipal Councils Elections (Q92282921). From all these items I want to find all the values of participant (P710) that have instance of (P31) -> human (Q5). Georgios Achilleos (Q93929496) and F. Michael (Q94563356) must be in the list. I want the list to have only the persons items (to use it with Wikidata list). Data Gamer play 12:56, 19 July 2020 (UTC)
- @Data Gamer: --Dipsacus fullonum (talk) 13:30, 19 July 2020 (UTC)Try it!
SELECT DISTINCT ?participant WHERE { ?municipality_elections wdt:P279 wd:Q92282921 . ?election wdt:P31 ?municipality_elections . ?election wdt:P710 ?participant . ?participant wdt:P31 wd:Q5 . }
Thanks! Data Gamer play 13:37, 19 July 2020 (UTC)
With out P3602
editHello. I want to find all items that have:
position held (P39) -> member of the House of Representatives of Cyprus (Q19801674) with qualifier elected in (P2715) -> 1976 Cypriot legislative election (Q3566196), but they don't have candidacy in election (P3602) -> 1976 Cypriot legislative election (Q3566196) . Data Gamer play 11:02, 22 July 2020 (UTC)
- @Data Gamer: I made the query so it can be used for all Cypriot legislative elections at once if you remove the line with the FILTER keyword. --Dipsacus fullonum (talk) 11:25, 22 July 2020 (UTC)Try it!
SELECT DISTINCT ?person ?personLabel ?election ?electionLabel WHERE { ?election wdt:P31 wd:Q22275878 . # ?election is a Cypriot legislative election ?person p:P39 / pq:P2715 ?election . MINUS { ?person wdt:P3602 ?election . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],el,en". } FILTER (?election = wd:Q3566196) # Only 1976 Cypriot legislative election }
Thanks! If I remove the line with the FILTER keyword then I get all the person's that were parliament members but they don't have any statement with candidacy in election (P3602). But some persons may have candidacy in election (P3602) with other elections (not legislative), so they will not be in the list. Filter is necessary. I will just change the legislative elections item to add the statement to all parliament members. Thanks again! Data Gamer play 11:47, 22 July 2020 (UTC)
- @Data Gamer: No, the MINUS clause will not remove persons with any value of candidacy in election (P3602) but only the cases where the value is the same as for the elected in (P2715) qualifier. That is because they share the variable
?election
which can only be bound to one value at a time. --Dipsacus fullonum (talk) 12:21, 22 July 2020 (UTC)
Given name in greek
editHello. I am trying to correct Greek names in Wikidata. But I will need help with queries. For start, I want four queries:
1) All items that instance of (P31) -> male given name (Q12308941) or instance of (P31) -> given name (Q202444), and language of work or name (P407) -> Modern Greek (Q36510) or language of work or name (P407) -> Greek (Q9129) or language of work or name (P407) -> Cypriot Greek (Q245899) but with no other value with language of work or name (P407).
2) All items that instance of (P31) -> male given name (Q12308941) or instance of (P31) -> given name (Q202444), and language of work or name (P407) -> Modern Greek (Q36510) or language of work or name (P407) -> Greek (Q9129) or language of work or name (P407) -> Cypriot Greek (Q245899) but with other values with language of work or name (P407).
3) All items that instance of (P31) -> male given name (Q12308941) or instance of (P31) -> given name (Q202444), and native label (P1705) -> something in el language but with no other value with native label (P1705).
4) All items that instance of (P31) -> male given name (Q12308941) or instance of (P31) -> given name (Q202444), and native label (P1705) -> something in el language but with other values with native label (P1705).
Data Gamer play 09:48, 23 July 2020 (UTC)
- @Data Gamer: 1) Try it!
SELECT ?item WHERE { VALUES ?name { wd:Q12308941 wd:Q202444 } VALUES ?lang { wd:Q36510 wd:Q9129 wd:Q245899 } ?item wdt:P31 ?name . ?item wdt:P407 ?lang . FILTER NOT EXISTS { ?item wdt:P407 ?other_lang . FILTER (?other_lang NOT IN( wd:Q36510, wd:Q9129, wd:Q245899 ) ) } }
- 2) --Dipsacus fullonum (talk) 10:38, 23 July 2020 (UTC)Try it!
SELECT ?item WHERE { VALUES ?name { wd:Q12308941 wd:Q202444 } VALUES ?lang { wd:Q36510 wd:Q9129 wd:Q245899 } ?item wdt:P31 ?name . ?item wdt:P407 ?lang . FILTER EXISTS { ?item wdt:P407 ?other_lang . FILTER (?other_lang NOT IN( wd:Q36510, wd:Q9129, wd:Q245899 ) ) } }
- 3) Try it!
SELECT DISTINCT ?item WHERE { VALUES ?name { wd:Q12308941 wd:Q202444 } ?item wdt:P31 ?name . ?item wdt:P1705 ?native_label . FILTER (LANG(?native_label) = "el") FILTER NOT EXISTS { ?item wdt:P1705 ?other_native_label . FILTER (?other_native_label != ?native_label ) } }
- 4) --Dipsacus fullonum (talk) 10:43, 23 July 2020 (UTC)Try it!
SELECT DISTINCT ?item WHERE { VALUES ?name { wd:Q12308941 wd:Q202444 } ?item wdt:P31 ?name . ?item wdt:P1705 ?native_label . FILTER (LANG(?native_label) = "el") FILTER EXISTS { ?item wdt:P1705 ?other_native_label . FILTER (?other_native_label != ?native_label ) } }
Thanks!! Data Gamer play 11:11, 23 July 2020 (UTC)
- @Data Gamer: probably you would be interested in a list of languages which are used in addition to different variants of Greek in given names:
SELECT ?lang ?langLabel (COUNT(?item) AS ?cnt)
WHERE
{
VALUES ?name { wd:Q12308941 wd:Q202444 wd:Q11879590}
VALUES ?fromlang { wd:Q36510 wd:Q9129 wd:Q245899 wd:Q2042538}
?item wdt:P31 ?name .
?item wdt:P407 ?fromlang.
?item wdt:P407 ?lang .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?lang ?langLabel
Infovarius (talk) 00:00, 25 July 2020 (UTC)