In our getting started with entities guide we went through the value entities can add to strengthen and fine-tune your project's recognition. The example we used covered creating an entity that treats the words “latest”, and “new” as synonyms within your project. In this example we used single words for the content of our entity, what we didn’t discuss was the option of compounding two or more words within an entity. These “compounds” provide an increased level of control and precision when setting up your recognition. Let’s go through what compounds are with another example.
Let’s say we’re an insurance company and we want to capture different types of insurance our end-users could ask us about. If one of our users would say “Do you offer car insurance?”, and we want to ensure that if a user asks us about car insurance that we can match a specific article on this value, then we’d put the words “car insurance” in an entity. This type of entity entry is called a compound, as it compounds the words “car”, and “insurance” into a single value for recognition purposes. The words “car”, and “insurance” on their own reference a very different entity from a linguistic point of view when compared to their compound equivalent.
How to Add a Compound Word
Adding a compound word to an entity is very similar to adding a single word. There are however a few additional options available to you when creating a compound. Compounds have two additional settings that can be factored in to increase flexibility and matching conditions. Keep in mind that when enabling these settings, the compound is forced to be split into two halves (disabled by default). Each half of the compound has a strict word order that does not allow for additional input between its contents. If we were to put this in an example, splitting a compound would look as follows:
- Say we have a compound that consists of two words “car insurance”.
- If we change one of the settings away from the default, the compound should be split into two halves. Conversational AI Cloud does not make any assumptions as to where this split should occur, so it’s up to the Content Editor to decide how to split their compound.
- The split here would result in the first half of the compound becoming “car”, and the second half “insurance”.
The following settings are made available to you when creating a compound word:
- Allow input between words: This setting determines whether or not Conversational AI Cloud should match the compound if there are words in between the two halves of the compound. In the case of our “car insurance” example setting this value to “Only one word” will allow for a single word to be between the two halves, and have the compound still be recognized. Example “car extra insurance” would still be matched as “car insurance” to the compound word, even though the word “extra” is added in between.
- Lock word order: This determines whether or not the order of words is relevant when provided in the end-users input. I.e. if a user says “I want insurance car” (although a poor grammatical example) the compound will still be matched.
When enabling either setting you’ll have the following options to choose from:
- Allow input between words:
- None (default)
- Only one word
- One word or more
- No word or one
- No word or more
- Lock word order:
- Enabled (default)
- Disabled
Now that we’ve discussed the possibilities when creating a compound word for an entity, it’s time to actually create one. Go to the entity editor and find an existing entity or create a new one for the compound word that you want to add. For the purpose of this guide, we’ll create a new entity for “car insurance”.
To create your first compound word for an entity, perform the following steps in order:
- Open the Entity editor
- Click the add “+” icon and select “Create standard”
- Enter a name and description for the entity
- Click the add “+” icon and select "Add combined word"
- Type a word into the text field and click the add icon “+”; do this for each combined word you want to add to the entity. If needed, adjust the settings that you want to use for your combined word
- Click the “Add” button
- Click the “Save” button
Good to know:
Compound words can only consist of a maximum of 8 words.