2
$\begingroup$

I am doing some work with my own EntityStores as well as the built in Wolfram Entities. After pulling a subset of data, I am wanting to structure it as a dataset and to do so I need to be able to extract the property names to use as keys in an association thread.

It easy to get the Properties, but as you can see, the result comes out structured like an Entity.

Properties

I tried using TextString but essentially got the input form:

TextString

If I were dealing with the Entities themselves, I could use simply use ["Name:]

Name

I can do a work around with StringSplit, but that seems like a very round about way to do things.

StringSplit[#, {"[", ","}] & /@ 
  TextString /@ EntityProperties["Aircraft"][[All, 2]] // Flatten

Is there a solution that I am missing that doesn't require such Wolfram Gymnastics?

$\endgroup$
3
  • 3
    $\begingroup$ Doesn't already EntityProperties["Aircraft"][[All , 2]] give you what you want? $\endgroup$
    – Kuba
    Sep 18, 2018 at 19:11
  • $\begingroup$ Wow... it does... I had no idea you could select a part of the variables of a function. Essentially that code would be: EntityProperty["Aircraft","Ceiling"][[2]] which in fact returns "Ceiling". I had only seen Part used with lists and not with functions. Thanks for the simple solution! $\endgroup$
    – kickert
    Sep 18, 2018 at 19:26
  • 3
    $\begingroup$ Unless an expression is atomic (AtomQ), you can manipulate it like a List can be manipulated. $\endgroup$
    – Kuba
    Sep 18, 2018 at 19:46

1 Answer 1

6
$\begingroup$

You could use EntityValue instead:

EntityValue["Aircraft","PropertyCanonicalNames"]

{"Ceiling", "Crew", "CruiseSpeed", "DesignedBy", "EmptyWeightPerBooster", "Height", "Image", "Introduced", "Length", "LoadedWeight", "MaidenFlight", "Manufacturer", "MaxSpeed", "MaxWeight", "Name", "NumberBuilt", "PowerPlant", "PowerPlantCount", "Range", "RateOfClimb", "Status", "Type", "WingArea", "WingLoading", "Wingspan"}

Another possibility is to use the function CanonicalName:

CanonicalName /@ EntityProperties["Aircraft"]

Also, for built-in entity types, you could use the subproperty "Dataset" to create a dataset:

EntityValue[
    EntityClass["Aircraft", "Harlow"],
    {"Ceiling", "Height", "Length"},
    "Dataset"
]

enter image description here

$\endgroup$
1
  • $\begingroup$ Excellent. That works great. I was afraid it wouldn't work with my own EntityStores since they include very limited properties, but everything translates nicely. $\endgroup$
    – kickert
    Sep 18, 2018 at 19:32

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.