Function Repository Resource:

LLMWikidataFilter

Source Notebook

Look up Wikidata entities matching a set of property constraints (for use by LLMs)

Contributed by: C. Alan Joyce

ResourceFunction["LLMWikidataFilter"][filters,props]

find Wikidata entities matching property constraints in filters and return properties props.

Details

filters takes a single string, containing pairs of [Wikidata Pxxx property ID]:[property constraint] separated by “;;”.
props takes a single string with Wikidata property IDs (Pxxx) to retrieve, separated by commas without spaces.
See documentation for WikidataData for other Wolfram Language symbols and special strings allowed as property constraints or property names.
LLMWikidataFilter also processes ExternalIdentifier objects to remove their Head and Keys of the internal Association, to save tokens and simplify the result for LLMs.

Examples

Basic Examples

Look up skyscrapers taller than 400 meters in Manhattan:

In[1]:=
ResourceFunction[
 "LLMWikidataFilter"]["P31:Q11303;;P131:Q11299;;P2048:GreaterThan[Quantity[400,\"Meters\"]]", "WikidataID,P2048"]
Out[1]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 26 January 2024

License Information