I'm working on the flight search agent using API.AI.
It bases on the pre-built Flight agent.
The agent recognizes the origin/destination location by either city name (e.g. London) or the airport code (e.g LHR).
The city is resolved to the following json:
{"city":"London"}
However, the airport code gets resolved to:
{"business-name":"London Heathrow Airport"}
The names are resolved using built-in entities (I tried #sys.location, #sys.geo-city and #sys.airport).
The search engine underneath recognizes both LHR and London, but it doesn't have a clue what "London Heathrow Airport" is.
According to the documentation the location can contain the following fields:
{
"country":"United States of America",
"admin-area":"New York",
"business-name":"Baxter Building",
"city":"New York",
"street-address":"42nd St",
"zip-code":"10036"
}
Since API.AI did recognize LHR as a London airport - is it possible to make it return more data about the location?
E.g. something like that:
{
"business-name":"London Heathrow Airport",
"city":"London"
}
Alternatively, is there a way to access the input parameter that was resolved to "business-name" (LHR in this case)?
You can get the 'original' value of the parameter before it is resolved using .original, so instead of a value of $parameter_name try $parameter_name.original
Related
If this question seems too trivial then please let me know in the comments, I will do further research on how to solve it.
I have a collection called products where I store details of a particular product from different retailers. The schema of a document looks like this -
{
"_id": "uuid of a product",
"created_at": "timestamp",
"offers": [{
"retailer_id": 123,
"product_url": "url - of -a - product.com",
"price": "1"
},
{
"retailer_id": 456,
"product_url": "url - of -a - product.com",
"price": "1"
}
]
}
_id of a product is system generated. Consider a product like 'iPhone X'. This will be a single document with URLs and prices from multiple retailers like Amazon, eBay, etc.
Now if a new URL comes into the system, I need to make a query if this URL already exists in our database. The obvious way to do this is to iterate every offer of every product document and see if the product_url field matches with the input URL. That would require loading up all the documents into the memory and iterate through the offers of every product one by one. Now my question arises -
Is there a simpler method to achieve this? Using pymongo?
Or my database schema needs to be changed since this basic check_if_product_url_exists() is too complex?
MongoDB provides searching within arrays using dot notation.
So your query would be:
db.collection.find({'offers.product_url': 'url - of -a - product.com'})
The same syntax works in MongoDB shell or pymongo.
I am attempting to subscribe to a DMAAP service and data can be filtered along the Highland Park Filter library, which is JSON based. What I need to do is filter on a value coming back, in this case, a state. We have a field called "deliveryState" which is the two-character state code. I would like to be able to filter on a series of states but for the life of me I haven't been able to do this, either I can filter on a single state, or on no states.
Ok well it looks like you pass in a JSON value as part of the header:
?filter={ "class":"Or", "filters": [ {"class":"Equals", "field":"State", "value":"FL" },{"class":"Equals", "field":"State", "value":"NY" },{"class":"Equals", "field":"State", "value":"CO" },{"class":"Equals", "field":"State", "value":"SC" }]}
You can't have multiple values but you can "stack" your filters. In this case, I'm doing it to only allow values with the "State" field equal to FL, NY, CO, or SC.
we are building a product on LUIS / Microsoft Bot framework and one of the doubt we have is Person Name understanding. The product is set to use by anyone by just signing up to our website. Which means any company who is signing up can have any number of employees with any name obviously.
What we understood is the user entity is not able to recognize all names. We have created a phrase list but as per we know there is a limit to phrase list (10K or even if its 100K) and names in the world can never have a limit. The other way we are thinking is to not train the entity with utterances. However if we have 100s of customers with 1000s of users each, the utterances will not be a good idea in that case.
I do not see any other way of handling this situation. Probably I am missing something here? Anyone faced similar problem and how it is handled?
The worst case would be to create a separate LUIS instance for each customer but that's really a big task to do only because we cant handle names.
As you might already know, a person's name could literally be anything: e.g. an animal, car, month, or color. So, there isn't any definitive way to identify something as a name. The closest you can come is via text analysis parts of speech and either taking a guess or comparing to an existing list. LUIS or any other NLP tool is unlikely to help with this. Here's one approach that might work out better. Try something like Microsoft's Text Analytics cognitive service, with a POST to the Key Phrases endpoint, like this:
https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases
and the body:
{
"documents": [
{
"language": "en-us",
"id": "myid",
"text": "Please book a flight for John Smith at 2:30pm on Wednesday."
}
]
}
That returns:
{
"languageDetection": {
"documents": [
{
"id": "e4263091-2d54-4ab7-b660-d2b393c4a889",
"detectedLanguages": [
{
"name": "English",
"iso6391Name": "en",
"score": 1.0
}
]
}
],
"errors": []
},
"keyPhrases": {
"documents": [
{
"id": "e4263091-2d54-4ab7-b660-d2b393c4a889",
"keyPhrases": [
"John Smith",
"flight"
]
}
],
"errors": []
},
"sentiment": {
"documents": [
{
"id": "e4263091-2d54-4ab7-b660-d2b393c4a889",
"score": 0.5
}
],
"errors": []
}
}
Notice that you get "John Smith" and "flight" back as key phrases. "flight" is definitely not a name, but "John Smith" might be, giving you a better idea of what the name is. Additionally, if you have a database of customer names, you can compare the value to a customer name, either exact or soundex, to increase your confidence in the name.
Sometimes, the services don't give you an 100% answer and you have to be creative with work-arounds. Please see the Text Analytics API docs for more info.
Have asked this question to few MS guys in my local region however it seems there is no way LUIS at moment can identify names.
Its not good as being NLP, it is not able to handle such things :(
I found wit.ai (best so far) in identifying names and IBM Watson is also good upto some level. Lets see how they turn out in future but for now I switched to https://wit.ai
By using LUIS and it's "Dialog Execution" under Action Binding, i'm expecting to be able to provide the required parameter (of an Action). (So that the Action can be triggered, or the Dialog can be continued.)
As far as i understand, once the Parameter has been asked to provide, we should provide it in the follow-up query call. For example:
First query:
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/...?subscription-key=...&q=what are the available items
Then, it asks me "Under what category?" (expecting me to provide the required parameter), like:
Then i provided it in the follow-up query:
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/...?subscription-key=...&q=electronics&contextId=d754ce3...
But then, seems like i still don't get the value accepted, and therefore it is still showing as null. Like this:
So the Parameter is not captured. So that Action can ever be triggered, yet. (Or i cannot reach to next Parameter, if there any)
Am i doing something wrong with it, or what seems to be the problem please?
(Below is the screenshot of that Intent with the "Action Parameters")
I have experienced this before. (In fact it still happens). Even in the Microsoft's Official LUIS API Example DEMOS, it still happens.
For example, in their Weather Bot there, just try something like:
You: What will the weather be tomorrow?
Bot: Where would you like the weather?
You: Singapore
Bot:
{
"name": "location",
"required": true,
"value": null
}
Then now try again, like:
You: What will the weather be tomorrow?
Bot: Where would you like the weather?
You: in Singapore
Bot:
{
"name": "location",
"required": true,
"value": [
{
"entity": "singapore",
"type": "builtin.geography.country"
}
]
}
Conclusion?
Prepositions! (in, at, on, by, under, ...) LUIS still doesn't understand the Entity input without the proper preposition provided, sometimes, in some cases.
I'm pretty sure this is the reason for your case. Try again with a preposition.
( This problem took me like 1~2 weeks to realise. Hope Microsoft can improve LUIS better in all this aspects asap. )
Basically when a foreign key becomes null (after it was set to a value) the relationship in core data is not reset.
Take as an example the following one-to-many relationship:
contact <<---> company (contact has one company, company has many contacts)
Which is mapped in both directions with the following methods from Restkit:
RKRelationshipMapping *contactCustomerRelationshipMapping = [RKRelationshipMapping relationshipMappingFromKeyPath:#"contacts" toKeyPath:#"hasContacts" withMapping:contactResponseMapping];
[customerResponseMapping addPropertyMapping:contactCustomerRelationshipMapping];
[contactResponseMapping addConnectionForRelationship:#"forCustomer" connectedBy:#{#"companyID" : #"identifier"}];
Then, assume that a contact is linked to a company both in core data and in the remote server, so the JSON returns:
company_id = 123
which is correctly mapped to the relationship in Core Data.
Although when the relationship is null-ed out the returning JSON in response of a GET contact returns:
'contact': {
....
address = "20 Wordworth Ave";
city = "<null>";
"company_id" = "<null>";
...
}
The company_id is then set correctly in the core data entity but the relationship connection mapper then does not delete the reference to the company with id 123 via the relationship. So it seems like Restkit is not applying the null value of the foreign key to the relationship in Core Data.
I have verified that this happens only when company_id is reset to null and not when the value is changed to another company_id.
Let me know if you have any suggestion on how to solve the issue.
(Right now I am thinking to implement the setter for company_id and manually reset the relationship when it's null)
Thanks a lot!
I am using the latest Restkit development branch (which is tagged as 0.21.0 - currently the lastest release is 0.20.3 but blake watters told me that the development branch has already been tagged but he did not have the time to prepare docs)
I am actually using cocoapods and included the latest dev release with the line:
pod 'RestKit', :head
Your workaround should be doable.
This could be classed as a bug in RestKit. As such you'd be better off raising it as an issue. You can also looking at adding it as a feature.
It's possible that you could use fetchRequestBlocks in order to provide RestKit with the information required to handle this, but this would result in the object being deleted which may not be what you want.