Manual Templates for Questions - statnett/Talk2PowerSystem GitHub Wiki
This page is a collection of particularly complex templates that represent interesting kinds of questions which are beyond the ability of the KGQA Dataset Generation method to create at this point. These will be organized by the kind of new functionality whenever possibly with the goal of eventually being incorporated in the automatic generation.
When complete, each question will need:
- At least five natural language paraphrases
- List of outputs, each given a unique name and identified by object type (e.g. "line": "cim:Line")
- List of parameters and filters. Each parameter and filter must be used at least once in finding an answer to the question.
- A template for a SPARQL where clause
- An input for any other tool calls expected in the template (e.g. IRI discovery tool call, Cognite data retrieval call, etc.)
1. Multi-output questions
2. Time-series questions
T2.1 Aggregated price over period for nc:BiddingZone
Questions:
- Which is the EIC for Norwegian Elspot Area 4, and what is the average EUR price per month for the last 12 months
Outputs: *
Parameters:
- area - nc:BiddingZone
Filters:
- aggregation_type - one of min, max, average, mean?
- period - int in range [1,18]?
IRI Discovery call: ???
SPARQL query: n/a
Cognite query: ???
3. GeoSPARQL questions
There are many possible queries with a geospatial aspect but there is no single universal implementation for the chatbot that can handle them all. Here is a list of potentially interesting questions with potential solutions, problems or open questions. These need to be prioritized and a few relevant ones can be incorporated into the corpus.
Objects at or near a point
Example Question 1: What is the substation at 59.9186, 10.5884?
Example Query 1:
PREFIX cim: <https://cim.ucaiug.io/ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT ?substation ?coordinates
WHERE {
?substation a cim:Substation ;
geo:hasGeometry/geo:asWKT ?coordinates .
# Construct the search point (lon lat)
BIND("POINT(10.5884 59.9186)"^^geo:wktLiteral AS ?targetPoint)
# Filter substations within a certain distance in meters
FILTER(geof:distance(?coordinates, ?targetPoint, uom:metre) < 20)
}
Example Question 2: Which lines come within 200 meters of 59.9186, 10.5884?
Example Query 2:
PREFIX cim: <https://cim.ucaiug.io/ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT ?line ?lineWKT
WHERE {
?line a cim:ACLineSegment ;
geo:hasGeometry/geo:asWKT ?lineWKT .
BIND("POINT(10.5884 59.9186)"^^geo:wktLiteral AS ?targetPoint)
FILTER(geof:distance(?lineWKT, ?targetPoint, uom:metre) < 200)
}
Example Question 3: Which is the closest substation to latitude 64.15, longitude 13.7?
Example Query 3:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT ?substation ?coordinates (geof:distance(?coordinates, ?targetPoint, uom:metre) AS ?distance)
WHERE {
?substation a cim:Substation ;
geo:hasGeometry/geo:asWKT ?coordinates .
BIND("POINT(13.7 64.15)"^^geo:wktLiteral AS ?targetPoint)
}
ORDER BY ASC(?distance)
LIMIT 1
Considerations and Problems:
- Is this actually an interesting question?
- How do we expect users to actually pass the coordinates to the chatbot?
Objects within a custom area
Example Question 1: Which lines cross through my custom area ?
Example Query 1:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?lineSegment ?geometry
WHERE {
?lineSegment a cim:ACLineSegment ;
geo:hasGeometry/geo:asWKT ?geometry .
BIND(
"POLYGON((10.229020984659712 59.24698254345179, 10.18420614097019 59.19982925336586, 10.142883363023742 59.13888033657065, 10.202442484289662 59.13758660552921, 10.276357875828012 59.16126409167293, 10.310502518638259 59.22922084872761, 10.229020984659712 59.24698254345179))"^^geo:wktLiteral
AS ?area
)
FILTER(geof:sfIntersects(?geometry, ?area))
}
Example Question 2: Which substations are within the square defined by 62.208737, 5.765184 and 71.061346, 26.727097?
Example Query 2:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?substation ?wkt
WHERE {
?substation a cim:Substation ;
geo:hasGeometry/geo:asWKT ?wkt .
BIND(
"POLYGON((5.765184 62.208737, 26.727097 62.208737, 26.727097 71.061346, 5.765184 71.061346, 5.765184 62.208737))"^^geo:wktLiteral
AS ?bbox
)
FILTER(geof:sfWithin(?wkt, ?bbox))
}
Considerations and Problems:
- Demo #3 had a question that described this as a desirable question to test. Can we get a confirmation?
- How do users actually pass custom zones to chatbot? I can make up things for the QA corpus but in practice we can't expect them to write coordinates.
- Do we apply this to any existing area (we only have one)? Seems pointless since the predefined ones already have solutions.
Objects North/East/South/West of point
Example Question 1: What is north of urn:uuid:64003f65-4313-f04f-85de-4202479ba890?
Wrong Query 1:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX sf: <http://www.opengis.net/ont/sf#>
PREFIX ogc: <http://www.opengis.net/def/function/geosparql/>
SELECT ?geom ?wkt
WHERE {
?geom a geo:Geometry ;
geo:asWKT ?wkt .
BIND("POINT(17.1942965688451 0)"^^geo:wktLiteral AS ?eastPoint)
BIND("LINESTRING(17.1942965688451 -90, 17.1942965688451 90)"^^geo:wktLiteral AS ?eastLine)
FILTER(**geof:sfBeyond**(?geom, ?eastLine))
}
Problem: This was the first attempt for an LLM to find a solution. The geof:sfBeyond looks reasonable except I couldn't find any mention to it existing in the GeoSPARQL documentation so I think it is entirely hallucinated. If it existed, it would be a great solution...
Wrong Query 2:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?otherUri ?otherWKT
WHERE {
bind(<urn:uuid:64003f65-4313-f04f-85de-4202479ba890> as ?origin_uri)
# Given point
?origin_uri geo:asWKT ?refWKT .
# Extract Y (latitude) from reference WKT (e.g., "POINT(x y)")
BIND(geof:y(?refWKT) AS ?refLat)
# Other geometries
?otherUri geo:asWKT ?otherWKT .
FILTER(?otherUri != ?origin_uri)
# Extract Y (latitude) of other geometry
BIND(geof:y(?otherWKT) AS ?otherLat)
# Only keep those that are north
FILTER(?otherLat > ?refLat)
}
Problem: This was the second attempt at an LLM solution. This time based on the geof:x and geof:y functions which don't exist in GraphDB. I saw some mentions of them online but they don't seem to be part of the actual specification. In either case, we cannot use them either.
Right(ish) Query 3:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?otherUri ?otherWKT
WHERE {
bind(<urn:uuid:64003f65-4313-f04f-85de-4202479ba890> as ?origin_uri)
# Given point
?origin_uri geo:asWKT ?refWKT .
# Extract Y (latitude) from reference WKT (e.g., "POINT(x y)")
BIND(xsd:double(REPLACE(STR(?refWKT), "^POINT\\([^ ]+ ([^\\)]+)\\)$", "$1")) AS ?refLat)
# Other geometries
?otherUri geo:asWKT ?otherWKT .
FILTER(?otherUri != ?origin_uri)
# Extract Y (latitude) of other geometry
FILTER(STRSTARTS(STR(?otherWKT), "POINT"))
BIND(xsd:double(REPLACE(STR(?otherWKT), "^POINT\\([^ ]+ ([^\\)]+)\\)$", "$1")) AS ?otherLat)
# Only keep those that are north
FILTER(?otherLat > ?refLat)
}
This query actually solves the issue but only by parsing the coordinates as a literal using regex. We can hardly call this GeoSPARQL. Note, however, that due to parsing we have limited the search to just other points. This solution would not work for arbitrarily shaped objects and it would be nightmarishly complicated if we tried to find something like "which polygons are north of a given point?"
Considerations and Problems:
- Is this actually an interesting question?
- Is this a well-defined question i.e. does east of non-point object mean east of the easternmost point?
- Is this a question we're interested in supporting? GeoSPARQL seems to provide no solution and the LLM is making up functions that don't exist. Processing coordinates with REGEXes seems like a bad idea.