PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?settlement ?settlementLabel ?settCoords ?centerCoords ?distKm ?distMeters WHERE {
  BIND( wd:Q2180733 AS ?center ) .
  ?center wdt:P625 ?centerCoords .
  ?settlement wdt:P625 ?settCoords .
  ?settlement wdt:P31 ?type .
  FILTER ( ?type IN ( wd:Q532 , wd:Q3957 , wd:Q5153359 ) ) {
    ?settlement wdt:P17 wd:Q213 .
  } UNION {
    ?settlement wdt:P131 * ?admin .
    ?admin wdt:P17 wd:Q213 .
  }
  ?settlement wdt:P31 / wdt:P279 * wd:Q486972 .
  BIND( geof:distance ( ?centerCoords , ?settCoords ) AS ?distKm ) BIND( ?distKm * 1000 AS ?distMeters ) FILTER ( ?distKm <= 35 ) OPTIONAL {
    ?settlement rdfs:label ?settlementLabel .
    FILTER ( LANG( ?settlementLabel ) = "en" )
  }
}
ORDER BY ?distKm

Using entities:
- Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of Republic / is instance of landlocked country / is instance of successor state / is instance of sovereign state / is instance of republic / is instance of country / country in Central Europe / country in Europe / republic in Central Europe
- Mezno (wd:Q2180733): is instance of municipality of the Czech Republic / village in Benešov District of Central Bohemian region
- town (wd:Q3957), also known as small city, small town: is instance of classification of human settlements / is subclass of city or town / is subclass of urban settlement / settlement that is bigger than a village but smaller than a city / settlement that is bigger than a village but smaller than a city / settlement that is smaller than a city but bigger than a large village (or a large borough in some areas)
- human settlement (wd:Q486972), also known as human settlements, inhabited place, settlement, settlements: is instance of first-order class / is subclass of group of structures or buildings / is subclass of geographical object / is subclass of geographical feature / is subclass of populated place / community of any size, in which people live / densely populated geographic location / place of any size, in which people live / place of any size, in which people permanently live
- municipality of the Czech Republic (wd:Q5153359), also known as municipality of Czechia: is instance of legal form / is instance of type of legal entity in the Czech Republic / is subclass of municipality / is subclass of obec / is subclass of administrative territorial entity of the Czech Republic / is subclass of fourth-level administrative division / is subclass of statutory corporation / is subclass of fourth-level administrative country subdivision / administrative territorial division of the Czech Republic / municipality in Czech republic
- village (wd:Q532), also known as small town: is instance of classification of human settlements / is subclass of census subdivision / is subclass of rural settlement / is subclass of locality / small clustered human settlement smaller than a town / small clustered human settlement smaller than a town / small clustered human settlement with a typical population of a few hundred

Using properties:
- located in the administrative territorial entity (wd:P131 as wdt), also known as administrative territorial entity, administrative territory, city, happens in, in, etc.: is subproperty of location / is subproperty of part of / the item is located on the territory of the following administrative entity / the item is located on the territory of the following administrative entity / the item is located on the territory of the following ... the item falls only partially into the administrative entity. / the item is located on the territory of the following ... the item falls only partially into the administrative entity.
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- coordinate location (wd:P625 as wdt), also known as co-ordinate location, co-ordinates, coordinates, co-ords, coords, etc.: coordinates of the subject / coordinates of the subject / geocoordinates of the subject. For Earth, please note that only WGS84 coordinating system is supported at the moment

