1
$\begingroup$

In the Wolfram Knowledgebase, how would you find the precise name of an EntityProperty, without scrolling through the whole list of them?

For example, suppose I wanted to find the leader of each of the G8 countries in the Wolfram Knowledgebase. I hoped it would be something like

Table[ e["President"], {e, EntityClass["Country","GroupOf8"]} ]

But "President" isn't a property of a country; it's not listed in

EntityProperties["Country"]

"Leader" and "President" and "Prime Minister" don't appear to be in that list, but perhaps I'm not looking for the right word.

To convert strings into Entities, I use the Ctrl-= natural-language input or SemanticInterpretation. But that doesn't work with EntityProperties.

I like using the Knowledgebase, but I'm not sure how to search it.

$\endgroup$
2
  • $\begingroup$ A great way to find out the property name is to use Ctrl= . I might try "current president of Japan", which returns the prime minister of japan on alpha right now. If there is a WL property, the Ctrl= call will return the name or an entity box. $\endgroup$
    – Jason B.
    Nov 10, 2016 at 5:23
  • $\begingroup$ @JasonB, thanks. However, using Ctrl-= on "current president of Japan" (without quotes) results in "No Wolfram Language translation found." Same with "president of usa". However, I agree that Ctrl-= often correctly returns the Entity and the EntityProperty together in the correct syntax, e.g., "obese adults in usa" returns Entity["Country", "UnitedStates"][EntityProperty["Country", "AdultsObese", {"Gender" -> "Total"}]]. $\endgroup$ Nov 14, 2016 at 17:03

1 Answer 1

2
$\begingroup$
countries = Last /@ (Interpreter["CountryClass"]["G8"]["Members"])

(*  {"Canada", "France", "Germany", "Italy", "Japan", "Russia", \
"UnitedKingdom", "UnitedStates"}  *)

Grid[({#, 
      WolframAlpha[
       "President of " <> #, {{"Result", 1}, "Content"}]} & /@ 
    countries) /.
  {c_, Missing["NotAvailable"]} :>
   {c, WolframAlpha[
     "Prime Minister of " <> c, {{"Result", 1}, "Content"}]}, 
 Alignment -> Left]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks @BobHanlon, the trick of using WolframAlpha for extra semantic processing is a good one. However, this technique doesn't reveal the name of the appropriate EntityProperty, if it exists. The main question at hand is how to find the name of an EntityProperty (or find that no such property for an entity exists) in the Wolfram Knowledgebase. $\endgroup$ Nov 14, 2016 at 17:06

Your Answer

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

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