heidloff.net - Building is my Passion
Post
Cancel

Using regular Expressions for Entities in Conversations

In conversational experiences entities are used to identify classes of objects in user phrases, for example ‘city’ or ‘person’. Watson Conversation supports entity definitions with predefined lists of potential values and synonyms. Recently a new capability has been added so that you can also use regular expressions to identify entities (beta).

This functionality is useful when, for example, you want to identify email addresses, phone numbers or URLs without predefining all potential values.

Let’s take SPRs as an example which IBM used to track issues. The SPRs can have the following formats
SPR: AAML68KURS
SPR:AAML68KURS
SPR#: AAML68KURS
SPR AAML68KURS

The SPRs can be identified via the regular expression ‘SPR[#: ]*?([A-Z]{4}[A-Z0-9]{6})’ which is defined as pattern for the SPR entity.

image

In order to access the actual value of the SPR entity in your code you need to put the value in a context variable.

image

After this Watson Conversation can identify the entity. Here is a sample conversation.

image

Featured Blog Posts
Disclaimer
The postings on this site are my own and don’t necessarily represent IBM’s positions, strategies or opinions.
Trending Tags