Answer:
I ran the query above. Summary of the results:
- Center (Mezno, wd:Q2180733) coordinates: POINT(14.644975 49.534590) (from wdt:P625).
- Number of settlements (villages/towns/municipalities) in the Czech Republic within 35 km of Mezno returned by the query: 58.
- The query returns, for each settlement: the settlement IRI, its English label (if available), its coordinate (wdt:P625), the center coordinate (Mezno's wdt:P625), the distance in kilometers (distKm) and meters (distMeters). Results are ordered by distance ascending.

Examples (first 5 rows returned):
- wd:Q2574196 — Borotín — POINT(14.613004 49.505101) — center POINT(14.644975 49.534590) — distKm: 4.00979 — distMeters: 4009.79
- wd:Q631813 — Miličín — POINT(14.661447 49.570761) — center POINT(14.644975 49.534590) — distKm: 4.19387 — distMeters: 4193.87
- wd:Q11862916 — Dědice — POINT(14.712500 49.513300) — center POINT(14.644975 49.534590) — distKm: 5.41846 — distMeters: 5418.46
- wd:Q10769866 — Alenina Lhota — POINT(14.521400 49.526400) — center POINT(14.644975 49.534590) — distKm: 8.96487 — distMeters: 8964.87
- wd:Q368888 — Sedlec-Prčice — POINT(14.532639 49.571905) — center POINT(14.644975 49.534590) — distKm: 9.10404 — distMeters: 9104.04

If you want the full table (all 58 rows) in CSV or another format, or want me to restrict to only items with instance-of specifically 'village' or specifically 'town' (rather than including 'municipality of the Czech Republic'), tell me which format or filter you prefer and I will re-run or export the results.

I ran the query above. Summary of the results:
- Center (Mezno, wd:Q2180733) coordinates: POINT(14.644975 49.534590) (from wdt:P625).
- Number of settlements (villages/towns/municipalities) in the Czech Republic within 35 km of Mezno returned by the query: 58.
- The query returns, for each settlement: the settlement IRI, its English label (if available), its coordinate (wdt:P625), the center coordinate (Mezno's wdt:P625), the distance in kilometers (distKm) and meters (distMeters). Results are ordered by distance ascending.

Examples (first 5 rows returned):
- wd:Q2574196 — Borotín — POINT(14.613004 49.505101) — center POINT(14.644975 49.534590) — distKm: 4.00979 — distMeters: 4009.79
- wd:Q631813 — Miličín — POINT(14.661447 49.570761) — center POINT(14.644975 49.534590) — distKm: 4.19387 — distMeters: 4193.87
- wd:Q11862916 — Dědice — POINT(14.712500 49.513300) — center POINT(14.644975 49.534590) — distKm: 5.41846 — distMeters: 5418.46
- wd:Q10769866 — Alenina Lhota — POINT(14.521400 49.526400) — center POINT(14.644975 49.534590) — distKm: 8.96487 — distMeters: 8964.87
- wd:Q368888 — Sedlec-Prčice — POINT(14.532639 49.571905) — center POINT(14.644975 49.534590) — distKm: 9.10404 — distMeters: 9104.04

If you want the full table (all 58 rows) in CSV or another format, or want me to restrict to only items with instance-of specifically 'village' or specifically 'town' (rather than including 'municipality of the Czech Republic'), tell me which format or filter you prefer and I will re-run or export the results.

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?settlement ?settlementLabel ?settCoords ?centerCoords ?distKm ?distMeters WHERE {
  BIND( wd:Q2180733 AS ?center ) .
  ?center wdt:P625 ?centerCoords .
  ?settlement wdt:P625 ?settCoords .
  ?settlement wdt:P31 ?type .
  FILTER ( ?type IN ( wd:Q532 , wd:Q3957 , wd:Q5153359 ) ) {
    ?settlement wdt:P17 wd:Q213 .
  } UNION {
    ?settlement wdt:P131 * ?admin .
    ?admin wdt:P17 wd:Q213 .
  }
  ?settlement wdt:P31 / wdt:P279 * wd:Q486972 .
  BIND( geof:distance ( ?centerCoords , ?settCoords ) AS ?distKm ) BIND( ?distKm * 1000 AS ?distMeters ) FILTER ( ?distKm <= 35 ) OPTIONAL {
    ?settlement rdfs:label ?settlementLabel .
    FILTER ( LANG( ?settlementLabel ) = "en" )
  }
}
ORDER BY ?distKm

Using entities:
- Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of Republic / is instance of landlocked country / is instance of successor state / is instance of sovereign state / is instance of republic / is instance of country / country in Central Europe / country in Europe / republic in Central Europe
- Mezno (wd:Q2180733): is instance of municipality of the Czech Republic / village in Benešov District of Central Bohemian region
- town (wd:Q3957), also known as small city, small town: is instance of classification of human settlements / is subclass of city or town / is subclass of urban settlement / settlement that is bigger than a village but smaller than a city / settlement that is bigger than a village but smaller than a city / settlement that is smaller than a city but bigger than a large village (or a large borough in some areas)
- human settlement (wd:Q486972), also known as human settlements, inhabited place, settlement, settlements: is instance of first-order class / is subclass of group of structures or buildings / is subclass of geographical object / is subclass of geographical feature / is subclass of populated place / community of any size, in which people live / densely populated geographic location / place of any size, in which people live / place of any size, in which people permanently live
- municipality of the Czech Republic (wd:Q5153359), also known as municipality of Czechia: is instance of legal form / is instance of type of legal entity in the Czech Republic / is subclass of municipality / is subclass of obec / is subclass of administrative territorial entity of the Czech Republic / is subclass of fourth-level administrative division / is subclass of statutory corporation / is subclass of fourth-level administrative country subdivision / administrative territorial division of the Czech Republic / municipality in Czech republic
- village (wd:Q532), also known as small town: is instance of classification of human settlements / is subclass of census subdivision / is subclass of rural settlement / is subclass of locality / small clustered human settlement smaller than a town / small clustered human settlement smaller than a town / small clustered human settlement with a typical population of a few hundred

Using properties:
- located in the administrative territorial entity (wd:P131 as wdt), also known as administrative territorial entity, administrative territory, city, happens in, in, etc.: is subproperty of location / is subproperty of part of / the item is located on the territory of the following administrative entity / the item is located on the territory of the following administrative entity / the item is located on the territory of the following ... the item falls only partially into the administrative entity. / the item is located on the territory of the following ... the item falls only partially into the administrative entity.
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- coordinate location (wd:P625 as wdt), also known as co-ordinate location, co-ordinates, coordinates, co-ords, coords, etc.: coordinates of the subject / coordinates of the subject / geocoordinates of the subject. For Earth, please note that only WGS84 coordinating system is supported at the moment

Execution result:
Got 58 rows and 6 columns, showing the first 5 and last 5 rows below:
| settlement                      | settlementLabel             | settCoords                                  | centerCoords                                | distKm                | distMeters            |
| ------------------------------- | --------------------------- | ------------------------------------------- | ------------------------------------------- | --------------------- | --------------------- |
| Borotín (wd:Q2574196)           | Borotín (lang:en)           | POINT(14.613004 49.505101) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 4.00979 (xsd:decimal) | 4009.79 (xsd:decimal) |
| Miličín (wd:Q631813)            | Miličín (lang:en)           | POINT(14.661447 49.570761) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 4.19387 (xsd:decimal) | 4193.87 (xsd:decimal) |
| Dědice (wd:Q11862916)           | Dědice (lang:en)            | POINT(14.712500 49.513300) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 5.41846 (xsd:decimal) | 5418.46 (xsd:decimal) |
| Alenina Lhota (wd:Q10769866)    | Alenina Lhota (lang:en)     | POINT(14.521400 49.526400) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 8.96487 (xsd:decimal) | 8964.87 (xsd:decimal) |
| Sedlec-Prčice (wd:Q368888)      | Sedlec-Prčice (lang:en)     | POINT(14.532639 49.571905) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 9.10404 (xsd:decimal) | 9104.04 (xsd:decimal) |
| ...                             | ...                         | ...                                         | ...                                         | ...                   | ...                   |
| Divišov (wd:Q854992)            | Divišov (lang:en)           | POINT(14.875843 49.788556) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 32.766 (xsd:decimal)  | 32766 (xsd:decimal)   |
| Trhový Štěpánov (wd:Q1854528)   | Trhový Štěpánov (lang:en)   | POINT(15.013611 49.711537) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 33.0492 (xsd:decimal) | 33049.2 (xsd:decimal) |
| Týnec nad Sázavou (wd:Q1852569) | Týnec nad Sázavou (lang:en) | POINT(14.589891 49.833549) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 33.4781 (xsd:decimal) | 33478.1 (xsd:decimal) |
| Křivsoudov (wd:Q1955504)        | Křivsoudov (lang:en)        | POINT(15.087405 49.633037) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 33.7216 (xsd:decimal) | 33721.6 (xsd:decimal) |
| Třebějice (wd:Q2259116)         | Třebějice (lang:en)         | POINT(14.819800 49.244492) (geo:wktLiteral) | POINT(14.644975 49.534590) (geo:wktLiteral) | 34.6505 (xsd:decimal) | 34650.5 (xsd:decimal) |

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Search for the entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- imdb: <https://www.imdb.com/
- math: <http://www.w3.org/2005/xpath-functions/math#
- ontolex: <http://www.w3.org/ns/lemon/ontolex#
- owl: <http://www.w3.org/2002/07/owl#
- p: <http://www.wikidata.org/prop/
- pq: <http://www.wikidata.org/prop/qualifier/
- pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
- pqv: <http://www.wikidata.org/prop/qualifier/value/
- pr: <http://www.wikidata.org/prop/reference/
- prn: <http://www.wikidata.org/prop/reference/value-normalized/
- prov: <http://www.w3.org/ns/prov#
- prv: <http://www.wikidata.org/prop/reference/value/
- ps: <http://www.wikidata.org/prop/statement/
- psn: <http://www.wikidata.org/prop/statement/value-normalized/
- psv: <http://www.wikidata.org/prop/statement/value/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
- rdfs: <http://www.w3.org/2000/01/rdf-schema#
- ref: <http://www.wikidata.org/reference/
- s: <http://www.wikidata.org/entity/statement/
- schema: <http://schema.org/
- skos: <http://www.w3.org/2004/02/skos/core#
- v: <http://www.wikidata.org/value/
- void: <http://rdfs.org/ns/void#
- wd: <http://www.wikidata.org/entity/
- wdno: <http://www.wikidata.org/prop/novalue/
- wdt: <http://www.wikidata.org/prop/direct/
- wdtn: <http://www.wikidata.org/prop/direct-normalized/
- wikibase: <http://wikiba.se/ontology#
- xsd: <http://www.w3.org/2001/XMLSchema#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- Do not use "SERVICE wikibase:label { bd:serviceParam wikibase:language ..." in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
- Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
- Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] What are the settlements (villages and towns) in the Czech Republic within a 35 km radius from the village of Mezno? Please include their coordinates, the coordinates of the center point, and the distance from the center point.

[Assistant]
Step 1: I'll search Wikidata for the item "Mezno" to find the correct entity (and confirm it's a Czech village). I'll run a search for entities matching "Mezno".

