Regex inside Entity (IBM-WATSON)












1















Is it possible to put an entity inside of a regex?
for example, giving that the entity "@pizza-toppings" contains toppings:



"topping": "<? input.text.extract('(?i).+(@pizza-toppings)(?-i)', 1) ?>"


So, if @pizza-toppings matches "onion", then "(?i).+(@pizza-toppings)(?-i)" will be "(?i).+(onion)(?-i)". If it matches "cheese", then it will be "(?i).+(cheese)(?-i)" and so on and so forth.



I've been trying to find a solution but so far I didn't find anything.










share|improve this question

























  • Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

    – data_henrik
    Nov 13 '18 at 12:49











  • Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

    – LAT94
    Nov 13 '18 at 13:29













  • And it is only 1 topping. Not toppings. I edited the question and changed it.

    – LAT94
    Nov 13 '18 at 13:32













  • So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

    – LAT94
    Nov 13 '18 at 13:37











  • Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

    – data_henrik
    Nov 13 '18 at 13:52
















1















Is it possible to put an entity inside of a regex?
for example, giving that the entity "@pizza-toppings" contains toppings:



"topping": "<? input.text.extract('(?i).+(@pizza-toppings)(?-i)', 1) ?>"


So, if @pizza-toppings matches "onion", then "(?i).+(@pizza-toppings)(?-i)" will be "(?i).+(onion)(?-i)". If it matches "cheese", then it will be "(?i).+(cheese)(?-i)" and so on and so forth.



I've been trying to find a solution but so far I didn't find anything.










share|improve this question

























  • Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

    – data_henrik
    Nov 13 '18 at 12:49











  • Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

    – LAT94
    Nov 13 '18 at 13:29













  • And it is only 1 topping. Not toppings. I edited the question and changed it.

    – LAT94
    Nov 13 '18 at 13:32













  • So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

    – LAT94
    Nov 13 '18 at 13:37











  • Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

    – data_henrik
    Nov 13 '18 at 13:52














1












1








1








Is it possible to put an entity inside of a regex?
for example, giving that the entity "@pizza-toppings" contains toppings:



"topping": "<? input.text.extract('(?i).+(@pizza-toppings)(?-i)', 1) ?>"


So, if @pizza-toppings matches "onion", then "(?i).+(@pizza-toppings)(?-i)" will be "(?i).+(onion)(?-i)". If it matches "cheese", then it will be "(?i).+(cheese)(?-i)" and so on and so forth.



I've been trying to find a solution but so far I didn't find anything.










share|improve this question
















Is it possible to put an entity inside of a regex?
for example, giving that the entity "@pizza-toppings" contains toppings:



"topping": "<? input.text.extract('(?i).+(@pizza-toppings)(?-i)', 1) ?>"


So, if @pizza-toppings matches "onion", then "(?i).+(@pizza-toppings)(?-i)" will be "(?i).+(onion)(?-i)". If it matches "cheese", then it will be "(?i).+(cheese)(?-i)" and so on and so forth.



I've been trying to find a solution but so far I didn't find anything.







regex ibm-cloud chatbot watson-conversation spring-el






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 14:16









data_henrik

9,14921030




9,14921030










asked Nov 13 '18 at 12:47









LAT94LAT94

8512




8512













  • Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

    – data_henrik
    Nov 13 '18 at 12:49











  • Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

    – LAT94
    Nov 13 '18 at 13:29













  • And it is only 1 topping. Not toppings. I edited the question and changed it.

    – LAT94
    Nov 13 '18 at 13:32













  • So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

    – LAT94
    Nov 13 '18 at 13:37











  • Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

    – data_henrik
    Nov 13 '18 at 13:52



















  • Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

    – data_henrik
    Nov 13 '18 at 12:49











  • Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

    – LAT94
    Nov 13 '18 at 13:29













  • And it is only 1 topping. Not toppings. I edited the question and changed it.

    – LAT94
    Nov 13 '18 at 13:32













  • So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

    – LAT94
    Nov 13 '18 at 13:37











  • Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

    – data_henrik
    Nov 13 '18 at 13:52

















Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

– data_henrik
Nov 13 '18 at 12:49





