Wolfram Language

Un accès plus riche à la base de connaissances

Requêtes entité-propriété en forme libre

Utilisez Interpreter pour construire une fonction similaire à EntityValue, mais permettant des spécifications EntityType, Entity et EntityProperty en langage naturel.

In[1]:=
Click for copyable input
NLEntityValue[type_String, entity_String, property_String] := With[{res = Map[{Replace[#, AmbiguityList[{a___}, ___] :> a]} &, Interpreter[ CompoundElement[{"EntityType", "Entity", "EntityProperty"}], AmbiguityFunction -> All][{type, entity, property}]]}, If[FreeQ[res, Failure], EntityValue[FirstCase[res[[2]], Entity[res[[1, 1]], ___]], FirstCase[res[[3]], EntityProperty[res[[1, 1]], ___]]], Missing["Unknown"]]]

Appliquez la fonction à différents types d'entités, à des entités et des propriétés.

In[2]:=
Click for copyable input
NLEntityValue["country", "GB", "oil imports"]
Out[2]=
In[3]:=
Click for copyable input
NLEntityValue["city", "windy city", "elderly population"]
Out[3]=
In[4]:=
Click for copyable input
NLEntityValue["celebrity", "the Boss", "birthday"]
Out[4]=
In[5]:=
Click for copyable input
NLEntityValue["moon", "ganymede", "image"]
Out[5]=
In[6]:=
Click for copyable input
Row[NLEntityValue["popular curve", #, "image"] & /@ {"trump", "hillary clinton"}]
Out[6]=

Exemples connexes

de en es ja ko pt-br ru zh