Question: Mezno

Top 10 entity alternatives:
1. Mezno (wd:Q2180733): village in Benešov District of Central Bohemian region / is instance of municipality of the Czech Republic
2. Mezno (wd:Q111685698): is instance of railway stop / railway stop in Czechia
3. Mezno (wd:Q30917394): former railway stop in Mezno, Czech Republic / is instance of former railway stop
4. Mezno (wd:Q96153716): is instance of pond (artificial) / is instance of artificial pond / pond in Mezno, Czech Republic
5. Mitrovice (Mezno) (wd:Q12038239): village in Benešov District of Central Bohemian region / is instance of cadastral area in the Czech Republic / is instance of municipal part of the Czech Republic
6. Mezno Tunnel (wd:Q108507418): is instance of railway tunnel
7. Meznokto metropola (wd:Q12352510): is instance of literary work
8. Structural isomerism and thermodynamic properties of the ... (n = 3, 4) studied by B3LYP and PCM calculations (wd:Q43063359): scientific article published in June 2010 / scientific article published in June 2010 / scientific article published in June 2010 / is instance of scholarly article / is instance of academic article

[Assistant]
I'll search for the Wikidata items for "village" and "town" to get their QIDs so I can filter settlements by instance-of. I'll search for "village" first.

Question: village

Top 10 entity alternatives:
1. village (wd:Q532), also known as small town: small clustered human settlement with a typical population of a few hundred / small clustered human settlement smaller than a town / small clustered human settlement smaller than a town / is instance of classification of human settlements / is subclass of census subdivision / is subclass of rural settlement / is subclass of locality
2. Edinburgh of the Seven Seas (wd:Q498153, matched via Village), also known as Edinburgh, Settlement, Settlement of Edinburgh, The Settlement, The Village, etc.: main settlement of the island of Tristan da Cunha / is instance of human settlement
3. The Village (wd:Q465227, matched via Village), also known as Village: 2004 film by M. Night Shyamalan / is instance of film
4. village in Turkey (wd:Q1529096, matched via village), also known as köy, village: is instance of designation for an administrative territorial entity of a single country / is subclass of administrative territorial entity type of Turkey / is subclass of third-level administrative country subdivision / is subclass of third-level administrative division / is subclass of Administrative divisions of Turkey / rural administrative division in Turkey / is subclass of human settlement / is subclass of locality / is subclass of village
5. ri (wd:Q483519, matched via village), also known as village: is subclass of administrative territorial entity of South Korea / is subclass of fourth-level administrative country subdivision / is subclass of Administrative divisions of South Korea / is instance of administrative territorial entity type / is subclass of fourth-level administrative division / administrative division in Korea / is subclass of village
6. village (wd:Q7930614), also known as Chinese village (Taiwan), cun, cuns, li, lis, etc.: small settlements and a 4th level administrative subdivisions ... Chinese states, now divided between urban li and rural cun / is subclass of administrative territorial entity of the Republic of China / is subclass of Administrative divisions of the Republic of China / is subclass of fourth-level administrative country subdivision / is subclass of Village-level division of Republic of China / is subclass of fourth-level administrative division / is subclass of village
7. The Village (wd:Q3228143, matched via Village), also known as Sie fanden eine Heimat, Village: 1953 Swiss drama film directed by Leopold Lindtberg / is instance of film
8. Village (wd:Q2526032): is instance of board game / 2011 board game
9. Salari jalil (wd:Q5798259, matched via village), also known as village: is instance of village / village in Iran / village in Iran
10. Küçüksöbeçimen (wd:Q6591308, matched via Village), also known as Village: Village in Sarız, Kayseri, Turkey / is instance of village in Turkey / köy in Sarız, Turkey / köy in Sarız, Turkey

[Assistant]
Now I'll search Wikidata for the entity "town" to get its QID (so I can include towns in the filter).

Question: town

