Introducing composite entities

As your Wit app matures, you will encounter more and more complex queries. Even using roles, it can become difficult to associate relevant entities with each other within a complex query like, “Find me a 2007 red Mustang and a 2003 grey Prius”.

To make your life easier, today we roll out composite entities. Composite entities are custom entities which have entities within them. For example, your could tag “2007 red Mustang” as a car and tag “Mustang” as the model, “red” as the color, and “2007” as the year. Nested entities can be other custom entities or any of Wit’s builtin entities.

Composite entities are tagged just like regular entities. First, select the entire span of the composite entity and assign it to a custom entity just like you would before. Then, select spans within the tagged entity and tag them as any entity you want (custom or builtin). Currently, Wit will only processes one level of nested entities; you cannot have a nested entity within another nested entity.

You can attach roles to composite entities and nested entities just like you would for standard entities.

In the api response, nested entities found within composite entities are returned as a list under the field “entities” and are formatted just like regular entities. An example response is below.

"msg_id" : "$ID",
"_text" : "find a 2007 red mustang",
"outcomes" : [ {
"_text" : "find a 2007 red mustang",
"intent" : "find_car",
"entities" : {
"car" : [ {
"value" : "2007 red mustang",
"entities" : {
"number" : [ {
"value" : 2007,
"type" : "value"
} ],
"color" : [ {
"value" : "red"
} ],
"model" : [ {
"value" : "mustang"
} ]
} ]
"confidence" : 0.52
} ]

We hope that composite entities will help you better interpret the information Wit extracts from your users’ statements so your app can make more intelligent decisions.

As always, feel free to reach out if you have any questions, comments, or suggestions.

Keep hacking,

Team Wit

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.