Skip to main content

Entity data types

Speechly can post-process some entity values so that they are returned in a more structured format. This is done by assigning the entity to have an appropriate data type.

Below are the supported entity data types, a brief description of what they do, and what standard variable they are designed to work with.

string

The default data type, returns the value verbatim.

date_future

Expressions that define a date are returned as ISO-8601 formatted string. Relative expressions like tomorrow or next Friday are parsed relative to the current date.

Example
january fifth twenty twenty four → 2024-01-05

date_past

Expressions that define a date are returned as ISO-8601 formatted string. Relative expressions like yesterday or last Monday are parsed relative to the current date.

Example
april ninth twenty twenty → 2020-04-09
Info

The two date types only differ in their behavior with relative date expressions in which it is unknown whether the user speaks about the future or the past.

For example, the phrase “on Monday” can either refer to the previous Monday (in the past), or the following Monday (in the future). Likewise, “January fifth” can either refer to the previous or next January.

By choosing the variant that prefers future dates, such phrases are mapped to a date in the future, while the one that prefers the past will return a date in the past, respectively.

Which variant you should use depends on the application in question, and whether your users are more likely to talk about the future or the past.

time

Expressions that define a time of day are returned as a hh:mm formatted string using a 24-hour clock.

Example
three thirty pm → 15:30
quarter past two in the morning → 02:15
twenty past nine pm → 21:20

number

Normalizes all numeric utterances into digits.

Example
five six four nine → 5649
seventeen point five → 17.5
three hundred thousand → 300000
three quarters → 0.75

identifier

Should be used together with alphanumeric identifiers (sequences) that are spelled out one character at a time. Entities of this type are normalized into character sequences representing the identifier.

Example
zero zero seven x → 007x
one two seven dot zero dot zero dot one slash x y → 127.0.0.1/xy

phone_number

  • Standard variable: $SPEECHLY.PHONE_NUMBER
  • Recommended for expressions that are phone numbers. Entities with this type are formatted according to common conventions for writing telephone numbers.
Example
plus four four two oh seven seven three oh one two three four → +44 207 730 1234

proper_noun

Should be used with entities that are person names. The returned entity value should in most cases have appropriate capitalization, and parts of the name that were spelled letter by letter should be combined to a single word.

Example
c o n a n o’brien → Conan O’Brien

email_address

  • Standard variable: $SPEECHLY.EMAIL_ADDRESS](/reference/standard-variables#speechlyemail_address)

Formats the returned entity value as an email address.

Example
john dot smith at company dot com → john.smith@company.com
a n t t i at speechly dot com → antti@speechly.com

url

Formats the returned entity value as a website URL.

Example
h t t p s colon slash slash docs dot speechly dot com → https://docs.speechly.com

address

Formats the returned entity value as a US style street address.

Example
one twenty three michigan avenue → 123 Michigan Av.
forty seven east one hundred and tenth street → 47 E 100th St.

lookup

The returned values of entities having lookup type are normalized according to a simple lookup mechanism. This is useful for mapping synonyms to a normalized value.

Example
t v → tv
tv set → tv
telly → tv
television → tv
Info

See Imports and lookups to learn more.