Top 10 entity alternatives:
1. town (wd:Q3957), also known as small city, small town: settlement that is smaller than a city but bigger than a large village (or a large borough in some areas) / settlement that is bigger than a village but smaller than a city / settlement that is bigger than a village but smaller than a city / is instance of classification of human settlements / is subclass of urban settlement / is subclass of city or town
2. Ipswich Town F.C. (wd:Q9653, matched via Town), also known as Ipswich, Ipswich Town, Ipswich Town FC, Ipswich Town Football Club, ITFC, etc.: A professional football club in Ipswich, Suffolk, England / association football club in Ipswich, England / is instance of association football club / is instance of soccer club
3. Huddersfield Town A.F.C. (wd:Q19473, matched via Town), also known as HTAFC, HTFC, Huddersfield, Huddersfield Town, Huddersfield Town AFC, etc.: association football club in Huddersfield, England / is instance of association football club / is instance of professional sports team / is instance of soccer club / English football club
4. Luton Town F.C. (wd:Q18520, matched via Town), also known as LTFC, Luton, Luton Town, Luton Town FC, Luton Town Football Club, etc.: association football club in Luton, England / is instance of association football club / is instance of soccer club / English football club
5. Swindon Town F.C. (wd:Q19634, matched via Town), also known as STFC, Swindon, Swindon Town, Swindon Town FC, Swindon Town Football Club, etc.: association football club in Swindon, England / is instance of association football club / is instance of soccer club / English football club
6. The Town (wd:Q725539, matched via Town), also known as Town: 2010 film directed by Ben Affleck / is instance of film
7. Shrewsbury Town F.C. (wd:Q19626, matched via Town), also known as Shrewsbury, Shrewsbury Town, Shrewsbury Town FC, Shrewsbury Town Football Club, STFC, etc.: association football club in Shrewsbury, England / is instance of association football club / English association football club / is instance of soccer club / English football club
8. Grimsby Town F.C. (wd:Q18515, matched via Town), also known as Grimsby, Grimsby Town, Grimsby Town FC, Grimsby Town Football Club, GTFC, etc.: association football club in Cleethorpes, England / is instance of association football club / is instance of soccer club / English football club
9. Yeovil Town F.C. (wd:Q19651, matched via Town), also known as The Glovers, Town, Yeovil, Yeovil Town, Yeovil Town FC, etc.: association football club in Yeovil, England / is instance of association football club / English association football club / is instance of soccer club / English football club
10. Northampton Town F.C. (wd:Q48945, matched via Town), also known as Northampton, Northampton Town, Northampton Town FC, Northampton Town Football Club, NTFC, etc.: association football club in Northampton, England / is instance of association football club / is instance of soccer club

[Assistant]
I'll check the coordinates and instance-of/country claims for Mezno (wd:Q2180733) by listing relevant triples (coordinates P625, instance of P31, country P17, administrative territorial unit P131).

list

wd:Q2180733

Got 234 rows and 3 columns, showing the first 10 rows below:
| subject             | property                                                    | object                                                                        |
| ------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------- |
| Mezno (wd:Q2180733) | instance of (wdt:P31)                                       | municipality of the Czech Republic (wd:Q5153359)                              |
| Mezno (wd:Q2180733) | country (wdt:P17)                                           | Czech Republic (wd:Q213)                                                      |
| Mezno (wd:Q2180733) | located in the administrative territorial entity (wdt:P131) | Benešov District (wd:Q792883)                                                 |
| Mezno (wd:Q2180733) | coordinate location (wdt:P625)                              | POINT(14.644975 49.534590) (geo:wktLiteral)                                   |
| Mezno (wd:Q2180733) | Commons category (wdt:P373)                                 | Mezno                                                                         |
| Mezno (wd:Q2180733) | image (wdt:P18)                                             | <http://commons.wikimedia.org/wiki/Special:FilePath/Mezno%2C%20domy%20II.jpg> |
| Mezno (wd:Q2180733) | Freebase ID (wdt:P646)                                      | /m/06w9n0l                                                                    |
| Mezno (wd:Q2180733) | GeoNames ID (wdtn:P1566)                                    | <https://sws.geonames.org/3070758/>                                           |
| Mezno (wd:Q2180733) | population (wdt:P1082)                                      | 383 (xsd:decimal)                                                             |
| Mezno (wd:Q2180733) | official name (wdt:P1448)                                   | Mezno (lang:cs)                                                               |
| ...                 | ...                                                         | ...                                                                           |

[Assistant]
I'll search for "human settlement" and also ensure the distance function works. I will search for "human settlement" entity to use as a type constraint if helpful.

Question: human settlement

Top 10 entity alternatives:
1. human settlement (wd:Q486972), also known as human settlements, inhabited place, settlement, settlements: place of any size, in which people permanently live / is subclass of group of structures or buildings / community of any size, in which people live / place of any size, in which people live / densely populated geographic location / is subclass of geographical feature / is subclass of geographical object / is instance of first-order class / is subclass of populated place
2. Kwande (wd:Q6450151, matched via Human settlement), also known as Human settlement: is instance of local government area of Nigeria / is instance of human settlement / LGA in Benue State, Nigeria
3. Burunduki (human settlement) (wd:Q11031822): human settlement in Krasnoarmeysky District, Chuvash Republic", Chuvash Republic, Russia / is instance of administrative territorial entity of Russia / is instance of hamlet
4. Svetlogorsk human settlement (wd:Q4145591): human settlement in Svetlogorsky District, Kaliningrad Oblast, Russia / is instance of urban settlement in Russia / is instance of former municipality
5. Ozherelye human settlement (wd:Q4145561): human settlement in Kashirsky District, Moscow Oblast, Russia / is instance of urban settlement in Russia / is instance of former municipality
6. Sabiñánigo (human settlement) (wd:Q24013331): capital of Sabiñánigo Municipality, Spain / is instance of municipality capital / is instance of locality / is instance of city
7. Ateca (wd:Q24016487, matched via Ateca (human settlement)), also known as Ateca (human settlement), Ateca town: capital town of Ateca Municipality, Spain / is instance of municipality capital / is instance of town
8. submerged city (wd:Q20616831, matched via sunken human settlement), also known as submerged settlement, submerged town, sunken city, sunken human settlement, sunken settlement, etc.: city or town no longer inhabited, due to flooding, or being submerged underwater / is subclass of destroyed settlement / is subclass of abandoned village / is subclass of former settlement / is subclass of submerged place / is subclass of sunken entity / is subclass of city
9. history of a human settlement (wd:Q116885401, matched via human settlement history), also known as history of settlement, human settlement history, settlement history: is instance of aspect of history / is subclass of locality / is subclass of history / aspect of history
10. Noginsk human settlement (wd:Q4145557): human settlement in Noginsky District, Moscow Oblast, Russia / is instance of urban settlement in Russia

