This version of the Speechly documentation is no longer actively maintained. For up-to-date documentation, see the latest version.

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.

Why do we need Entity Data Types?

Unless otherwise specified, the entity values returned from the Speechly API are verbatim what the user said. If you have configured the template:

*book book a flight for $SPEECHLY.DATE(departure)

and the user says “book a flight for july third twenty twenty one”, without using a Data Type the API returns:

intent: book
entity:
    name: "departure"
    value: "july third twenty twenty one"

However, if you explicitly designate the entity departure to have Data Type date, the API returns:

intent: book
entity:
    name: "departure"
    value: "2021-07-03"

The Data Type of an entity thus determines what is done to the entity value after it has been recognized. While the default Data Type string returns the value verbatim, the other Data Types, such as date, provide normalizations for the entities that make their further use easier. The Data Types are defined in the Speechly Dashboard when listing entities.

And while Standard Variables and Data Types can be used separately, the two features are best when combined.

Entity Data Type Reference

Here are all Entity Data Types that we support, a brief description of what they do, and what Standard Variable they are designed to work with.

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.

Works together with $SPEECHLY.DATE

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.

Works together with $SPEECHLY.DATE

april ninth twenty twenty → 2020-04-09

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.

Works together with $SPEECHLY.TIME

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.

Works together with $SPEECHLY.*_NUMBER

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.

Works together with $SPEECHLY.IDENTIFIER*

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

phone_number

Recommended for expressions that are phone numbers. Entities with this type are formatted according to common conventions for writing telephone numbers.

Works together with $SPEECHLY.PHONE_NUMBER

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.

Works together with $SPEECHLY.PERSON_NAME

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

email_address

Formats the returned entity value as an email address.

Works together with $SPEECHLY.EMAIL_ADDRESS

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.

Works together with $SPEECHLY.WEB_ADDRESS

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.

Works together with $SPEECHLY.STREET_ADDRESS

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.

t v → tv
tv set → tv
telly → tv
television → tv
See Imports and lookups to learn more.

Last updated by Mathias Lindholm on October 13, 2022 at 17:25 +0300

Found an error on our documentation? Please file an issue or make a pull request