2
$\begingroup$

I am trying to generate a list of people that Mathematica knows about that have a certain occupation.

Using the PersonData[] command I can get a list of all 285,362 people that Mathematica knows about. For a specific person Entity, I can use PersonData to learn more about them. For example, PersonData[Entity["Person", "LebronJames::tv6s9"], EntityProperty["Person", "Occupation"]] tells me that Lebron James is a basketball player.

I'm trying to filter this list of 285,362 people to a list of people that are basketball players.

  1. Is there a way to download this information from the Cloud without downloading all 286,000 data points first?
  2. If not, how can I use a Select function call or something to filter the PersonData[] list by occupation?

Thanks!

$\endgroup$
  • 1
    $\begingroup$ I think there is a bug with "Person". EntityValue[EntityClass["Person", {"Occupation" -> "basketball player"}], "EntityCount"] should return the number of "Person" entities that have "basketball player" in their "Occupation" list. However it returns zero. Please report to WRI. $\endgroup$ – Edmund May 4 '17 at 0:25
  • $\begingroup$ It works for EntityValue[ EntityClass["Person", {"Gender" -> "Male"}], "EntityCount"] so I'm more inclined to think it is a bug. $\endgroup$ – Edmund May 4 '17 at 0:29
  • $\begingroup$ @Edmund is there a way to return the entire list of entities, not just the count? $\endgroup$ – jxmorris12 May 4 '17 at 14:57
  • 1
    $\begingroup$ See EntityValue. EntityValue[ EntityClass["Person", {"Gender" -> "Male"}], "Entities"] $\endgroup$ – Edmund May 4 '17 at 18:28
1
$\begingroup$

It seems there's no way to access this data in Mathematica 10 without filtering it and resolving your own list. I've produced a list of all basketball players (albeit in several hours) using the following code:

people = PersonData[]; (* over 500,000 Entities representing people *)

isBasketballPlayer[p_] := Module[{occupation},
  (occupation = PersonData[p, "Occupation"];
   If[
    MatchQ[occupation, _Missing],
    False, 
    MemberQ[occupation, "basketball player"]
    ])]; 

basketballPlayers = Select[people, isBasketballPlayer] 
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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