[Assistant]
I'll try a SPARQL query that:
- uses wd:Q2180733 as the center and its wdt:P625 coordinate,
- finds items with wdt:P625 and whose wdt:P31 is village (Q532), town (Q3957) or municipality of the Czech Republic (Q5153359),
- ensures the place is in the Czech Republic via wdt:P17 or wdt:P131* admin chain,
- computes geof:distance between coordinates and filters by < 35000 meters,
- returns settlement IRI, English label, coordinates, center coordinates and distance in meters and kilometers.

I'll run that query and then refine if it fails or returns unexpected results.

execute

SELECT DISTINCT ?settlement ?settlementLabel ?settCoords ?centerCoords ?distMeters ?distKm WHERE {
  BIND(wd:Q2180733 AS ?center).
  ?center wdt:P625 ?centerCoords.

  ?settlement wdt:P625 ?settCoords.
  ?settlement wdt:P31 ?type.
  FILTER(?type IN (wd:Q532, wd:Q3957, wd:Q5153359))

  # located in Czech Republic either directly or via admin hierarchy
  {
    ?settlement wdt:P17 wd:Q213.
  } UNION {
    ?settlement wdt:P131* ?admin .
    ?admin wdt:P17 wd:Q213.
  }

  # ensure it's a human settlement
  ?settlement wdt:P31/wdt:P279* wd:Q486972.

  # compute distance (meters)
  BIND(geof:distance(?centerCoords, ?settCoords) AS ?distMeters)
  BIND(?distMeters/1000 AS ?distKm)

  FILTER(?distMeters <= 35000)

  OPTIONAL { ?settlement rdfs:label ?settlementLabel . FILTER(LANG(?settlementLabel) = "en") }
}
ORDER BY ?distMeters

[Assistant]
Observation: the previous query returned distances that look like kilometers (e.g., Borotín ~4.01, Karviná ~282.6). I had treated the function output as meters and divided by 1000, which produced incorrect small values. I'll fix that: treat geof:distance(...) as returning kilometers, compute meters as ?distMeters = ?distKm * 1000, filter by ?distKm <= 35, and return both values.

I'll run the corrected query now.

SELECT DISTINCT ?settlement ?settlementLabel ?settCoords ?centerCoords ?distKm ?distMeters WHERE {
  BIND(wd:Q2180733 AS ?center).
  ?center wdt:P625 ?centerCoords.

  ?settlement wdt:P625 ?settCoords.
  ?settlement wdt:P31 ?type.
  FILTER(?type IN (wd:Q532, wd:Q3957, wd:Q5153359))

  # located in Czech Republic either directly or via admin hierarchy
  {
    ?settlement wdt:P17 wd:Q213.
  } UNION {
    ?settlement wdt:P131* ?admin .
    ?admin wdt:P17 wd:Q213.
  }

  # ensure it's a human settlement
  ?settlement wdt:P31/wdt:P279* wd:Q486972.

  # compute distance in kilometers (geof:distance returns kilometers on this endpoint)
  BIND(geof:distance(?centerCoords, ?settCoords) AS ?distKm)
  BIND(?distKm * 1000 AS ?distMeters)

  FILTER(?distKm <= 35)

  OPTIONAL { ?settlement rdfs:label ?settlementLabel . FILTER(LANG(?settlementLabel) = "en") }
}
ORDER BY ?distKm

[Assistant]
I'll finalize with the SPARQL query I executed and a brief summary of the results (center coordinates, number of settlements found, and what the query returns). Then I'll stop.

answer

SELECT DISTINCT ?settlement ?settlementLabel ?settCoords ?centerCoords ?distKm ?distMeters WHERE {
  BIND(wd:Q2180733 AS ?center).
  ?center wdt:P625 ?centerCoords.

  ?settlement wdt:P625 ?settCoords.
  ?settlement wdt:P31 ?type.
  FILTER(?type IN (wd:Q532, wd:Q3957, wd:Q5153359))

  # located in Czech Republic either directly or via admin hierarchy
  {
    ?settlement wdt:P17 wd:Q213.
  } UNION {
    ?settlement wdt:P131* ?admin .
    ?admin wdt:P17 wd:Q213.
  }

  # ensure it's a human settlement
  ?settlement wdt:P31/wdt:P279* wd:Q486972.

  # compute distance in kilometers (geof:distance returns kilometers on this endpoint)
  BIND(geof:distance(?centerCoords, ?settCoords) AS ?distKm)
  BIND(?distKm * 1000 AS ?distMeters)

  FILTER(?distKm <= 35)

  OPTIONAL { ?settlement rdfs:label ?settlementLabel . FILTER(LANG(?settlementLabel) = "en") }
}
ORDER BY ?distKm

