Condition with Watson conversation - watson-conversation

I have one Entity called Doctors with this value "Fabio" and Synonyms ("Cancer", "head", "legs"...)
So if my user say. "I want to take care of my head", can I idenfity that my user find one Doctor (Fabio) but with Synonymous and not return something like this:
"I found the doctor Fabio that take care of head"??
tks

To get the exact text that was matched by the entity, you can use .literal accessor that will return the exact text matched by the entity.
In your example that would be #Doctors.literal. For more information, see WCS documentation.

Related

Smalltalk, increment a value from a dictionary of counters

im working on Smalltalk, i have "tweets" collection, each tweet have "user" and i want to count the tweets by user in a dictionary.
So i have to add a counter in each key of the dictionary, and have to add keys for the first time i get the user.
I was thinking in this code for the add, i want to know if is human redeable and efficient or is there a better way to do it
tweetCountUserFrom: tweet in: aDictionary
| user |
user := tweet user.
aDictionary at: user ifAbsentPut: 0.
aDictionary at: user put: (result at: user) + 1
Your code is clear enough (even though it likely includes a mistake as the result variable should have been aDictionary instead). Anyway, the intention is clear and does (or is expected to do) the same a well-known object does, which is Bag. So, let's see how the code would have been with an instance of Bag (it is always a good idea to become increasingly familiar with the Collection hierarchy of Smalltalk). Here is how you could arrive at the same result
tweetCountUserFrom: tweet in: aBag
aBag add: tweet user
That's it!
When it is time for you to see how many tweets a user has authored, you will only need to evaluate
aBag occurrencesOf: user
Internally, aBag will hold a Dictionary and will maintain it the way you intended in your code. However, by using an existing object you will keep your code simpler, shorter and easier to read and maintain. You will also decrease the probability of failure as Bags have been kicking around for more than 40 years now, so there is little chance for them to decieve you.

How to capture the multiple values of one entity in IBM watson assistant after asking slot?

