User:Swpb

From Wikidata
Jump to navigation Jump to search

Wikipedia userpage: w:User:Swpb
Modeling Principles

Babel

[edit]
Babel user information
en-N This user has a native understanding of English.
es-1 Esta persona tiene un conocimiento básico del español.
de-0 Dieser Benutzer beherrscht Deutsch nicht (oder versteht es nur mit beträchtlichen Schwierigkeiten).
fr-0 Cet utilisateur n’a aucune connaissance en français (ou le comprend avec de grandes difficultés).
en-GB-4 This user has near native speaker knowledge of British English.
en-US-N This user has a native understanding of American English.
ru-0 Этот участник не владеет русским языком (или понимает его с трудом).
zh-0 这位用户不懂或很难理解中文
Users by language

Main

[edit]

Useful properties / Property explorer

Basic concepts

User:Swpb/sandbox

{{subst:User:Swpb/bmp-msg|url=|property|superclass|altProp_or_altItem|custom_msg=}}

User:Mateusz Konieczny/failing testcases

Category:Templates

Ideas

[edit]

Lexeme deriviations

[edit]

Binary oppositions

[edit]

Opposite of

[edit]

Of

[edit]

Useful pages

[edit]

Automation

[edit]

Properties

[edit]

Constraints

[edit]

Help

[edit]

Development wishlist

[edit]

Query

[edit]
SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item wdt:P31/wdt:P279* wd:Q3947.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
} LIMIT 5

SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item p:P794 ?x .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}

SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item p:P106 [
    pq:P794 ?x].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