Answer:
I ran the query above. Summary of the results:
- Center (Mezno, wd:Q2180733) coordinates: POINT(14.644975 49.534590) (from wdt:P625).
- Number of settlements (villages/towns/municipalities) in the Czech Republic within 35 km of Mezno returned by the query: 58.
- The query returns, for each settlement: the settlement IRI, its English label (if available), its coordinate (wdt:P625), the center coordinate (Mezno's wdt:P625), the distance in kilometers (distKm) and meters (distMeters). Results are ordered by distance ascending.

Examples (first 5 rows returned):
- wd:Q2574196 — Borotín — POINT(14.613004 49.505101) — center POINT(14.644975 49.534590) — distKm: 4.00979 — distMeters: 4009.79
- wd:Q631813 — Miličín — POINT(14.661447 49.570761) — center POINT(14.644975 49.534590) — distKm: 4.19387 — distMeters: 4193.87
- wd:Q11862916 — Dědice — POINT(14.712500 49.513300) — center POINT(14.644975 49.534590) — distKm: 5.41846 — distMeters: 5418.46
- wd:Q10769866 — Alenina Lhota — POINT(14.521400 49.526400) — center POINT(14.644975 49.534590) — distKm: 8.96487 — distMeters: 8964.87
- wd:Q368888 — Sedlec-Prčice — POINT(14.532639 49.571905) — center POINT(14.644975 49.534590) — distKm: 9.10404 — distMeters: 9104.04

If you want the full table (all 58 rows) in CSV or another format, or want me to restrict to only items with instance-of specifically 'village' or specifically 'town' (rather than including 'municipality of the Czech Republic'), tell me which format or filter you prefer and I will re-run or export the results.


PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?periodical ?periodicalLabel WHERE {
  ?periodical wdt:P31 / wdt:P279 * wd:Q1002697 .
  ?periodical wdt:P407 wd:Q143 .
  OPTIONAL {
    ?periodical rdfs:label ?periodicalLabel .
    FILTER ( LANG( ?periodicalLabel ) = "en" )
  }
}
ORDER BY ?periodicalLabel

Using entities:
- periodical (wd:Q1002697), also known as periodical literature, periodical publication, periodicals: is instance of type of mass media / is instance of type of publication / is subclass of serial / is subclass of communication medium / is subclass of medium / is subclass of publication / publication type, serial publication that appears in a new edition on a regular schedule / serial publication that appears in a new edition on a regular schedule / work; published at regular intervals
- Esperanto (wd:Q143), also known as eo, epo, Esperanto language: is instance of modern language / is instance of planned language / is instance of constructed language / is instance of a posteriori language / is instance of international auxiliary language / international auxiliary language designed by L. L. Zamenhof / international auxiliary language designed by Ludwik Lejzer Zamenhof / international auxiliary language designed by Ludwik Lejzer Zamenhof

Using properties:
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- language of work or name (wd:P407 as wdt), also known as audio language, available in, broadcasting language, language, language of name, etc.: language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this work or name (for persons use P103 and P1412)

Got 341 rows and 2 columns, showing the first 5 and last 5 rows below:
| periodical                                                                         | periodicalLabel                                                              |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| wd:Q19723943                                                                       |                                                                              |
| wd:Q12357327                                                                       |                                                                              |
| wd:Q12357381                                                                       |                                                                              |
| wd:Q130248902                                                                      |                                                                              |
| wd:Q131696057                                                                      |                                                                              |
| ...                                                                                | ...                                                                          |
| Vertikale (wd:Q1999041)                                                            | Vertikale (lang:en)                                                          |
| Voinstvuiuschii ateizm (wd:Q56291294)                                              | Voinstvuiuschii ateizm (lang:en)                                             |
| Vojo de la vivo: oficiala organo de la internacia kristana frataro (wd:Q123593369) | Vojo de la vivo: oficiala organo de la internacia kristana frataro (lang:en) |
| Vojo-Vero-Vivo: eldono de la internacia katolika informejo (wd:Q123593365)         | Vojo-Vero-Vivo: eldono de la internacia katolika informejo (lang:en)         |
| Young Friend (wd:Q3891983)                                                         | Young Friend (lang:en)                                                       |

Answer:
Assumptions and approach: I treated "primary language = Esperanto" as the item having the property "language of work or name" (P407) set to Esperanto (wd:Q143). I restricted results to items that are instances (or instances of subclasses) of "periodical" (wd:Q1002697) by using the property-path wdt:P31/wdt:P279*. I executed the query against Wikidata.

Result summary: The query returns the Wikidata items (IRIs) for periodicals whose language (P407) is Esperanto. The query returned many items (341 rows). Many returned items lack an English rdfs:label; examples that do have English labels in the results include:
- wd:Q1999041 (Vertikale)
- wd:Q56291294 (Voinstvuiuschii ateizm)
- wd:Q123593369 (Vojo de la vivo: oficiala organo de la internacia kristana frataro)
- wd:Q123593365 (Vojo-Vero-Vivo: eldono de la internacia katolika informejo)
- wd:Q3891983 (Young Friend)

If you want, I can:
- return the full list of IRIs (all results),
- add labels in another language (e.g., Esperanto labels),
- expand the type constraint (e.g., include magazines/newspapers specifically), or
- filter to currently active periodicals only.

Final SPARQL query (executed above) is provided so you can reproduce or refine the results.

Assumptions and approach: I treated "primary language = Esperanto" as the item having the property "language of work or name" (P407) set to Esperanto (wd:Q143). I restricted results to items that are instances (or instances of subclasses) of "periodical" (wd:Q1002697) by using the property-path wdt:P31/wdt:P279*. I executed the query against Wikidata.

Result summary: The query returns the Wikidata items (IRIs) for periodicals whose language (P407) is Esperanto. The query returned many items (341 rows). Many returned items lack an English rdfs:label; examples that do have English labels in the results include:
- wd:Q1999041 (Vertikale)
- wd:Q56291294 (Voinstvuiuschii ateizm)
- wd:Q123593369 (Vojo de la vivo: oficiala organo de la internacia kristana frataro)
- wd:Q123593365 (Vojo-Vero-Vivo: eldono de la internacia katolika informejo)
- wd:Q3891983 (Young Friend)

If you want, I can:
- return the full list of IRIs (all results),
- add labels in another language (e.g., Esperanto labels),
- expand the type constraint (e.g., include magazines/newspapers specifically), or
- filter to currently active periodicals only.

Final SPARQL query (executed above) is provided so you can reproduce or refine the results.

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?periodical ?periodicalLabel WHERE {
  ?periodical wdt:P31 / wdt:P279 * wd:Q1002697 .
  ?periodical wdt:P407 wd:Q143 .
  OPTIONAL {
    ?periodical rdfs:label ?periodicalLabel .
    FILTER ( LANG( ?periodicalLabel ) = "en" )
  }
}
ORDER BY ?periodicalLabel

Using entities:
- periodical (wd:Q1002697), also known as periodical literature, periodical publication, periodicals: is instance of type of mass media / is instance of type of publication / is subclass of serial / is subclass of communication medium / is subclass of medium / is subclass of publication / publication type, serial publication that appears in a new edition on a regular schedule / serial publication that appears in a new edition on a regular schedule / work; published at regular intervals
- Esperanto (wd:Q143), also known as eo, epo, Esperanto language: is instance of modern language / is instance of planned language / is instance of constructed language / is instance of a posteriori language / is instance of international auxiliary language / international auxiliary language designed by L. L. Zamenhof / international auxiliary language designed by Ludwik Lejzer Zamenhof / international auxiliary language designed by Ludwik Lejzer Zamenhof

Using properties:
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- language of work or name (wd:P407 as wdt), also known as audio language, available in, broadcasting language, language, language of name, etc.: language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this work or name (for persons use P103 and P1412)

Execution result:
Got 341 rows and 2 columns, showing the first 5 and last 5 rows below:
| periodical                                                                         | periodicalLabel                                                              |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| wd:Q19723943                                                                       |                                                                              |
| wd:Q12357327                                                                       |                                                                              |
| wd:Q12357381                                                                       |                                                                              |
| wd:Q130248902                                                                      |                                                                              |
| wd:Q131696057                                                                      |                                                                              |
| ...                                                                                | ...                                                                          |
| Vertikale (wd:Q1999041)                                                            | Vertikale (lang:en)                                                          |
| Voinstvuiuschii ateizm (wd:Q56291294)                                              | Voinstvuiuschii ateizm (lang:en)                                             |
| Vojo de la vivo: oficiala organo de la internacia kristana frataro (wd:Q123593369) | Vojo de la vivo: oficiala organo de la internacia kristana frataro (lang:en) |
| Vojo-Vero-Vivo: eldono de la internacia katolika informejo (wd:Q123593365)         | Vojo-Vero-Vivo: eldono de la internacia katolika informejo (lang:en)         |
| Young Friend (wd:Q3891983)                                                         | Young Friend (lang:en)                                                       |

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Search for the entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- imdb: <https://www.imdb.com/
- math: <http://www.w3.org/2005/xpath-functions/math#
- ontolex: <http://www.w3.org/ns/lemon/ontolex#
- owl: <http://www.w3.org/2002/07/owl#
- p: <http://www.wikidata.org/prop/
- pq: <http://www.wikidata.org/prop/qualifier/
- pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
- pqv: <http://www.wikidata.org/prop/qualifier/value/
- pr: <http://www.wikidata.org/prop/reference/
- prn: <http://www.wikidata.org/prop/reference/value-normalized/
- prov: <http://www.w3.org/ns/prov#
- prv: <http://www.wikidata.org/prop/reference/value/
- ps: <http://www.wikidata.org/prop/statement/
- psn: <http://www.wikidata.org/prop/statement/value-normalized/
- psv: <http://www.wikidata.org/prop/statement/value/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
- rdfs: <http://www.w3.org/2000/01/rdf-schema#
- ref: <http://www.wikidata.org/reference/
- s: <http://www.wikidata.org/entity/statement/
- schema: <http://schema.org/
- skos: <http://www.w3.org/2004/02/skos/core#
- v: <http://www.wikidata.org/value/
- void: <http://rdfs.org/ns/void#
- wd: <http://www.wikidata.org/entity/
- wdno: <http://www.wikidata.org/prop/novalue/
- wdt: <http://www.wikidata.org/prop/direct/
- wdtn: <http://www.wikidata.org/prop/direct-normalized/
- wikibase: <http://wikiba.se/ontology#
- xsd: <http://www.w3.org/2001/XMLSchema#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- Do not use "SERVICE wikibase:label { bd:serviceParam wikibase:language ..." in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
- Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
- Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] Which periodicals have a primary language of Esperanto?

