4
$\begingroup$

I tried to create my own entity type in which entities have dated properties.

But I can't find any helpful documentation on that matter. And every try failed.

I tried

store = EntityStore[
  "t" -> <|

    "Entities" -> <|

      "e1" -> <|Dated["p1", 2019] -> 17, "p2" -> 59|>,
      "e2" -> <|"p1" -> 27, "p2" -> 288|>
      |>
    |>]

And

store = EntityStore[
  "t" -> <|

    "Entities" -> <|

      "e1" -> <|"p1" -> <|"Value" -> 17, "Date"->DateObject@2019|>, "p2" -> 59|>,
      "e2" -> <|"p1" -> 27, "p2" -> 288|>
      |>
    |>]

Do you have any suggestions?

$\endgroup$
1
$\begingroup$

I was wrong. I found that dated properties are related to qualifiers and there're some posts about qualifiers of entity framework.

Here's my modified example.

EntityUnregister["beehive"];
EntityRegister[
 EntityStore[
  "beehive" -> <|
    "Entities" -> <|
      "lisa" -> <|{"Population", "Date" -> All} -> 
         TimeSeries[{{{2013}, 100000}, {{2014}, 200000}, {{2015}, 
            150000}}]|>, 
      "tom" -> <|{"Population", "Date" -> All} -> 
         TimeSeries[{{{2013}, 300000}, {{2014}, 200000}, {{2015}, 
            200000}}]|>|>, 
    "Properties" -> <|
      "Population" -> <|
        "DefaultFunction" -> 
         Function[ent, 
          ent[Dated["Population", All]][
           "LastValue"]]|>, {"Population", 
        "Date" -> _?DateObjectQ} -> <|
        "DefaultFunction" -> 
         Function[{ent, quals}, 
          Round[ent[Dated["Population", All]][quals["Date"]]]]|>,
      {"Population", "Date" -> _Interval} -> <|

        "DefaultFunction" -> 
         Function[{ent, quals}, 
          TimeSeriesWindow[ent[Dated["Population", All]], 
            quals["Date"][[1]]]["Values"]]|>
      |>|>]];

$\endgroup$
  • $\begingroup$ Any chance you can point to exactly where the Dated comes in here? I know a reader can figure it out, but it's nice to make it easy on them. $\endgroup$ – b3m2a1 May 15 at 5:43

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.