Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

How to permanently store an EntityType?

I am wondering how to permanently store a custom entity using EntityRegister and EntityStore. I have figured out how to make it work in a local session, but restarting Mathematica resets my entity and I have to reload it. How can I permanently store a custom Entity type that is not a Resource Data object?

POSTED BY: Peter Burbery
3 Replies

Thank you! I have found this helpful. I have two questions. If I wanted to add more entities to my custom entity type, how would I do it? Is there a way to add an entity type to the autocomplete menu?

POSTED BY: Peter Burbery
Posted 4 years ago

If I wanted to add more entities to my custom entity type, how would I do it?

Using the fruit example above, assuming it has been registered then to add a new entity

Entity["fruit", "orange"]["color"] = Orange

Orange has been added

EntityList["fruit"]

There is no need to register/unregister, but the PersistentSymbol will have to be updated.

Is there a way to add an entity type to the autocomplete menu?

There may be, but I don't know how.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

Using PersistentSymbol

fruit = EntityStore[
  "fruit" -> <|
    "Entities" -> <|
      "banana" -> <|"color" -> Yellow|>,
      "strawberry" -> <|"color" -> Red|>
      |>
    |>]

PersistentSymbol["fruit"] = fruit

Quit[]

Add this to init.m

EntityRegister[PersistentSymbol["fruit"]]

Then this should work

EntityList["fruit"]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard