{"id":22994,"date":"2019-12-11T12:35:04","date_gmt":"2019-12-11T12:35:04","guid":{"rendered":"https:\/\/developer.kore.ai\/v9-1\/?p=22994"},"modified":"2021-05-10T10:53:42","modified_gmt":"2021-05-10T09:53:42","slug":"how-to-use-patterns-for-intents-entities","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v9-1\/docs\/bots\/how-tos\/how-to-use-patterns-for-intents-entities\/","title":{"rendered":"How to use Patterns for Intents &amp; Entities"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>Using patterns can help to improve NLP interpreter accuracy.<\/p>\n<p>In this document, we will elaborate on the various pattern syntax and how they can be used in intent detection and entity extraction.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p><b>Things to Remember:<\/b><\/p>\n<ul>\n<li>Patterns are to be used as a last resort, only for cases where ML engine cannot be used. Examples of such cases would be to train bot in recognising idiomatic utterances, command like utterances.<\/li>\n<li>Patterns are evaluated in the order of their listing. Once a match is found the rest of the patterns are not evaluated. So ensure when adding patterns to add in the order of most restrictive to least restrictive.<\/li>\n<li>Only one wildcard (*) is allowed in a pattern.<\/li>\n<li>While most of the features are supported in all languages, there are some exceptions, <a href=\"\/docs\/bots\/how-tos\/multi-lingual-bot-behavior\/\" target=\"_blank\" rel=\"noopener noreferrer\">see here for more details<\/a>.<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<div class=\"alert alert-info\">The following are some general guideline for creating intent patterns:<\/div>\n<ul>\n<li>Use a minimum of 3 words.<\/li>\n<li>Use words in their canonical forms (i.e. infinitive verbs, singular nouns).<\/li>\n<li>Use lowercase both for words and their synonyms.<\/li>\n<li>Use the US spelling of words (i.e. <em>normalize<\/em> instead of <em>normalise<\/em>).<\/li>\n<li>Avoid using determiners and pronouns (the, a, my, that).<\/li>\n<li>Avoid using digits.<\/li>\n<li>Avoid using entity values in defining a task pattern.<\/li>\n<li>Don\u2019t use elision (i.e. what\u2019s ).<\/li>\n<li>Don\u2019t use special characters such as () &amp; \/ \\ $ [ ] + *.<\/li>\n<li>Don\u2019t use punctuation such as &#8211; , . ! ? \u2018 \u201c.<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Patterns_for_Intent_Detection\">Patterns for Intent Detection<\/span><\/h2>\n<p>Following is a list of pattern syntax, along with examples, that can be configured for intent detection.<\/p>\n<table>\n<thead>\n<tr>\n<th>Pattern<\/th>\n<th>Description<\/th>\n<th>Pattern Examples<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"15%\"><strong>word1 word2 &#8230; wordn<\/strong><\/td>\n<td width=\"45%\">This mandates all the words defined to be available in the user utterance in the same consecutive order with upto 3 (language specific) additional words allowed between any two consecutive words mentioned in the pattern and infinite number of words before and after those specified set of words.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>can you please transfer funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>can you please transfer some funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8211; &#8220;<em>i want to transfer<\/em>&#8220;<br \/>&#8211; &#8220;<em>can i transfer some significant amount of monetary funds<\/em>&#8220;<br \/>&#8211; &#8220;<em>i want to do fund transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1_word2<\/strong><\/td>\n<td width=\"45%\">Enforce phrase, no additional words allowed in between word1 and word2. This is to ensure a sequence of tokens are read as a phrase. Usage restricted to words, concepts not allowed.<br \/><u>Note<\/u>: There should be no space between the word1, word2 and _. Also be aware that &#8220;_word1&#8221; is to ensure that the word1 in the user utterance is <u>not marked<\/u> as <span style=\"text-decoration: underline\">Used Up<\/span> by the platform and is to be considered for entity extraction. This is useful when entity words are used in the intent pattern.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer_fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8220;<em>can you help me transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>can you please transfer some funds from my account<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1 * word2<\/strong><\/td>\n<td width=\"45%\">0 to infinite number of additional words between the specified words\/phrases<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer * fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>can you please transfer some funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>can you help me transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1 *n word2<\/strong><\/td>\n<td width=\"45%\">Exactly <em>n<\/em> number of additional words between the specified words\/phrases<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer *2 fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>can you help me transfer some significant funds from my account<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8211; &#8220;<em>i want to transfer<\/em>&#8220;<br \/>&#8211; &#8220;<em>can you please transfer some funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>can you help me transfer some significant amount of funds<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1 *0 word2<\/strong><\/td>\n<td width=\"45%\">To disable wildcards between two tokens. Similar to the underscore between two words but can be used between two concepts or within [\u00a0 ], {\u00a0 } groups.<br \/>(available 7.1 onwards)<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer *0 fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>can you please transfer funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>can you help me transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to transfer some funds<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1 &lt; word2<\/strong><\/td>\n<td width=\"45%\">Indicates the match for word2 should start from the beginning of a sentence. It is useful especially when the word2 appears in the middle of the utterance.<br \/>Add a space after the angular bracket<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer &lt; fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>want to transfer funds<\/em>&#8220;<br \/>&#8211; &#8220;<em>i want to initiate fund transfer<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1 &gt; word2<\/strong><\/td>\n<td width=\"45%\">Indicates the end of the sentence and no words are allowed after it.<br \/>Add a space before closing the angular bracket<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer * fund &gt;<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>transfer funds<\/em>&#8220;<br \/>&#8211; &#8220;<em>transfer few funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>transfer funds today<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>!abc<\/strong><\/td>\n<td width=\"45%\">Indicates the word\/concept &#8220;abc&#8221; should not exist anywhere in the user utterance after this token<br \/>No space between ! and word\/concept<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8211; &#8220;<em>!status transfer fund<\/em>&#8220;<br \/>&#8211; &#8220;<em>transfer !status fund<\/em>&#8220;<br \/>&#8211; &#8220;<em>transfer fund !status<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8220;<em>i want to transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8211; &#8220;<em>what is the status of my fund transfer<\/em>&#8220;<br \/>&#8211; &#8220;<em>i want to find my fund transfer status<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>!!abc<\/strong><\/td>\n<td width=\"45%\">The very next word\/concept should not be &#8220;abc&#8221;<br \/>No space between !! and word\/concept<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer fund !!status<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>i want to transfer funds<\/em>&#8220;<br \/>&#8211; &#8220;<em>what is the status of my fund transfer<\/em>&#8220;<br \/>&#8211; &#8220;<em>i want to find my fund transfer from yesterday&#8217;s status<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to find my fund transfer status<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>[ &#8230; ]<\/strong><\/td>\n<td width=\"45%\">Used to define a group of words\/concepts and the match should be against exactly one of the group declared in [ ]. Be aware that when a match is found the rest of the group is ignored, so order the words accordingly.<br \/>Note: the parentheses should not be clubbed with the word, i.e maintain a space between the parenthesis and the adjacent word.<br \/>\nDue to the difficulty in maintaining and tracking, it is recommended you use concept instead of this pattern. This pattern also has detrimental effect on the bot  performance.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer [ funds amount cash ]<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>transfer money<\/em>&#8220;<br \/>&#8211; &#8220;<em>can i transfer some cash<\/em>&#8220;<br \/>&#8211; &#8220;<em>i want to transfer funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>transfer dollars<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>{ &#8230; }<\/strong><\/td>\n<td width=\"45%\">Used to define a optional group or words\/concepts and the match would be against zero or one of the words\/patterns declared in { }. Be aware that when a match is found rest of the group is ignored, so order the words accordingly.<br \/>Note: the parentheses should not be clubbed with the word, i.e maintain a space between the parenthesis and the adjacent word.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>transfer { some few my } fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>how do i transfer funds<\/em>&#8220;<br \/>&#8211; &#8220;<em>can i transfer some funds<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>( &#8230; )<\/strong><\/td>\n<td width=\"45%\">contain a pattern i.e when a pattern or part of a pattern is enclosed in these parentheses, we treat it as a pattern unlike [ ] and { }.<br \/>This is the default setting i.e. when a pattern <em>word1 word2<\/em> it is treated as <em>( word1 word2 )<\/em><br \/>Commonly used explicitly to define sub pattern inside [ ] or { }<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>( transfer fund )<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8220;<em>transfer funds from my account<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i would like to initiate fund transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>&lt;&lt; &#8230; &gt;&gt;<\/strong><\/td>\n<td width=\"45%\">Used to find words in any order<br \/>\nDue to the risk of running into false positives, you are advised <u>not<\/u> to use this pattern.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>&lt;&lt; transfer fund &gt;&gt;<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8211; &#8220;<em>transfer funds from my account<\/em>&#8220;<br \/>&#8211; &#8220;<em>i would like to initiate fund transfer<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>i want to transfer<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>&#8216;word1<\/strong><\/td>\n<td width=\"45%\">If you quote words or use words that are not in canonical form, the system will restrict itself to what you used in the pattern<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>&#8216;like to transfer fund<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8220;<em>I would like to ransfer funds from my account<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>I really liked transfer funds process<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"15%\"><strong>word1~concept2<\/strong><br \/><strong>~concept1~concept2<br \/><\/strong>(from ver8.0)<\/td>\n<td width=\"45%\">A word (word1) or concept (concept1) can be matched only if it is also a member of another concept (concept2). The most common usage of this is through the system concepts that are dynamically added for each POS tag.<\/td>\n<td width=\"40%\">\n<table>\n<tbody>\n<tr>\n<td><strong>Sample Pattern<\/strong><\/td>\n<td>&#8220;<em>schedule~verb<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance Match<\/strong><\/td>\n<td>&#8220;<em>schedule a meeting<\/em>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><strong>Utterance not Matching<\/strong><\/td>\n<td>&#8220;<em>show my schedule<\/em>&#8220;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Pattern_Operators\">Pattern Operators<\/span><\/h2>\n<ul>\n<li><b>AND: ( X Y )<\/b>: An ordered relationship of words in sequence. This is the default setting. i.e. when you specify a pattern as <em>cancel order<\/em> it is the same as <em>(cancel order)<\/em>.<br \/>For example, <i>(Cancel Order)<\/i> matches <em>Cancel my phone order<\/em> but doesn\u2019t match <em>I have a pending order for an iPhone X, can I cancel<\/em>. Bot Builder tool uses patterns with increasing numbers of wildcards between words (up to 3 for an intent). So a pattern of <em>Cancel Order<\/em> can match:\n<ul>\n<li>cancel order<\/li>\n<li>cancel my order<\/li>\n<li>cancel that last order<\/li>\n<li>cancel last weeks big order<\/li>\n<\/ul>\n<\/li>\n<li><b>OR: [X Y Z]<\/b>: Any of these can be interchangeably used in the user utterance. For example, ([get make] me [food drink dessert]) will match any of the below utterances:\n<ul>\n<li>Get me food<\/li>\n<li>Make me a drink<\/li>\n<li>Get me a drink<\/li>\n<li>Get me a dessert<\/li>\n<li>Make me some quick food<\/li>\n<\/ul>\n<\/li>\n<li><b>NOT: !X<\/b>: Words that should not appear in the user utterance for an intent match. For example, (!forecast) is marked as a pattern for intent named <em>Get current weather<\/em> and the bot supports another intent called <em>Get 3-day weather forecast.<\/em>\n<ul>\n<li>User utterance: <em>Planning a trip to California get me the forecast<\/em>\n<ul>\n<li>will not match <em>Get current weather<\/em><\/li>\n<li>will match <em>Get 3-day weather forecast<\/em><br \/>Note that the <em>!word<\/em> means <em>not after this point<\/em>. So (!forecast the weather) and (get the weather !forecast) are different. The utterance <em>get the forecast for the weather<\/em>\u00a0matches the second but not the first.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><b>Optional: {X}<\/b>: For example, {phone} If the user utterance is <em>Get me a phone number<\/em> or <em>get me a number<\/em>\u00a0the platform will treat it equally.<\/li>\n<li><strong>Enforce Phrase:<\/strong> X_Y: To enforce occurrence of the phrase as is in the user utterance, without any words in between. For example, transfer_funds. The utterance <em>transfer funds<\/em> or <em>I want to transfer funds<\/em> will match but not <em>Can I transfer some funds<\/em>.<\/li>\n<li><b>Concepts: ~<\/b>: Platform has a large set of inbuilt concepts that developers can use to define a pattern. For example, (I [like love] ~world_country) will match\n<ul>\n<li>I like India<\/li>\n<li>I love traveling to Australia<\/li>\n<li>I would like to visit an African country<\/li>\n<\/ul>\n<\/li>\n<li><b>Unordered: &lt;&lt;, &gt;&gt;<\/b>: Used to find words in any order. For example, &lt;&lt;Cancel Order&gt;&gt; matches <i>Cancel my phone order<\/i> and also <i>I have a pending order for an iPhone X, can I cancel<\/i><\/li>\n<li><b>Start\/End of Statement: &lt;, &gt;:<\/b> For example, ( <em>transfer fund &gt;<\/em> ) will match <i>I want to <em>transfer funds<\/em><\/i> but will not match <em>transfer funds today.<\/em><\/li>\n<li><b>Quote: \u2018 &#8211;<\/b>: If you quote words or use words that are not in canonical form, the system will restrict itself to what you used in the pattern. For example, (<em>like to transfer funds<\/em>) This matches <em>I would like to transfer funds from my account<\/em> but not <em>I really liked transfer funds process<\/em>.<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Negative_Patterns\">Negative Patterns<\/span><\/h2>\n<p>Negative Patterns can be used to eliminate intents detected in the presence of a phrase. This will help filter the matched intents for false positives.<\/p>\n<p><strong>User Utterance<\/strong>: &#8220;<em>I was transferring funds when I got network failure error&#8221;<br \/>\n<\/em><strong>Intent Detected<\/strong>:\u00a0<em>Transfer Funds<br \/>\n<\/em><strong>Intended Intent<\/strong>:\u00a0<em>Register Complaint<\/em><\/p>\n<p>Add a\u00a0<strong>Negative Pattern<\/strong> (<em>network failure) (error) (technical issue)<\/em>\u00a0for the intent <em>Transfer Funds<\/em><br \/>\n<strong>User Utterance<\/strong>: &#8220;<em>I was transferring funds when I got network failure error&#8221;<br \/>\nor &#8220;I was transferring funds when I faced a technical issue&#8221;<br \/>\nor &#8220;I got an error during transfer funds process.&#8221;<br \/>\n<\/em><strong>Intent Rejected<\/strong>:\u00a0<em>Transfer Funds<br \/>\n<\/em><strong>Intent Triggered:<\/strong><em> Register Complaint<br \/>\n<\/em><\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Patterns_for_Entity_Extraction\">Patterns for Entity Extraction<\/span><\/h2>\n<p>Patterns can be used to identify the values for entities in user utterance based upon their position and occurrence in user utterance.<\/p>\n<p>Intent patterns operators like <em>{&#8230;}<\/em>, <em>[&#8230;]<\/em>, <em>!<\/em>, <em>~concepts<\/em> can be used for entity extraction. The following are some use cases how the patterns can be applied.<\/p>\n<p>Every entity pattern has to include a * (of some form) to represent where the platform should look for an entity value.<\/p>\n<p>Continuing with the Banking Bot example with\u00a0<em>Transfer Funds<\/em> intent. This intent needs two entities &#8211;\u00a0<em>ToAccount<\/em> and\u00a0<em>FromAccount<\/em>. We will see how to achieve this.<\/p>\n<h4>Pattern 1: word1 * word2<\/h4>\n<p>This can be used as a positional wildcard that indicates the expected position of the entity.<br \/>\n<strong>Pattern for\u00a0<em>ToAccount<\/em> entity<\/strong>:\u00a0<em>to * from<br \/>\n<\/em><strong>User Utterance<\/strong>:\u00a0<em>Transfer funds to ABC123 from my account.<br \/>\n<\/em><strong>Entity Extracted<\/strong>:\u00a0<em>ToAccount = ABC123<br \/>\n<\/em><em><strong>User Utterance not resulting in entity extraction<\/strong>: &#8220;transfer funds <span style=\"text-decoration: underline\">for<\/span> ABC123 from my account&#8221;<br \/>\n<\/em><\/p>\n<h4>Pattern 2: word1 *n<\/h4>\n<p>This can be used as a positional wildcard * that indicates the <span style=\"text-decoration: underline\">expected position of the entity based upon the number of words<\/span> after the specified word1. That is, <em>n<\/em> words after the <em>word1<\/em> are to be considered for the entity, if <em>n<\/em> words are not present then look for the next occurence of <em>word1<\/em>.<br \/>\n<strong>Pattern for\u00a0<em>ToAccount<\/em> entity<\/strong>: <em>from *2<br \/>\n<\/em><strong>User Utterance<\/strong>:\u00a0<em>Transfer funds to ABC123 from my account.<br \/>\n<\/em><strong>Entity Extracted<\/strong>: <em>FromAccount = my account<br \/>\n<\/em><em><strong>User Utterance<\/strong>:\u00a0Transfer funds to ABC123 from XYZ321 that is from my account.<strong><br \/>\nEntity Extracted<\/strong>: FromAccount = my account<strong><br \/>\nUser Utterance not resulting in entity extraction<\/strong>: &#8220;transfer funds to\u00a0 ABC123 <span style=\"text-decoration: underline\">using<\/span> my account&#8221;<br \/>\n<\/em><\/p>\n<h4>Extension to Pattern 2: word1 *~n<\/h4>\n<p>Similar to above (pattern 2) but extracts up to n number, if that number of words are available. Note that entities need to extract something so *~1 is really the same as *1.<\/p>\n<h4>Pattern 3: a combination of word1 * word2 and word3 *n<\/h4>\n<p>This can be used as a combination of patterns for the likely location in the user utterance that the entity value could be found and the number of words contributing to the entity.<br \/>\n<strong>Pattern for\u00a0<em>ToAccount<\/em> entity<\/strong>:\u00a0<em>&#8220;to * from&#8221;<\/em> and <em>&#8220;from to *1&#8221;<br \/>\n<\/em><strong>Pattern for\u00a0<em>FromAccount<\/em> entity<\/strong><em>:\u00a0&#8220;from * to&#8221; and &#8220;to from *2&#8221;<\/em><em><br \/>\n<\/em><strong>User Utterance<\/strong>:\u00a0<em>Transfer funds to ABC123 from my account.<br \/>\n<\/em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0or\u00a0<em>Transfer funds from my account to ABC123.<\/em><em><br \/>\n<\/em><strong>Entity Extracted<\/strong>:\u00a0<em>ToAccount = ABC123<\/em> and\u00a0<em>FromAccount = my account<br \/>\n<strong>User Utterance not resulting in entity extraction<\/strong>: &#8220;transfer funds <span style=\"text-decoration: underline\">for<\/span> ABC123 using my account&#8221;<br \/>\n<\/em><\/p>\n<h4>Pattern 4: [ word1 word2 ] *<\/h4>\n<p>This can be for patterns using a group of words or concepts of which at least one should be present in the utterance. The order within the group is important (see above in <a href=\"#Patterns_for_Intent_Detection\">intent detection<\/a> for details).<br \/>\n<strong>Pattern for\u00a0<em>ToAccount<\/em> entity<\/strong>:\u00a0<em>&#8220;to * [ using from ]&#8221;<\/em> and <em>&#8220;[ using from ] to *1&#8221;<br \/>\n<\/em><strong>Pattern for\u00a0<em>FromAccount<\/em> entity<\/strong><em>: &#8220;[ using from ] * to&#8221; and &#8220;to [ using from ] *&#8221;<\/em><em><br \/>\n<\/em><strong>User Utterance<\/strong>:\u00a0<em>Transfer funds to ABC123 from my account.<br \/>\n<\/em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0or\u00a0<em>Transfer funds using my account to ABC123.<\/em><em><br \/>\n<\/em><strong>Entity Extracted<\/strong>:\u00a0<em>ToAccount = ABC123<\/em> and\u00a0<em>FromAccount = my account<br \/>\n<strong>User Utterance not resulting in entity extraction<\/strong>: &#8220;transfer funds <span style=\"text-decoration: underline\">for<\/span> ABC123 using my account&#8221;<br \/>\n<\/em><\/p>\n<h4>Pattern 5: ~CustomConcept *<\/h4>\n<p>This can be for using concepts. You can create your own custom concepts and use them to define patterns.<br \/>\n<strong>Pattern for\u00a0<em>ToAccount<\/em> entity<\/strong>:\u00a0<em>&#8220;to * from&#8221;<\/em> and <em>&#8220;from to *&#8221;<br \/>\n<\/em><strong>Pattern for\u00a0<em>FromAccount<\/em> entity<\/strong><em>: &#8220;~in * to&#8221; and &#8220;to ~in *&#8221;<br \/>\n<\/em>Custom Concept<em>: ~in<\/em> &#8211; <em>(using) (from)<br \/>\n<\/em><strong>User Utterance<\/strong>:\u00a0<em>Transfer funds to ABC123 using my account.<br \/>\n<\/em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0or\u00a0<em>Transfer funds from my account to ABC123.<\/em><em><br \/>\n<\/em><strong>Entity Extracted<\/strong>:\u00a0<em>ToAccount = ABC123<\/em> and\u00a0<em>FromAccount = my account<br \/>\n<\/em><strong>User Utterance not resulting in entity extraction<\/strong>: &#8220;<em>transfer funds to ABC123 <span style=\"text-decoration: underline\">of<\/span> my account<\/em>&#8220;<\/p>\n<h4>Pattern 6: ~intent<\/h4>\n<p>Useful in entity patterns and custom entities<br \/>\nWords that are used in the intent identification are dynamically marked with the <em>~intent<\/em> concept. This can then be used as an anchor or reference point for some entity patterns.<br \/>\n<strong>Sample Pattern<\/strong>:\u00a0<em>&#8220;~intent~meeting~plural<\/em><em>&#8220;<br \/>\n<\/em><strong>User Utterance not resulting in entity extraction<\/strong>: <em>show my meetings.<br \/>\n<\/em><strong>User Utterance might mark the entity<\/strong>: &#8220;<em>schedule a presentation called Meeting the Sales Goals<\/em>&#8220;<\/p>\n<h4>Pattern 7: $currentEntity<\/h4>\n<p>Useful in delaying the evaluation of a pattern until the entity is actually processed. Normally entity patterns are evaluated when a dialog starts and on new input to see if any words need to be protected until that entity is processed. This might not always desirable, especially for strings.<br \/>\n<strong>Pattern<\/strong>:\u00a0<em>&#8220;$currentEntity=TaskTitle &#8216;called *<\/em><em>&#8220;<br \/>\n<\/em>The above rule will result in evaluating the pattern when the dialog flow has reached the TaskTitle node.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"Using patterns can help to improve NLP interpreter accuracy. In this document, we will elaborate on the various pattern syntax and how they can be used in intent detection and entity extraction. Things to Remember: Patterns are to be used as a last resort, only for cases where ML engine cannot be used. Examples of...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-22994","post","type-post","status-publish","format-standard","hentry","category-how-tos"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/22994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/comments?post=22994"}],"version-history":[{"count":19,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/22994\/revisions"}],"predecessor-version":[{"id":27347,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/22994\/revisions\/27347"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/media?parent=22994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/categories?post=22994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/tags?post=22994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}