[Assistant]
Step 1: I'll search Wikidata for the item representing "periodical" (to use as instance-of / type constraint), and properties for "language" to use (likely P407). I'll run searches and explain results.

Question: periodical

Top 10 entity alternatives:
1. periodical (wd:Q1002697), also known as periodical literature, periodical publication, periodicals: publication type, serial publication that appears in a new edition on a regular schedule / serial publication that appears in a new edition on a regular schedule / work; published at regular intervals / is subclass of communication medium / is instance of type of publication / is instance of type of mass media / is subclass of publication / is subclass of medium / is subclass of serial
2. periodicals (wd:Q131470059, matched via periodical), also known as periodical, periodicals as topic: is subclass of serial / study of periodicals
3. Periodical (wd:Q103961464): is instance of encyclopaedic article / is instance of encyclopedia article / encyclopedia article
4. Periodical (wd:Q67520005), also known as Cartoon mag, Cartoon Magazine, Journal, Magazine, Publication: a monthly cartoon publication / is instance of publication / is instance of magazine / is instance of project / is instance of ebook
5. article (wd:Q191067, matched via periodical article), also known as journal article, periodical article, serial article: text that forms an independent part of a publication / is instance of type of publication / is subclass of part of a work / is instance of literary form / is subclass of written work / is subclass of publication / is subclass of document / is subclass of text
6. Magicicada (wd:Q49664, matched via Periodical cicada), also known as Periodical cicada: genus of insect of eastern North America / is instance of taxon
7. student newspaper (wd:Q738377, matched via student periodical), also known as student magazine, student periodical, student publication: newspaper or periodical run by students / is instance of newspaper genre / is subclass of newspaper / is subclass of magazine
8. wrapper (wd:Q443177, matched via periodical wrapper), also known as newspaper wrapper, periodical wrapper, postal band: postal stationery which pays the cost of the delivery of a newspaper or a periodical / is subclass of postal stationery / is subclass of mail item
9. periodical library (wd:Q137655), also known as hemeroteque, newspaper library: Library archive for newspaper issues / is subclass of special library
10. annual publication (wd:Q567357, matched via annual periodical), also known as annual, annual periodical, annual serial, annual serial publication: is subclass of periodical / serial issued annually / is subclass of serial

[Assistant]
Now I'll search for the property to represent the primary language of a work. I expect P407 ("language of work or name"). I'll search for "language of work". I'll explain and verify the property.

Question: language of work or name