In my Watson Assistant app, I want to capture the multiple entities in the context and also have a slot to ask a question to user. Here is an example:
User: I want to fly from Toronto to Boston
And the Watson correctly detects:
intent: 'booking', #city:'Toronto', #city:'Boston'
Now I have a slot which asks for booking class:
Watson(Slot): Which class would you like?
User: Economy
At this point, the context only have first value for the #city entity i.e. Toronto. I understand from my googling that I can access #city[0] and #city1. And I tried to capture it in the context by doing the following but the value I'm getting is None.
How can I correctly capture both cities #city:Toronto, #city:Boston and at the same time entity #class:economy ?
The slots are smart - when there are multiple entities of the same type and more slots that match the entity of the same type then when a slot matches the first entity it will be "eaten" and not available for other slot - hence the next slot matching the same entity type will match any other entity of the same type. To achieve what you want to do simply define the slots in a following way (so both of them match simply the #city entity).
Revisiting this as there has been changes to Watson Assistant to make this easier.
1. Create two Entities. #fromCity and toCity.
2. Fill each entity with the same values. Names of locations.
3. Create your intent with questions like below.
I want to fly from Toronto to Boston
I have to get to Boston from Toronto ASAP.
I want to get a flight to New York
I'm in Texas and need to fly to San Diego
4. On the intents page select each city and flag them as either the #fromCity or #toCity. This creates contextual entities.
Now when it trains it will understand the entities in the context of the sentence. It will also understand locations you have not trained it on.
More detailed example here.
I'm replying here not only for you, but also for myself, since I have had this question a couple times. This is how I've handled it.
You can use SPEL, the expression language for watson to map all the literal values that match an entity and put them into a context variable like so inside the json configuration:
"context": {
"ReferenceNumber": "#ReferenceNumber.literal",
"ReferenceNumbersRunAdd": "<?$ReferenceNumbersMultiple.addAll(entities['ReferenceNumber'].![literal]) ?>"
}

How to access the first three values from a array of context variable in conditon node of watson conversation?

I have an array of context passed to the conversation from the application. It is something like:
result:[Apple,Orange,Mango,Grapes]
1st instance- I want the first value of array
if context.result.length==3
I should get [Apple,Orange,Mango] and to get the output in response, I will use $context.result[0],$context.result[1],$context.result[2] which will give me Apple, Orange, Mango.
if context.result.length==2
I should get [Apple,Orange] and to get the output in response $context.result[0],$context.result[1] which will give me Apple,Orange.
Can anyone tell me if this is the correct approach to access the context.
In watson conversation you can use some methods with arrays. One of them is join
If you passing in the context all items which in stock and you want to have output like We have X,Y,Z in stock, then you can create output in Watson like this:
We have <? context.results.join(', ') ?> in stock
It will print all string values, which you have in context.results.
You can find more information about available methods in Watson conversation here

Get peoples surnames or christian names from freebase?

Is it possible to get a users first name or surname from a freebase query?
For example, I have a person entry I have the id of, but I just want to extract their first name.
{
"id": "/en/paul_thomas_anderson",
"name" : null
}​
How would I modify this query, its something I've found nothing about by googling or searching here on S.O.? I know this kind of thing is possible in dbpedia for most people entries.
No, it's not possible directly. The name is stored as a single unit. There are topics for given names and surnames (e.g. http://www.freebase.com/view/base/givennames/given_name), so you could split the name and see which list(s) it appears in, but that's indirect and doesn't tell you about the specific person you are querying.

How to query individuals in DL Manchester OWL Syntax?

I know this sounds like a very stupid question, but I've been trying to figure this out and I can't find anything on this, though it seems obvious that this should be doable.
I'm developing something that queries an OWL file through its API using the Manchester OWL Syntax and a HermiT reasoner. I alternatively also run queries on the DL Query tab in Protege 4 to check my query results on that file. The file is basically the Friend Of A Friend (FOAF) ontology with added data instances.
The problem: I can't find a way to query an instance by its unique identifier.
It's supposed to be the URI so e.g. for a Person object with URI http://xmlns.com/foaf/0.1/Andrew_Kuchling, I tried to run the following queries:
Person and URI value "http://xmlns.com/foaf/0.1/Andrew_Kuchling"
Person value "http://xmlns.com/foaf/0.1/Andrew_Kuchling"
Person and URI value "Andrew_Kuchling"
Person that "Andrew_Kuchling"
none of these work. (The URI is constructed by prefixing http://xmlns.com/foaf/0.1/ to whatever string you enter and URI is not actually identified in the ontology as a property).
In FOAF, mbox_sha1sum is the sha1sum of a mailbox. Mailboxes are uniquely connected to individuals. So I tried the following query:
Person and mbox_sha1sum value "mbox_sha1sum-property-value-here"
However, it doesn't even execute this query because it feels the query is incorrect. The mbox_sha1sum value is the same that I've added for this Person. It exists in Individuals.
It does execute this query:
Person and firstName value "Andrew"
All data properties are not specialised data types. Treated as literals by default.
I really don't know what I'm doing wrong. Can someone please please help?
I know this question has been posted more than a year ago, but I recently asked me the same question and found the following solution:
Just put the name of the individual/member you want to query for in curly brackets:
{MyIndividualEntityName}
This way you can even query for more than one individual at a time:
{IndividualName1,IndividualName2}
Please note that these queries form class expressions of so called enumarated classes. This means, that the result of this query will not simply be a list of all super or sub classes of all the individuals you have named in your query. Instead it refers to an anonymous class that consists of exactly the individuals you have listed.
An anonymous class is a class that isn't available from outside of your ontology, because there is no referrable owl entity for this class (no IRI to refer to).
You can find more information on the OWL Manchester Syntax in the offcial W3C specification.

Resources