How to get dates from user input in Watson's conversation API? - ibm-cloud

Does anybody already figured out how to get dates that were inputed by the User in the Watson's Conversation API?
In the Dialog API, we could use the standard entities, like DATE_TIME_RANGE and FROM_DATE, but I wont find any way that doesn't end adding a new custom entity by myself.
I want to create a verification that was this way on Dialog API:
<input>
<grammar>
<item>$ (IATA)={var-from} * (IATA)={var-to} * (DATE_TIME_RANGE)={var-date1} * (DATE_TIME_RANGE)={var-date2}</item>
<item>$ (IATA)={var-from} * (IATA)={var-to} * (DATE_TIME_RANGE)={var-date1} * (DATE_TIME_RANGE)={var-date2} *</item>
<item>(IATA)={var-from} * (IATA)={var-to} * (DATE_TIME_RANGE)={var-date1} * (DATE_TIME_RANGE)={var-date2} *</item>
<item>(IATA)={var-from} * (IATA)={var-to} * (DATE_TIME_RANGE)={var-date1} * (DATE_TIME_RANGE)={var-date2}</item>
</grammar>
<output id="itinerario">
<action varName="var-from" operator="SET_TO">{var-from.value:main}</action>
<action varName="var-to" operator="SET_TO">{var-to.value:main}</action>
<action varName="var-date1" operator="SET_TO">{var-date1.value:FROM_DATE}</action>
<action varName="var-date2" operator="SET_TO">{var-date2.value:FROM_DATE}</action>
<prompt>
<item>{var-from} {var-to} {var-date1} {var-date2}</item>
</prompt>
</outputt>

The Conversation API does not have that feature yet. In the short term, one work around might be to extract dates in the client application using a regex, and passing them to the API as a context variable.

You can use a condition to access a special node with
input.text.matches( '[0-9]+' )
(add any regex you want inside)
http://www.ibm.com/watson/developercloud/doc/conversation/expression-language.html
To extract the value in the node you want to extract the value. Inside the context variable add something like
"context": {
"number_extract": "<? input.text.extract('[\\d]+',0) ?>"
}
(you can put any regex you want inside the extract)
That is the best you can do currently with watson conversation. So you have to make your own regex to parse the date.
I personally use another solution which is to make a custom parser that comes before watson.
This guy details how to do it using alchemyAPI
https://kozhayasite.wordpress.com/2016/08/27/watson-conversation-with-alchemy-entity-extraction/

Related

RegEx for google event

Hello I would like help writing a regex that captures all urls with the word confirmation in it.
Ex:
https://example.com/this-is-a-confirmation
https://example.com/confirmation
https://example.com/folder/this-is-confirmation
I am trying to set up a Goal that captures all visits to any confirmation page on the website as by visiting that page you most likely filled out a form to download an asset
Thanks!
So, basically all links end with confirmation?
Then you could just use a very stupid and simple regex like:
confirmation$
If you only want the URL to contain confirmation:
confirmation
is already enough (Demo). That's basically the same as if you were using String.endsWith(str) and String.contains(str).
Depending on the way you're evaluating this, you may need to allow chars before the search term to produce a full match (not only a partial match):
.*confirmation
or
.*confirmation.*
if you want to allow any text after the search term.

Recognize undefined Entities in Watson Conversation

Please, I wanted to know if it is possible to catch different entities on Watson conversation without defining their values.
For example, I am working on a Mobile up for room booking in my company and I can't define all the room's names so I want that my Bot recognize the name just according to the used pattern for example
"Book #room for tomorrow"
and whatever I put in place of #room it takes it as a room name.
thank you
Its now available check out https://console.bluemix.net/docs/services/conversation/entities.html#pattern-entities
A pattern must be entered as a regular expression in the field.
For instance internationalPhone: ^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$, e.g., +44 1962 815000
EDIT: The solution below still works but right now the pattern entities as discussed by Dudi are more systematic solution. Leaving this here for legacy reasons.
Right now the regexp support inside Watson Conversation Service is probably the est bet.
For your particular example, you can use the following expression inside the dialog node condition:
input.text.matches('^[bB]ook[^\w]+(\w+).+ (tomorrow|today)$')
and inside that node you can add the following regexp to node context to extract the second word (or the word after "Book") to a variable:
"room" : "<? input.text.extract('^[bB]ook[^\\w]+(\\w+).+ (tomorrow|today)$',1) ?>"
(note that in context unlike in conditions you need to actually escape \ with another \)
This will match inputs such as "book bathroom for today" or "book r101 for tomorrow".
A good place where you can try your regexp expressions is https://regex101.com/

Finding node/asset using Name LIKE in CQ5?

I want to find an asset under a particular path and that has a name like '%xyz%'.
I referred to this page "9 JCR Queries every AEM developer should know"
Please refer to point number 7. It clearly states that I can use a combination of Name() Like '%xyz%'
APPROACH 1
So I fired a query
String jcrQuery = "SELECT * FROM [dam:Asset] WHERE NAME() LIKE '%"+conditionalSelectString+"%'";
And I go javax.jcr.UnsupportedRepositoryOperationException.
Approach 2
I found this amazing page with CQ5 that helps you construct JCR-SQL2 queries
http://localhost:4502/crx/explorer/ui/search.jsp
So with the help of this I generated the query
select * from dam:Asset where jcr:path like '/content/dam/pdf/%' and contains(*, '%Slide%')
This works fine when I fire this query on the search.jsp page of CQ5. But when I try to fire this query in a class within my bundle I get an Exception
So how do I fire a query that searches a DAM Asset by name using like and not exact name. I know that NAME can be used to find node with exact match.
How do I use name and Like together ?

Adding messages to grib2 files

Context
I would like to add additional fields to a grib2 file, which are a function of existing fields.
e.g.: I would like to add a wind-chill message, given by the formula:
35.74 + 0.6215 * T -35.75 * V^0.16 + 0.4275 * T * V^0.16
where T and V are the temperature and wind speed field that appears in the original grib2 file.
Question
I have searched for documentation on the subject, but failed to find any reference :(
Is there any easy way doing that (preferably using bash, other interfaces are also relevant...)?
Thanks :)
Multi-field messages are generally considered a bad idea. Regardless, to edit a message, you can use grib_api or wgrib.

Quartz Get trigger description

Is there a function in the API that returns language description of a trigger? For example,
cron trigger expression="0 0 0 L * ?"
Language I'm looking for is "Fires at 0:00:00 every last day of the month" (Or something like that)
I want to use this to give feed back to user of what schedules are created. I'm hoping I don't have to parse the expression myself. I search Google but have came empty, maybe I'm not using the right words to search for.
I'm using the .NET version. But if there is a java function out there I could probably figure out how to port it.
Thanks in advance
There is a question similiar to this here I think your going to have to write something yourself for this.