Message Boards Message Boards

0
|
8947 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Filtering Entity lists?

Posted 8 years ago

Desired output: a list of entities from the same class that have been filtered (e.g., they aren't missing "Image", they have a "Length" > 30 ft., or they have a "BirthDate" ? 1950).

I can accomplish this by retrieving one entity at a time, testing it, and adding it to a list if it passes the test:

dinos = {};
While[Length[dinos] < 4,
  tryDino = RandomChoice[EntityList[EntityClass["Dinosaur", "DinosaurSpecies"]]];
  If[! (MemberQ[dinos, tryDino] ||  MissingQ[EntityValue[tryDino, "Image"]]), 
   dinos = Append[dinos, tryDino]]];
{dinos}

In this case, I get four dinosaurs that have images, which is what I want. But I get the feeling that there is a better way to do this, something along the lines of "Get a list four dinosaurs that have images" rather than "Get one dinosaur, and if it has an image, add it to the list." I know how to use the RandomSample[] function. Is there a way to stipulate when querying the database that the entities should have certain properties or property values?

(By the way, I did search this community for answers first and found a discussion about dwarf planets that seemed to answer the question. On further investigation, though, I was unable to apply that solution to my situation.)

Thank you in advance,

Mark Greenberg

POSTED BY: Mark Greenberg
3 Replies
POSTED BY: Sean Clarke
Posted 8 years ago

Thank you for your reply. This is exactly what I needed.

I had seen mention of "Implicit Entities" in the docs, but, being somewhat overwhelmed by the learning curve as I teach myself Wolfram Language, I did not recognize it as the solution to my question. The last part of your answer is still mysterious and magical to me, but I'll get it eventually.

Thanks again,

Mark

POSTED BY: Mark Greenberg

Some serious thread resurrection here, but Sean — am I correct to understand from your documentation quote and example that only a limited number of test functions are supported, and that more general tests are not? E.g., I couldn't do something like:

test=EntityList[
  "WolframLanguageSymbol", {"DocumentationExampleInputs" -> (<|#|>[
        "NeatExamples"] != {} &)}];

This seems to just return EntityList["WolframLanguageSymbol"], so I'm guessing not. Is there any workaround to this, or is this a limitation based on some deeper dependency/functionality?

POSTED BY: Arben Kalziqi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract