Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Place mentions: toponym candidates and spatial relation frames

Last updated: 7 Oct 20265 min read
tutorial
AdvancedBy AITrove Editorial

Extract place candidates and the relation between them before assigning coordinates to a natural-language location description.

A place name is not a coordinate

“North of Cedar Depot” contains a named anchor and a relation. It does not provide a single point. A place name can refer to several facilities, and “north of” may mean a broad area whose extent depends on task and map scale. Capture mention offsets, anchor candidates, relation type and any explicit distance or unit. Keep unknown extent as unknown. Entity candidate linking gives a suitable NIL state for absent facilities.

Build a typed frame

Represent the target, anchor, relation and constraints separately. For “within 3 kilometres of Cedar Depot,” the numeric radius is explicit; for “near Cedar Depot,” it is not. Do not invent a radius from the word “near.” In a sentence with two anchors, attach each relation to the correct phrase rather than applying it to the entire document. Dependency alignment helps preserve which noun phrase a preposition modifies.

Use context to narrow anchors

A gazetteer may hold two Cedar Depots in different districts. Document region, facility type and neighboring place mentions can narrow the candidate set. Avoid using the incident’s desired outcome as evidence for the anchor; that would bias resolution. Store gazetteer version, selected feature ID and geographic type. A precise coordinate for the wrong depot is worse than an unresolved mention. The scope lesson discusses geometry after candidate resolution.

Evaluate the whole frame

Score mention span, place ID, relation type, distance value and unit separately. Then evaluate the resolved region against a human-reviewed map fixture. A system can recognize both place names yet reverse “east of” into “west of.” Include direction, containment, border, route-distance and ambiguous “near” cases. The field report project prevents unresolved descriptions from being turned into misleading pins.

Implementation

python
def location_frame(anchor_name, relation, distance_km, gazetteer):
    candidates = gazetteer.get(anchor_name, [])
    if len(candidates) != 1:
        return {"state": "review", "reason": "ambiguous-anchor",
                "candidate_ids": [item["place_id"] for item in candidates]}
    if relation == "within" and distance_km is not None and distance_km > 0:
        return {"state": "bounded", "anchor_id": candidates[0]["place_id"],
                "radius_km": distance_km}
    return {"state": "review", "reason": "unbounded-relation"}

places = {"Cedar Depot": [{"place_id": "depot-47"}]}
assert location_frame("Cedar Depot", "within", 3, places) == {
    "state": "bounded", "anchor_id": "depot-47", "radius_km": 3}
assert location_frame("Cedar Depot", "near", None, places)["state"] ==     "review"

Performance and operating cost

The dictionary lookup is expected O(1); emitting c candidate IDs costs O(c) time and space. Actual gazetteer search, geometry and map rendering have separate costs. The snippet returns a typed frame, not a computed boundary or a claim that an incident occurred inside it.

Common Mistakes

  • Assigning a coordinate to the word “north” without an extent.
  • Choosing the first gazetteer match when names repeat.
  • Treating “near” as a fixed radius without a declared policy.
  • Testing place-name recognition while ignoring reversed spatial relations.

Read next

ai-data
natural-language-processing
Storage details