I've a list of Entities from Wikidata

listOfKeys = {"Ambientalismo", "Anoressia", "Aspetto fisico", 
   "Attivismo", "Burocrazia", "COVID-19", "Cambiamento climatico", 
   "Canoni estetici"};

list3 = First[#, Missing["NotFound"]] & /@ (WikidataSearch /@ 
    listOfKeys) //DeleteMissing

Then I defined a function to look for the parent of the Entity and apply it to the element of the list: (this instruction

     "P279", <|"Label" -> "SubclassOf"|>]

means that the ID is P279 and it's human readable meaning is SubclassOf)

findParent := # -> 
     "P279", <|"Label" -> "SubclassOf"|>]] &

Graph[findParent /@ list3]

The result first problem is that the graph should connect an entity to another entity, while I get a list of associations between 1 entity and a list of entities.

enter image description here


1 Answer 1


Define findParent as:

findParent = Thread[# -> WikidataData[#, 
   ExternalIdentifier["WikidataID", "P279", <|"Label" -> "SubclassOf"|>]] ] &; 

edges = Flatten[findParent /@ list3];

 VertexShapeFunction -> 
    (Text[Framed @ Style[#2["Label"] /. _Missing -> #2, Black, 12], #] &), 
 ImageSize -> 900] 

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.