Top 10 property alternatives:
1. language of work or name (wd:P407 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as audio language, available in, broadcasting language, language, language of name, etc.: language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this work or name (for persons use P103 and P1412)
2. creator's signature (wd:P7457 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via name on work), also known as artist's signature on work, monogram on work, name on work, pinxit, sculpsit, etc.: image of the artist's mark on the work that identifies their work / is subproperty of inscription image / is subproperty of image
3. writing language (wd:P6886 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via language of works), also known as language for writing, language of works, language of writings, languages for writing, languages of works, etc.: is subproperty of languages spoken, written or signed / language in which the writer has written their work
4. native label (wd:P1705 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via name in official language), also known as autonym, label in official language, label in original language, name in official language, name in original language, etc.: label for the items in their official language (P37) or their original language (P364) / label for the items in their official language (P37) or their original language (P364) / label for the items in their official language (P37) or their original language (P364) / label for the items in their official language  or their original language / is subproperty of name
5. working title (wd:P1638 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via working name), also known as code name, codename, production name, production title, working name, etc.: temporary name of a product or project used during its development
6. language used (wd:P2936 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via working language), also known as languages used, medium of instruction, used language, uses language, working language, etc.: language widely used (spoken or written) in this place or at this event or organisation
7. present in work (wd:P1441 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via from work), also known as appeared in, appears in, appears in work, character in, featured in work, etc.: this (fictional or fictionalized) entity, place, or person ... P1343 for entities described in non-fictional accounts) / work in which this fictional entity (Q14897293) or historical ... P1343 for entities described in non-fictional accounts)
8. name in native language (wd:P1559 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as native name, P1559: name of a person in their native language / name of a person in their native language / name of a person in their native language / name of a person in their native language / is subproperty of name
9. original language of film or TV show (wd:P364 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via language of the original work), also known as created on language, language of the original work, media language, original language, P364: language in which a film or a performance work was originally ... and songs; use P407 ("language of work or name") instead. / language in which a film or a performance work was originally ... written works; use P407 ("language of work or name") instead. / language in which a film or a performance work was originally ... written works; use P407 ("language of work or name") instead. / is subproperty of language of work or name
10. for work (wd:P1686 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as awarded for work, citation for award, for their work on, nominated for work, P1686: qualifier of award received (P166) to specify the work that an award was given to the creator for / qualifier of award received (P166) to specify the work that an award was given to the creator for

[Assistant]
I'll search for the Esperanto language item (to use in the query as the language value).

Question: Esperanto

Top 10 entity alternatives:
1. Esperanto (wd:Q143), also known as eo, epo, Esperanto language: international auxiliary language designed by Ludwik Lejzer Zamenhof / international auxiliary language designed by Ludwik Lejzer Zamenhof / international auxiliary language designed by L. L. Zamenhof / is instance of international auxiliary language / is instance of a posteriori language / is instance of constructed language / is instance of planned language / is instance of modern language
2. Esperanto (wd:Q608836): official magazine of the World Esperanto Association (UEA) / is instance of periodical
3. Esperanto (wd:Q5398868): is instance of rock band / Belgo-English band
4. Esperanto (wd:Q15734339), also known as Esperanto.4733: is instance of computer virus / computer virus
5. Esperanto (wd:Q3733094): 1993 debut studio album by Elektric Music / is instance of album
6. Esperanto (wd:Q10489150): is instance of Zamenhof-Esperanto object / restaurant in Stockholm, Sweden / is instance of restaurant
7. Esperanto (wd:Q11290111): album by Ryuichi Sakamoto / is instance of album
8. Esperanto (wd:Q12347414): is instance of ship / Spanish ship
9. Esperanto (wd:Q23012159): album by Freundeskreis / album by Freundeskreis / album by Freundeskreis / is instance of album
10. Esperanto (wd:Q5398858): US-American fishing schooner / is instance of schooner

[Assistant]
I'll run a SPARQL query that finds items that are instances (or instances of subclasses) of "periodical" (wd:Q1002697) and have "language of work or name" (P407) set to Esperanto (wd:Q143). I will request English labels as optional. Then I'll inspect results and refine if needed. Now executing the query.

execute

SELECT ?periodical ?periodicalLabel WHERE {
  ?periodical wdt:P31/wdt:P279* wd:Q1002697 .
  ?periodical wdt:P407 wd:Q143 .
  OPTIONAL { ?periodical rdfs:label ?periodicalLabel . FILTER(LANG(?periodicalLabel) = "en") }
}
ORDER BY ?periodicalLabel

Got 341 rows and 2 columns, showing the first 5 and last 5 rows below:
| periodical                                                                         | periodicalLabel                                                              |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| wd:Q19723943                                                                       |                                                                              |
| wd:Q12357327                                                                       |                                                                              |
| wd:Q12357381                                                                       |                                                                              |
| wd:Q130248902                                                                      |                                                                              |
| wd:Q131696057                                                                      |                                                                              |
| ...                                                                                | ...                                                                          |
| Vertikale (wd:Q1999041)                                                            | Vertikale (lang:en)                                                          |
| Voinstvuiuschii ateizm (wd:Q56291294)                                              | Voinstvuiuschii ateizm (lang:en)                                             |
| Vojo de la vivo: oficiala organo de la internacia kristana frataro (wd:Q123593369) | Vojo de la vivo: oficiala organo de la internacia kristana frataro (lang:en) |
| Vojo-Vero-Vivo: eldono de la internacia katolika informejo (wd:Q123593365)         | Vojo-Vero-Vivo: eldono de la internacia katolika informejo (lang:en)         |
| Young Friend (wd:Q3891983)                                                         | Young Friend (lang:en)                                                       |

[Assistant]
Now I'll finalize with the SPARQL I executed and a concise answer describing the results and assumptions.

answer

SELECT ?periodical ?periodicalLabel WHERE {
  ?periodical wdt:P31/wdt:P279* wd:Q1002697 .
  ?periodical wdt:P407 wd:Q143 .
  OPTIONAL { ?periodical rdfs:label ?periodicalLabel . FILTER(LANG(?periodicalLabel) = "en") }
}
ORDER BY ?periodicalLabel

Answer:
Assumptions and approach: I treated "primary language = Esperanto" as the item having the property "language of work or name" (P407) set to Esperanto (wd:Q143). I restricted results to items that are instances (or instances of subclasses) of "periodical" (wd:Q1002697) by using the property-path wdt:P31/wdt:P279*. I executed the query against Wikidata.

Result summary: The query returns the Wikidata items (IRIs) for periodicals whose language (P407) is Esperanto. The query returned many items (341 rows). Many returned items lack an English rdfs:label; examples that do have English labels in the results include:
- wd:Q1999041 (Vertikale)
- wd:Q56291294 (Voinstvuiuschii ateizm)
- wd:Q123593369 (Vojo de la vivo: oficiala organo de la internacia kristana frataro)
- wd:Q123593365 (Vojo-Vero-Vivo: eldono de la internacia katolika informejo)
- wd:Q3891983 (Young Friend)

If you want, I can:
- return the full list of IRIs (all results),
- add labels in another language (e.g., Esperanto labels),
- expand the type constraint (e.g., include magazines/newspapers specifically), or
- filter to currently active periodicals only.

Final SPARQL query (executed above) is provided so you can reproduce or refine the results.