Genie Community Forum

Entity type information

Hi,
I’m studing the ThingTalk language and I need of a clarification about Entity type.
What are the elements specified inside (…), after word Entity?
Is each element an identifier of a specific Object?
Is it possible define an Entity contains some objects of Number type, Boolean type or String type ?
Is it possible create an Entity contains miscellaneous elements, such as Date, Measure and others ?
How can I do it?
Consider this example: new Thingpedia.Value.Entity(“goog”, “tt:stock_id”, “Alphabet Inc.”). What does it mean? Did we create an entity with three string objects?

Many Thank’s

An Entity type is the type of references to some named entity, such as a person, a restaurant, a movie, etc.
The part inside the () is an entity identifier.
Valid entity identifiers are listed at https://almond.stanford.edu/thingpedia/entities

Operationally, an entity value is a string identifier.
Some entities have names and some are just opaque strings.
You cannot create entities whose ID is a number or boolean, but you can stringify those values and use them as ID if desired. Entities are not container types.

The constructor you gave new Thingpedia.Value.Entity(“goog”, “tt:stock_id”, “Alphabet Inc.”) is not valid.
I realize now there is a bug in the docs, which I’ll fix.
It would be either new Thingpedia.Value.Entity(“goog”, “Alphabet Inc.”) or new Thingpedia.Value.Entity(“goog”, null). The former constructs an entity value with ID “goog” and name “Alphabet Inc.” while the latter constructs an entity value with ID “goog” and no name.
Because ThingTalk is a statically-typed language, the entity type is implicit.

Hi Giovanni and all,
thank’s a lot for answer.
I have a dubt.
Example: I define a new Entity by new Thingpedia.Value.Entity(“Andrea Campetella”, “Person”). When I use this Entity in signature of a Query, how can I write it? Entity(Andrea Campetella) ? Is it correct?

BR

I think you’re confusing the type declaration with the syntax of values.

“Andrea Campetella” is a value. That value has some type, let’s call it com.example:person.

You declare, in the manifest.tt the type, as Entity(com.example:person).
You construct, inside index.js, the value, as new Tp.Value.Entity("CMPNDR...", "Andrea Campetella") - where “CMPNDR…” is some unique identifier for the specific person (in this case a fiscal code/SSN).

Does it make sense?