Do you mean inside a regex that is evaluated in a dialog node? Could you add more details of what you want to accomplish?

– data_henrik
Nov 13 '18 at 12:49













Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

– LAT94
Nov 13 '18 at 13:29







Yes, I am inside a dialog node.The string "toppings" will be assigned with the return of the extract

– LAT94
Nov 13 '18 at 13:29















And it is only 1 topping. Not toppings. I edited the question and changed it.

– LAT94
Nov 13 '18 at 13:32







And it is only 1 topping. Not toppings. I edited the question and changed it.

– LAT94
Nov 13 '18 at 13:32















So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

– LAT94
Nov 13 '18 at 13:37





So, if it matches a topping inside the entity @pizza-toppings, the value will be assigned to the string "topping".

– LAT94
Nov 13 '18 at 13:37













Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

– data_henrik
Nov 13 '18 at 13:52





Why do you want to do it? Maybe there is a different way... Could you first try to compose the pattern string, then use a variable with the string as parameter?

– data_henrik
Nov 13 '18 at 13:52












2 Answers
2






active

oldest

votes


















2














Without testing, after I noticed you were including the entity reference into the string. Try to do something like this:



"topping": "<? input.text.extract('(?i).+('+@pizza-toppings+')(?-i)', 1) ?>"





share|improve this answer


























  • There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

    – LAT94
    Nov 13 '18 at 19:43











  • updated it slightly, removed a single quote

    – data_henrik
    Nov 13 '18 at 20:01



















1














In general when you use a pattern entity, this will match the pattern and add the entity with the hardcoded value from the entity definition. But if you want the value that was matched, you should do as the documentation suggests (https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities) and add in the node response section a statement which creates a context variable and assigns the value of the pattern matched bit to that context variable:



{
"context" : {
"topping": "<? @pizza-toppings.literal ?>"
}
}


So if your pizza topping matches onion, your context variable topping will have the value "onion".



For example in this sample https://github.com/IBM/watson-assistant-app-connect there is a single entity @customerId which matches against a customer ID "[a-zA-Zd]{15,18}".



In the dialog node AppConnect in "Then check for:" it checks for the @customerId entity. In "Then set context:" it sets $id to "" and this is where the value that matched for @customerId is set in the context variable $id.






share|improve this answer
























  • Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

    – LAT94
    Nov 13 '18 at 20:09











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281349%2fregex-inside-entity-ibm-watson%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Without testing, after I noticed you were including the entity reference into the string. Try to do something like this:



"topping": "<? input.text.extract('(?i).+('+@pizza-toppings+')(?-i)', 1) ?>"





share|improve this answer


























  • There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

    – LAT94
    Nov 13 '18 at 19:43











  • updated it slightly, removed a single quote

    – data_henrik
    Nov 13 '18 at 20:01
















2














Without testing, after I noticed you were including the entity reference into the string. Try to do something like this:



"topping": "<? input.text.extract('(?i).+('+@pizza-toppings+')(?-i)', 1) ?>"





share|improve this answer


























  • There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

    – LAT94
    Nov 13 '18 at 19:43











  • updated it slightly, removed a single quote

    – data_henrik
    Nov 13 '18 at 20:01














2












2








2







Without testing, after I noticed you were including the entity reference into the string. Try to do something like this:



"topping": "<? input.text.extract('(?i).+('+@pizza-toppings+')(?-i)', 1) ?>"





share|improve this answer















Without testing, after I noticed you were including the entity reference into the string. Try to do something like this:



"topping": "<? input.text.extract('(?i).+('+@pizza-toppings+')(?-i)', 1) ?>"






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 20:01

























answered Nov 13 '18 at 14:16









data_henrikdata_henrik

9,14921030




9,14921030













  • There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

    – LAT94
    Nov 13 '18 at 19:43











  • updated it slightly, removed a single quote

    – data_henrik
    Nov 13 '18 at 20:01



















  • There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

    – LAT94
    Nov 13 '18 at 19:43











  • updated it slightly, removed a single quote

    – data_henrik
    Nov 13 '18 at 20:01

















There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

– LAT94
Nov 13 '18 at 19:43





