Message Boards Message Boards

1
|
2049 Views
|
4 Replies
|
7 Total Likes
View groups...
Share
Share this post:

How to Structure a Simple EntityStore

I posted this on Stack Exchange, but received no replies. Maybe someone in the community has an answer. I have modified a simple example from the documentation:

store = EntityStore[
  "t" -> <|"Entities" -> <|"e1" -> <|"p1" -> 17|>, 
      "e2" -> <|"p2" -> 288|>|>|>];
EntityRegister[store];
Entity["t", "e1"]["Properties"]

In this modified example, entity e1 only has property p1, while entity e2 only has property p2. However, when you query the properties for each entity, both properties p1 and p2 are listed.

Is there a way to structure the store so that only property p1 shows for entity e1 and only property p2 shows for entity e2?

POSTED BY: Jonathan Kinlay
4 Replies

In any event my question remains unanswered. I.e. is there a way to construct an EntityStore so that entities can have different properties. Or can the EntityStore construct only handle regular (non-ragged) datasets? Imputing properties or property values is not what is required here...

POSTED BY: Jonathan Kinlay

But I don't agree with our characterization that entities of type "t" have two properties.

By definition they do. Properties are defined for each semantic type defined in a given entity store. Your entity store has one semantic type with two defined properties. There is only one value stored for each property, because your data is ragged rather than rectangular. But EntityValue does a great job with non-rectangular data and will return a Missing for any property value not stored in the data.

POSTED BY: Jason Biggs

Your store is structured properly, and the return from "Properties" is correct because entities of type "t" have two properties. I don't see this in the documentation anywhere but it looks like you can get the list of properties from a given entity that would return a non-missing value with the following:

In[23]:= Entity["t", "e1"]["NonMissingProperties"]

Out[23]= {EntityProperty["t", "p1"]}
POSTED BY: Jason Biggs

Hi Jason,

Thanks - that's a useful tip.

But I don't agree with our characterization that entities of type "t" have two properties. Entity e1 has a single property, as has entity e2. But the EntityStore construct appears to force each entity to assume both properties, even when they have null values.

What you seem to be implying is that the Entity Store structure can only handle regular ("square") data structures. Is that really correct? If so, it does limit the applicability of the EntityStore to more complex data structures.

POSTED BY: Jonathan Kinlay
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