SELECT DISTINCT ?item ?itemLabel ?val WHERE {
  ?item ?x [pq:P1480 wd:Q21067468].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

#Items with "instance of" wd
SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q27949697 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

#A UNION
SELECT DISTINCT ?item ?itemLabel ?val WHERE {
  {?item ?x [pq:P1480 wd:Q4895105]} 
  UNION {?item ?x [pq:P1480 wd:Q4676846]}.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

SELECT DISTINCT ?item ?itemLabel ?pq WHERE {
  ?item ?x [?pq wd:Q4676846].
  FILTER ( ?pq != pq:P3831 )
  FILTER ( ?pq != pq:P2868 )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

SELECT DISTINCT ?item ?itemLabel 
WHERE 
{
  {
  ?item wdt:P279 wd:Q52161601.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  } UNION {
  ?item wdt:P366 wd:Q52161601.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }
}

SELECT DISTINCT ?item ?itemLabel ?val WHERE {
  ?item ?x [pq:P5102 wd:Q41719].
  FILTER NOT EXISTS {
   ?item wdt:P1148 ?number.
   }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

# Multiple values of same property:
SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P461 ?x.
      ?item p:P461 ?y.
    FILTER (?x != ?y)
    }
  }
}

#Statement with qualifier
SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item p:P2302 ?statement1.
  ?statement1 ps:P2302 wd:Q21510856.
  ?statement1 pq:P2306 wd:P642.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

#One of several values:
SELECT DISTINCT ?item ?itemLabel WHERE {
  VALUES ?nature {wd:Q110143752 wd:Q28962312 wd:Q28962310}
  ?item p:P279 [pq:P5102 ?nature].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

#Multiple statement values:
SELECT DISTINCT ?item ?itemLabel WHERE {
  {
    SELECT ?item WHERE { ?item (wdt:P279/wdt:P279/(wdt:P279?)/(wdt:P279?)/(wdt:P279?)) wd:Q7048977, wd:Q112276019. }
    LIMIT 300
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,es,fr,de". }
}

#Frequency of different values:
SELECT ?val ?valLabel (COUNT(?item) AS ?count) WHERE {
  {?item wdt:P5135 ?val.}
  UNION
  {?item wdt:P5136 ?val.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}
GROUP BY ?val ?valLabel
ORDER BY DESC(?count)

#None-of constraints by number of "item of property qualifier" values
SELECT ?QualStatement ?count WHERE {
  {
    SELECT ?QualStatement (COUNT(?item) AS ?count)
    WHERE {
      ?Properties p:P2302 ?QualStatement.
      ?QualStatement ps:P2302 wd:Q52558054.
      ?QualStatement pq:P2305 ?item.
    }
    GROUP BY ?QualStatement
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)

#Item labels not matching a regex
SELECT ?item ?itemLabel 
WHERE 
{
  ?item wdt:P31 wd:Q174923;
        rdfs:label ?itemLabel.        [or schema:description]
  FILTER (lang(?itemLabel) = "en").
  FILTER (!regex(?itemLabel, "illusion$")).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}

***** Properties can be OR'ed: P1|P2|P3 *****

# Statements WITHOUT qualifiers
SELECT DISTINCT ?item ?itemLabel 
WHERE 
{
  ?item p:P2670 ?stat .
  filter not exists {?stat ?predicate ?value . 
                    ?property wikibase:qualifier ?predicate . }
  ?item wdt:P279 []. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
  }

#Any quals present?
SELECT DISTINCT ?item ?itemLabel ?qual ?qualval
WHERE 
{
  ?item p:P106 ?statement.
  ?statement ps:P106 wd:Q327321.
  ?statement ?qual ?qualval.
  ?qualifierproperty wikibase:qualifier ?qual.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}

#Filtering out statements with unknown value
FILTER (! wikibase:isSomeValue(?class))

#Select property by value type
?prop wikibase:propertyType wikibase:ExternalId .

# References
SELECT ?item ?statedin ?retrieved
WHERE {
  ?item p:P31 ?statement.
  ?statement ps:P31 wd:Q15642541.
  OPTIONAL {?statement prov:wasDerivedFrom/pr:P248 ?statedin.}
  OPTIONAL {?statement prov:wasDerivedFrom/pr:P813 ?retrieved.}
}

======================================================================

# All properties used in references on a certain set of statements
SELECT ?prop ?refpropertyLabel ?proptypeLabel (COUNT(?item) as ?count)
WHERE {
  ?item p:P31 ?statement.

  ?statement prov:wasDerivedFrom ?provenance.
  ?provenance ?prop ?propval.
  ?refproperty wikibase:reference ?prop.
  ?refproperty wikibase:propertyType ?proptype.

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
} GROUP BY ?prop ?refpropertyLabel ?proptypeLabel
ORDER BY DESC(?count)

#All properties used as qualifiers on a certain set of statements
SELECT ?qual ?qualifierpropertyLabel ?proptypeLabel (COUNT(?item) as ?count)
WHERE {
  ?item p:P31 ?statement.
  ?statement ps:P31 wd:Q50030.

  ?statement ?qual ?qualval.
  ?qualifierproperty wikibase:qualifier ?qual.
  ?qualifierproperty wikibase:propertyType ?proptype.

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
} GROUP BY ?qual ?qualifierpropertyLabel ?proptypeLabel
ORDER BY DESC(?count)

# Return values of selected reference properties
SELECT ?item ?S813 ?S854
WHERE {
  ?statement prov:wasDerivedFrom ?provenance.
  ?provenance pr:P813 ?S813.
  ?provenance pr:P854 ?S854.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}

# All statements WITH references or qualifiers
SELECT DISTINCT ?item ?itemLabel
WHERE {
  VALUES ?class {wd:Q50030}
  {
    ?statement prov:wasDerivedFrom ?provenance.
    ?provenance ?refprop ?val.
  } UNION {
    ?statement ?qualprop ?any.
    ?qualifierproperty wikibase:qualifier ?qualprop.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}

# All statements WITHOUT any references or qualifiers
SELECT DISTINCT ?item ?itemLabel
WHERE {

  MINUS {
    ?statement prov:wasDerivedFrom ?provenance.
    ?provenance ?refprop ?val.
  }
  MINUS {
    ?statement ?qualprop ?any.
    ?qualifierproperty wikibase:qualifier ?qualprop.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}

======================================================================

# All statements with a specified value and qualifier, but any main property
SELECT ?item ?itemLabel ?propertyLabel ?value ?valueLabel  where {
  ?item ?predicate_p ?statement . 
  ?property wikibase:claim ?predicate_p .
  ?property wikibase:statementProperty ?predicate_ps .
  ?statement ?predicate_ps wd:Q1193470 . 
  ?statement pq:P642 ?value . 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}

======================================================================
#Quantity with unit
  ?statement pqv:P3629 ?ageFull.
  ?ageFull wikibase:quantityAmount ?agenumber.
  ?ageFull wikibase:quantityUnit ?unit.

Matching statements with ALL quals and refs listed (OUTDATED): [12]

Matching statements with ALL quals and refs listed (handles multiple P642 values): [13]

Count of statements with same property and value: [14]

Count of reference blocks on each statement: [15]

Other

[edit]

Templates

[edit]