There are something missing in the snippet you sent to me. over here: ('+@pizza-toppings'+'). I tried to change it properly but didnt not run succesfully.

– LAT94
Nov 13 '18 at 19:43













updated it slightly, removed a single quote

– data_henrik
Nov 13 '18 at 20:01





updated it slightly, removed a single quote

– data_henrik
Nov 13 '18 at 20:01













1














In general when you use a pattern entity, this will match the pattern and add the entity with the hardcoded value from the entity definition. But if you want the value that was matched, you should do as the documentation suggests (https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities) and add in the node response section a statement which creates a context variable and assigns the value of the pattern matched bit to that context variable:



{
"context" : {
"topping": "<? @pizza-toppings.literal ?>"
}
}


So if your pizza topping matches onion, your context variable topping will have the value "onion".



For example in this sample https://github.com/IBM/watson-assistant-app-connect there is a single entity @customerId which matches against a customer ID "[a-zA-Zd]{15,18}".



In the dialog node AppConnect in "Then check for:" it checks for the @customerId entity. In "Then set context:" it sets $id to "" and this is where the value that matched for @customerId is set in the context variable $id.






share|improve this answer
























  • Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

    – LAT94
    Nov 13 '18 at 20:09
















1














In general when you use a pattern entity, this will match the pattern and add the entity with the hardcoded value from the entity definition. But if you want the value that was matched, you should do as the documentation suggests (https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities) and add in the node response section a statement which creates a context variable and assigns the value of the pattern matched bit to that context variable:



{
"context" : {
"topping": "<? @pizza-toppings.literal ?>"
}
}


So if your pizza topping matches onion, your context variable topping will have the value "onion".



For example in this sample https://github.com/IBM/watson-assistant-app-connect there is a single entity @customerId which matches against a customer ID "[a-zA-Zd]{15,18}".



In the dialog node AppConnect in "Then check for:" it checks for the @customerId entity. In "Then set context:" it sets $id to "" and this is where the value that matched for @customerId is set in the context variable $id.






share|improve this answer
























  • Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

    – LAT94
    Nov 13 '18 at 20:09














1












1








1







In general when you use a pattern entity, this will match the pattern and add the entity with the hardcoded value from the entity definition. But if you want the value that was matched, you should do as the documentation suggests (https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities) and add in the node response section a statement which creates a context variable and assigns the value of the pattern matched bit to that context variable:



{
"context" : {
"topping": "<? @pizza-toppings.literal ?>"
}
}


So if your pizza topping matches onion, your context variable topping will have the value "onion".



For example in this sample https://github.com/IBM/watson-assistant-app-connect there is a single entity @customerId which matches against a customer ID "[a-zA-Zd]{15,18}".



In the dialog node AppConnect in "Then check for:" it checks for the @customerId entity. In "Then set context:" it sets $id to "" and this is where the value that matched for @customerId is set in the context variable $id.






share|improve this answer













In general when you use a pattern entity, this will match the pattern and add the entity with the hardcoded value from the entity definition. But if you want the value that was matched, you should do as the documentation suggests (https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities) and add in the node response section a statement which creates a context variable and assigns the value of the pattern matched bit to that context variable:



{
"context" : {
"topping": "<? @pizza-toppings.literal ?>"
}
}


So if your pizza topping matches onion, your context variable topping will have the value "onion".



For example in this sample https://github.com/IBM/watson-assistant-app-connect there is a single entity @customerId which matches against a customer ID "[a-zA-Zd]{15,18}".



In the dialog node AppConnect in "Then check for:" it checks for the @customerId entity. In "Then set context:" it sets $id to "" and this is where the value that matched for @customerId is set in the context variable $id.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 15:50









DSeagerDSeager

994




994













  • Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

    – LAT94
    Nov 13 '18 at 20:09



















  • Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

    – LAT94
    Nov 13 '18 at 20:09

















Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

– LAT94
Nov 13 '18 at 20:09





Yeah, that would solve it. This is how I managed to get it done. But, I think that the solution I'm asking for is not available yet, right? t

– LAT94
Nov 13 '18 at 20:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281349%2fregex-inside-entity-ibm-watson%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation