Luis not working due to its maintance (just in spanish culture)? - azure-language-understanding

our staging application with spanish culture was not working yesterday, and today our production application is also not working. The problem is that some intents are not returning any entities. And in the web of luis is annunced that "We are performing system wide maintenance. Some apps may experience temporary unavailability. Thank you for your patience."
We want to know if it is a normal case and how long will it last. Our bot is in the production, which means it is a product. We ara caring about our product, and do not want interrupt its service with any accident.
Also we want to know is there any technical way to avoiding cases like this.
Detail of the error, when call version english https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/xxxx?subscription-key=xxxxxxxxxx&verbose=true&timezoneOffset=0&q=malaga
{
"query": "malaga",
"topScoringIntent": {
"intent": "sports_football_team_global",
"score": 0.989564657
},
"intents": [
{
"intent": "sports_football_team_global",
"score": 0.989564657
},
{
"intent": "sports_user_follow",
"score": 0.256285429
},
{
"intent": "sports_user_unfollow",
"score": 0.0624738075
},
{
"intent": "sports_football_team_information",
"score": 0.0452761
},
{
"intent": "sports_user_notification_level",
"score": 0.0250913966
},
{
"intent": "OPTA_Cancelar",
"score": 0.01700071
},
{
"intent": "None",
"score": 0.0113976067
},
{
"intent": "sports_user_enable_notification",
"score": 0.01062314
},
{
"intent": "sports_user_emotion_hate",
"score": 0.008717464
},
{
"intent": "sports_competition_classification",
"score": 0.006895263
},
{
"intent": "sports_user_welcome",
"score": 0.003931297
},
{
"intent": "root_change_user_info",
"score": 0.002939801
},
{
"intent": "sports_user_disable_notification",
"score": 0.00284402771
},
{
"intent": "sports_team_last_match",
"score": 0.002589234
},
{
"intent": "sports_next_match_bytime",
"score": 0.00225439551
},
{
"intent": "sports_showmore_team",
"score": 0.00210961024
},
{
"intent": "sports_competition_next_round",
"score": 0.00183723459
},
{
"intent": "sports_team_next_match",
"score": 0.0017626757
},
{
"intent": "sports_competition_last_round",
"score": 0.001716528
},
{
"intent": "sports_user_emotion_gol",
"score": 0.001380223
},
{
"intent": "sports_user_unfollow_all",
"score": 0.00104989111
},
{
"intent": "sports_user_current_match",
"score": 0.0008975425
},
{
"intent": "sports_user_last_match",
"score": 0.0005386151
},
{
"intent": "sports_user_show_follow",
"score": 0.0004062014
},
{
"intent": "sports_team_current_match",
"score": 0.000116936135
},
{
"intent": "sports_user_next_match",
"score": 1.70625044E-05
}
],
"entities": [
{
"entity": "malaga",
"type": "football_team",
"startIndex": 0,
"endIndex": 5,
"resolution": {
"values": [
"Málaga"
]
}
}
]
And version spanish https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/xxxxxx?subscription-key=xxxx&verbose=true&timezoneOffset=0&q=malaga
{
"query": "malaga",
"topScoringIntent": {
"intent": "sports_football_team_global",
"score": 0.9602209
},
"intents": [
{
"intent": "sports_football_team_global",
"score": 0.9602209
},
{
"intent": "sports_user_disable_notification",
"score": 0.130784482
},
{
"intent": "sports_team_last_match",
"score": 0.09194096
},
{
"intent": "sports_user_notification_level",
"score": 0.08853955
},
{
"intent": "sports_team_next_match",
"score": 0.0597797334
},
{
"intent": "sports_user_unfollow",
"score": 0.0510462932
},
{
"intent": "sports_football_team_information",
"score": 0.0401076
},
{
"intent": "sports_competition_classification",
"score": 0.03524222
},
{
"intent": "sports_user_follow",
"score": 0.02526744
},
{
"intent": "sports_next_match_bytime",
"score": 0.0111262156
},
{
"intent": "sports_user_enable_notification",
"score": 0.009637802
},
{
"intent": "sports_team_current_match",
"score": 0.00436334638
},
{
"intent": "sports_user_emotion_hate",
"score": 0.004245238
},
{
"intent": "None",
"score": 0.00323706563
},
{
"intent": "sports_user_show_follow",
"score": 0.00276356842
},
{
"intent": "sports_showmore_team",
"score": 0.00234427629
},
{
"intent": "sports_user_last_match",
"score": 0.00233005267
},
{
"intent": "sports_user_welcome",
"score": 0.00157872075
},
{
"intent": "sports_competition_next_round",
"score": 0.00108685123
},
{
"intent": "sports_user_emotion_gol",
"score": 0.000902815256
},
{
"intent": "sports_competition_last_round",
"score": 0.000205698016
},
{
"intent": "sports_user_current_match",
"score": 0.000102570972
},
{
"intent": "sports_user_next_match",
"score": 3.606828E-05
},
{
"intent": "sports_user_unfollow_all",
"score": 3.43515676E-05
}
],
"entities": []
}

It was a temporary issue which has been resolved. Please contact Luisuservoice#microsoft.com if any issues.

Related

LUISGen throws exception when generating cs classes from json

I am trying to generate cs calsses from json which I exported from luis.ai for one of my luis App.
But when I run the command LUISGen myLuisApp.json -cs myClassName I get below error on commandline
Snapshot of exception
below is the json I got from luis.ai
{
"luis_schema_version": "7.0.0",
"versionId": "0.1",
"name": "myBotName",
"desc": "",
"culture": "en-us",
"tokenizerVersion": "1.0.0",
"patternAnyEntities": [],
"regex_entities": [],
"phraselists": [],
"regex_features": [],
"patterns": [],
"intents": [
{
"name": "ApproveAllTasksOnMe"
},
{
"name": "ApproveTask"
},
{
"name": "GetApprovedTasks"
},
{
"name": "GetCompletedTasks"
},
{
"name": "GetLastApprovedTask"
},
{
"name": "GetLastNTasks"
},
{
"name": "GetLastRejectedTask"
},
{
"name": "GetRejectedTasks"
},
{
"name": "GetTaskDetails"
},
{
"name": "GetTasks"
},
{
"name": "GetTotalPendingTasks"
},
{
"name": "GetTotalTasksCompleted"
},
{
"name": "None"
},
{
"name": "RejectAllTasksOnMe"
},
{
"name": "RejectTask"
}
],
"entities": [
{
"name": "Application",
"children": [],
"roles": [],
"features": []
},
{
"name": "Email",
"children": [
{
"name": "AssignedTo",
"children": [],
"features": []
},
{
"name": "InitiatedBy",
"children": [],
"features": []
}
],
"roles": [],
"features": []
},
{
"name": "Name",
"children": [
{
"name": "AssignedTo",
"children": [],
"features": []
},
{
"name": "InitiatedBy",
"children": [],
"features": []
}
],
"roles": [],
"features": []
},
{
"name": "Status",
"children": [],
"roles": [],
"features": []
},
{
"name": "Workspace",
"children": [],
"roles": [],
"features": []
}
],
"hierarchicals": [],
"composites": [],
"closedLists": [],
"prebuiltEntities": [],
"utterances": [
{
"text": "all approved tasks",
"intent": "GetApprovedTasks",
"entities": []
},
{
"text": "all tasks",
"intent": "GetTasks",
"entities": []
},
{
"text": "approve all",
"intent": "ApproveAllTasksOnMe",
"entities": []
},
{
"text": "approve task",
"intent": "ApproveTask",
"entities": []
},
{
"text": "get all tasks i approved",
"intent": "GetApprovedTasks",
"entities": []
},
{
"text": "get all tasks i rejected",
"intent": "GetRejectedTasks",
"entities": []
},
{
"text": "get last 5 tasks",
"intent": "GetLastNTasks",
"entities": []
},
{
"text": "get last approved task",
"intent": "GetLastApprovedTask",
"entities": []
},
{
"text": "get last rejected task",
"intent": "GetLastRejectedTask",
"entities": []
},
{
"text": "get task details",
"intent": "GetTaskDetails",
"entities": []
},
{
"text": "get tasks pending on me",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 21,
"endPos": 22,
"children": [
{
"entity": "AssignedTo",
"startPos": 21,
"endPos": 22,
"children": []
}
]
}
]
},
{
"text": "how man tasks are pending on me",
"intent": "GetTotalPendingTasks",
"entities": []
},
{
"text": "how many tasks are assigned to me",
"intent": "GetTotalPendingTasks",
"entities": []
},
{
"text": "how many tasks i closed today",
"intent": "GetTotalTasksCompleted",
"entities": []
},
{
"text": "how many tasks were completed by me",
"intent": "GetTotalTasksCompleted",
"entities": []
},
{
"text": "last 7 tasks",
"intent": "GetLastNTasks",
"entities": []
},
{
"text": "last approved task",
"intent": "GetLastApprovedTask",
"entities": []
},
{
"text": "last task i approved",
"intent": "GetLastApprovedTask",
"entities": []
},
{
"text": "last task i rejected",
"intent": "GetLastRejectedTask",
"entities": []
},
{
"text": "list my tasks",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 5,
"endPos": 6,
"children": [
{
"entity": "AssignedTo",
"startPos": 5,
"endPos": 6,
"children": []
}
]
}
]
},
{
"text": "number of tasks closed",
"intent": "GetTotalTasksCompleted",
"entities": []
},
{
"text": "reject all",
"intent": "RejectAllTasksOnMe",
"entities": []
},
{
"text": "reject all my tasks",
"intent": "RejectAllTasksOnMe",
"entities": []
},
{
"text": "reject all tasks",
"intent": "RejectAllTasksOnMe",
"entities": []
},
{
"text": "reject this task",
"intent": "RejectTask",
"entities": []
},
{
"text": "show all completed tasks",
"intent": "GetCompletedTasks",
"entities": []
},
{
"text": "show all done tasks",
"intent": "GetCompletedTasks",
"entities": []
},
{
"text": "show all tasks approved by me",
"intent": "GetApprovedTasks",
"entities": []
},
{
"text": "show done tasks",
"intent": "GetCompletedTasks",
"entities": []
},
{
"text": "show how many tasks are closed",
"intent": "GetTotalTasksCompleted",
"entities": []
},
{
"text": "show last 2 tasks",
"intent": "GetLastNTasks",
"entities": []
},
{
"text": "show my tasks",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 5,
"endPos": 6,
"children": [
{
"entity": "AssignedTo",
"startPos": 5,
"endPos": 6,
"children": []
}
]
}
]
},
{
"text": "show tasks i took action on",
"intent": "GetCompletedTasks",
"entities": []
},
{
"text": "show tasks pending on me",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 22,
"endPos": 23,
"children": [
{
"entity": "AssignedTo",
"startPos": 22,
"endPos": 23,
"children": []
}
]
}
]
},
{
"text": "tasks assigned to me",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 18,
"endPos": 19,
"children": [
{
"entity": "AssignedTo",
"startPos": 18,
"endPos": 19,
"children": []
}
]
}
]
},
{
"text": "tasks i rejected",
"intent": "GetRejectedTasks",
"entities": []
},
{
"text": "tasks pending on me",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 17,
"endPos": 18,
"children": [
{
"entity": "AssignedTo",
"startPos": 17,
"endPos": 18,
"children": []
}
]
}
]
},
{
"text": "tasks rejected by me",
"intent": "GetRejectedTasks",
"entities": []
},
{
"text": "tasks waiting for my attention",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 18,
"endPos": 19,
"children": [
{
"entity": "AssignedTo",
"startPos": 18,
"endPos": 19,
"children": []
}
]
}
]
},
{
"text": "tasks waiting on me",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 17,
"endPos": 18,
"children": [
{
"entity": "AssignedTo",
"startPos": 17,
"endPos": 18,
"children": []
}
]
}
]
},
{
"text": "today's priorities",
"intent": "GetTasks",
"entities": []
},
{
"text": "total tasks for me",
"intent": "GetTotalPendingTasks",
"entities": []
},
{
"text": "what are my tasks for the day",
"intent": "GetTasks",
"entities": [
{
"entity": "Name",
"startPos": 9,
"endPos": 10,
"children": [
{
"entity": "AssignedTo",
"startPos": 9,
"endPos": 10,
"children": []
}
]
}
]
}
],
"settings": []
}
when run the same command with of the json from examples it generated the classes without any error.
Can anybody help me understand what I might be doing wrong or if I am missing something?
I have installed LUISGen with below comand dotnet tool install --global LUISGen --version 2.2.0
Normally I would say 'make sure you're using the most up-to-date version of the tool', but
LUISGen is deprecated (legacy tool). The new botframework-cli was designed to replace legacy standalone tools. I don't think you're missing anything, but it hasn't been updated in almost a year.
The botframework-cli has a similar command: bf luis:generate:cs meant to generate CS classes on LUIS models.
https://github.com/microsoft/botframework-cli/blob/main/packages/luis/README.md#bf-luisgeneratecs

Rasa nlu parse request giving wrong intent result

Rasa NLU version (e.g. 0.7.3): 0.10.0a6
Used backend / pipeline (mitie, spacy_sklearn, ...): ["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy","ner_crf", "ner_synonyms", "intent_classifier_sklearn","ner_spacy"]
Operating system (windows, osx, ...): Windows server 2012 R2
Issue: I have installed Rasa nlu 0.10.0a6 version. My confi_spacy file looks like.
{
"project":"Project",
"pipeline" : ["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy","ner_crf", "ner_synonyms", "intent_classifier_sklearn","ner_spacy"],
"path" : "./projects",
"cors_origins":["*"],
"data" : "./data/examples/rasa/People.json"
}
and my data file looks like.
{
"rasa_nlu_data": {
"regex_features": [
{
"name": "zipcode",
"pattern": "[0-9]{5}"
}
],
"entity_synonyms": [
{
"value": "chinese",
"synonyms": ["Chinese", "Chines", "chines"]
},
{
"value": "vegetarian",
"synonyms": ["veggie", "vegg"]
}
],
"common_examples": [
{
"text": "hey",
"intent": "greet",
"entities": []
},
{
"text": "howdy",
"intent": "greet",
"entities": []
},
{
"text": "hey there",
"intent": "greet",
"entities": []
},
{
"text": "hello",
"intent": "greet",
"entities": []
},
{
"text": "hi",
"intent": "greet",
"entities": []
},
{
"text": "good morning",
"intent": "greet",
"entities": []
},
{
"text": "good evening",
"intent": "greet",
"entities": []
},
{
"text": "dear sir",
"intent": "greet",
"entities": []
},
{
"text": "yes",
"intent": "affirm",
"entities": []
},
{
"text": "yep",
"intent": "affirm",
"entities": []
},
{
"text": "yeah",
"intent": "affirm",
"entities": []
},
{
"text": "indeed",
"intent": "affirm",
"entities": []
},
{
"text": "that's right",
"intent": "affirm",
"entities": []
},
{
"text": "ok",
"intent": "affirm",
"entities": []
},
{
"text": "great",
"intent": "affirm",
"entities": []
},
{
"text": "right, thank you",
"intent": "affirm",
"entities": []
},
{
"text": "correct",
"intent": "affirm",
"entities": []
},
{
"text": "great choice",
"intent": "affirm",
"entities": []
},
{
"text": "sounds really good",
"intent": "affirm",
"entities": []
},
{
"text": "i'm looking for a place to eat",
"intent": "restaurant_search",
"entities": []
},
{
"text": "I want to grab lunch",
"intent": "restaurant_search",
"entities": []
},
{
"text": "I am searching for a dinner spot",
"intent": "restaurant_search",
"entities": []
},
{
"text": "i'm looking for a place in the north of town",
"intent": "restaurant_search",
"entities": [
{
"start": 31,
"end": 36,
"value": "north",
"entity": "location"
}
]
},
{
"text": "show me chinese restaurants",
"intent": "restaurant_search",
"entities": [
{
"start": 8,
"end": 15,
"value": "chinese",
"entity": "cuisine"
}
]
},
{
"text": "show me chines restaurants",
"intent": "restaurant_search",
"entities": [
{
"start": 8,
"end": 14,
"value": "chinese",
"entity": "cuisine"
}
]
},
{
"text": "show me a mexican place in the centre",
"intent": "restaurant_search",
"entities": [
{
"start": 31,
"end": 37,
"value": "centre",
"entity": "location"
},
{
"start": 10,
"end": 17,
"value": "mexican",
"entity": "cuisine"
}
]
},
{
"text": "i am looking for an indian spot called olaolaolaolaolaola",
"intent": "restaurant_search",
"entities": [
{
"start": 20,
"end": 26,
"value": "indian",
"entity": "cuisine"
}
]
}, {
"text": "search for restaurants",
"intent": "restaurant_search",
"entities": []
},
{
"text": "anywhere in the west",
"intent": "restaurant_search",
"entities": [
{
"start": 16,
"end": 20,
"value": "west",
"entity": "location"
}
]
},
{
"text": "anywhere near 18328",
"intent": "restaurant_search",
"entities": [
{
"start": 14,
"end": 19,
"value": "18328",
"entity": "location"
}
]
},
{
"text": "I am looking for asian fusion food",
"intent": "restaurant_search",
"entities": [
{
"start": 17,
"end": 29,
"value": "asian fusion",
"entity": "cuisine"
}
]
},
{
"text": "I am looking a restaurant in 29432",
"intent": "restaurant_search",
"entities": [
{
"start": 29,
"end": 34,
"value": "29432",
"entity": "location"
}
]
},
{
"text": "I am looking for mexican indian fusion",
"intent": "restaurant_search",
"entities": [
{
"start": 17,
"end": 38,
"value": "mexican indian fusion",
"entity": "cuisine"
}
]
},
{
"text": "central indian restaurant",
"intent": "restaurant_search",
"entities": [
{
"start": 0,
"end": 7,
"value": "central",
"entity": "location"
},
{
"start": 8,
"end": 14,
"value": "indian",
"entity": "cuisine"
}
]
},
{
"text": "bye",
"intent": "goodbye",
"entities": []
},
{
"text": "goodbye",
"intent": "goodbye",
"entities": []
},
{
"text": "good bye",
"intent": "goodbye",
"entities": []
},
{
"text": "stop",
"intent": "goodbye",
"entities": []
},
{
"text": "end",
"intent": "goodbye",
"entities": []
},
{
"text": "farewell",
"intent": "goodbye",
"entities": []
},
{
"text": "Bye bye",
"intent": "goodbye",
"entities": []
},
{
"text": "have a good one",
"intent": "goodbye",
"entities": []
}
]
}
}
Using above config and json data I have trained Rasa using below HTTP end point
/train?project=Project
After training data there in one Project folder created with trained data.
And I started Rasa server with below command.
python -m rasa_nlu.server -c config_spacy.json
Now server started with port 5000.
When I can execute '/parse?q=hello&project=Project' parse end point am getting below response.
{
"intent": {
"name": "greet",
"confidence": 0.6409561289105246
},
"entities": [],
"intent_ranking": [
{
"name": "greet",
"confidence": 0.6409561289105246
},
{
"name": "goodbye",
"confidence": 0.16788352870824252
},
{
"name": "restaurant_search",
"confidence": 0.10908268742176423
},
{
"name": "affirm",
"confidence": 0.08207765495946878
}
],
"text": "hello"
}
When I can execute '/parse?q=Great choice&project=Project' parse end point am getting below response.
{
"intent": {
"name": "affirm",
"confidence": 0.7718580601897227
},
"entities": [],
"intent_ranking": [
{
"name": "affirm",
"confidence": 0.7718580601897227
},
{
"name": "goodbye",
"confidence": 0.11611828257295627
},
{
"name": "greet",
"confidence": 0.07060567364272623
},
{
"name": "restaurant_search",
"confidence": 0.04141798359459499
}
],
"text": "Great choice"
}
When I can execute '/parse?q=Great choice&Project=Project' parse end point am getting below response.
{
"intent": {
"name": "None",
"confidence": 1
},
"entities": [],
"text": "Great choice"
}
When I can execute "/parse?q=Book a cab&project=Project" parse end point am getting below response.
{
"intent": {
"name": "goodbye",
"confidence": 0.40930529216955336
},
"entities": [],
"intent_ranking": [
{
"name": "goodbye",
"confidence": 0.40930529216955336
},
{
"name": "restaurant_search",
"confidence": 0.31818118919270977
},
{
"name": "greet",
"confidence": 0.20524111006007764
},
{
"name": "affirm",
"confidence": 0.06727240857765926
}
],
"text": "Book a cab"
}
In this way for each request it is responding with proper results some times and sometime not. If you can observe Parse_reponce2.txt and Parse_reponce3.txt in these both the response I just changed from small 'p' to capital 'P' in place 'Project' because of this change, i got different results for each request.
And in trained data there is no 'Book a cab' text or any related intent to it. But when I send parse using this text I am not getting None intent, it is returning intent result. for any parse request with any random am not getting None intent.
Is this my training issue or what went wrong in it.
Please let me know how can I get proper intent results as well as entities result.
Content of configuration file (if used & relevant):
{
"project":"Project",
"pipeline" : ["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy","ner_crf", "ner_synonyms", "intent_classifier_sklearn","ner_spacy"],
"path" : "./projects",
"cors_origins":["*"],
"data" : "./data/examples/rasa/People.json"
}
URL parameters are case sensitive, which is why the two great choice examples had different outputs. In the 2nd case Rasa wasn't finding a project/model to parse against.
Rasa NLU will always return a matched intent. So in the last example you can see that it returned an intent, but the confidence was low. Handling this is what would be called a fallback or out of scope. The two primary ways discussed for handling fallback is to implement logic that takes over when the confidence falls below a certain threshold or to train an actual fallback intent that has all the non-intent examples you want to catch.
I had the same issue with using Rasa NLU where I had around 120 examples for 5 different intents, and 5-7 entities as well. Here, you seem to have used the spacy-sklearn pipeline.
spaCy typically requires more data to train and detect intents and (more so) entities. The docs say 500-1000 examples would be considered "decent and good" for the library.
In my case I changed my pipeline to MITIE-sklearn and I got a decent model trained with only 80 examples and same number of intents as before.
Also spaCy tends to be faster as you would have noted, but MITIE does take around 6 minutes for an 80-example model.

When connecting to LUIS, what does the "forceset" parameter do

In my LUIS app I have an intent called GetWeather requiring a Location to be set.
When connecting to the app using the query
What is the weather in london
it correctly returns
{
"query": "what is the weather in london",
"topScoringIntent": {
"intent": "GetWeather",
"score": 0.999875546,
"actions": [
{
"triggered": true,
"name": "GetWeather",
"parameters": [
{
"name": "Location",
"type": "Location",
"required": true,
"value": [
{
"entity": "london",
"type": "Location",
"resolution": {}
}
]
}
]
}
]
},
"entities": [
{
"entity": "london",
"type": "Location",
"startIndex": 23,
"endIndex": 28,
"score": 0.832388461,
"resolution": {}
}
],
"dialog": {
"contextId": "e1df6c2d-e691-4fc6-89f2-3ee2ef519724",
"status": "Finished"
}
}
If I instead use the query
What is the weather
It returns the following expected result.
{
"query": "what is the weather",
"topScoringIntent": {
"intent": "GetWeather",
"score": 1.0,
"actions": [
{
"triggered": false,
"name": "GetWeather",
"parameters": [
{
"name": "Location",
"type": "Location",
"required": true,
"value": null
}
]
}
]
},
"entities": [],
"dialog": {
"prompt": "Where",
"parameterName": "Location",
"parameterType": "Location",
"contextId": "3b0725f4-7d6f-43fd-ab6e-02fc11c3eed1",
"status": "Question"
}
}
I thought that using the contextID together with the forceSet parameter in my next call would set the parameter Location to whatever I send as the query. The conection string I use is this:
https://api.projectoxford.ai/luis/v2.0/apps/{APP_ID}?subscription-key={SUBSCRIPTION_KEY}&q=london&contextid=3b0725f4-7d6f-43fd-ab6e-02fc11c3eed1&forceset=Location
Instead I get the following response back:
{
"query": "london",
"topScoringIntent": {
"intent": "GetWeather",
"score": 1.0,
"actions": [
{
"triggered": false,
"name": "GetWeather",
"parameters": [
{
"name": "Location",
"type": "Location",
"required": true,
"value": null
}
]
}
]
},
"entities": [],
"dialog": {
"prompt": "Where",
"parameterName": "Location",
"parameterType": "Location",
"contextId": "3b0725f4-7d6f-43fd-ab6e-02fc11c3eed1",
"status": "Question"
}
}
I had expected to get something like my first response back.
Am I doing something wrong or just misunderstanding what the forceSet parameter is supposed to do?

how to improve elasticsearch suggest results

I am using the elasticsearch _suggest endpoint to suggest spelling corrections ("did you mean"). One example that has come up is
"gardeing with muclh"
My search request is:
{
"phrase": {
"phrase": {
"field": "summary",
"max_errors": 0.5,
"analyzer": "standard",
"highlight": {
"pre_tag": "<em>",
"post_tag": "</em>"
},
"gram_size": 1,
"real_word_error_likelihood": 0.95,
"direct_generator": [
{
"field": "summary",
"suggest_mode": "missing",
"min_word_len": 3,
"min_doc_freq": 5,
"max_edits": 1
}
]
},
"text": "gardeing with muclh"
},
"term": {
"term": {
"field": "summary",
"analyzer": "standard",
"suggest_mode": "missing",
"size": 3
},
"text": "gardeing with muclh"
}
}
and it returns the results:
{
"term": [
{
"text": "gardeing",
"offset": 0,
"length": 8,
"options": [
{
"text": "gardening",
"score": 0.875,
"freq": 512
},
{
"text": "gardenia",
"score": 0.75,
"freq": 71
},
{
"text": "gardeninig",
"score": 0.75,
"freq": 1
}
]
},
{
"text": "with",
"offset": 9,
"length": 4,
"options": []
},
{
"text": "muclh",
"offset": 14,
"length": 5,
"options": [
{
"text": "mulch",
"score": 0.8,
"freq": 190
},
{
"text": "much",
"score": 0.75,
"freq": 527
},
{
"text": "muscle",
"score": 0.6,
"freq": 1
}
]
}
],
"phrase": [
{
"text": "gardeing with muclh",
"offset": 0,
"length": 19,
"options": [
{
"text": "gardening with much",
"highlighted": "<em>gardening</em> with <em>much</em>",
"score": 0.000007876507
},
{
"text": "gardening with mulch",
"highlighted": "<em>gardening</em> with <em>mulch</em>",
"score": 0.000005306385
},
{
"text": "gardening with muclh",
"highlighted": "<em>gardening</em> with muclh",
"score": 5.7017786e-7
}
]
}
]
}
The problem is that the correct version is "gardening with mulch" but the phrase match is coming back with "gardening with much". Note that the term suggest score for "mulch" is higher than "much" for "muclh", I assume because they score a position change higher than an omission or addition.
UPDATE: I fixed this particular problem by adding a "maxTermFrequency" of .2 - but this seems just like a hack. I would prefer to solve it more intelligently if possible.
Is there a way to make "gardening with mulch" be the first suggestion instead of "gardening with much" without resorting to the MaxTermFrequency?

Ace Editor save as txt file

I have incorporated ace editor in my project
<div id="page-content-wrapper">
<pre id="editor">
</pre>
</div>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/text");
editor.setShowPrintMargin(false);
$('#mode').on('change', function(){
console.log("Change");
var newMode = document.getElementById('mode').value
console.log(newMode);
editor.getSession().setMode("ace/mode/" + newMode);
});
</script>
I want to store the contents written on this editor as a text file using php or javascript.
Need help on this.
Thanks in advance.
Cheers :)
I have implemented download file from ACE editor using Controller.
<div id="editor"></div>
<form action="downloadFromAce" method="post">
<textarea type="text" hidden id="valueInput" name=value ></textarea>
<button class="btn btn-primary" id="downloadBtn" type="submit">Download</button>
</form>
And on click of download button send this data (setting data in text area using jquery) form ACE editor to controller on POST request.
<script>
let editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/yaml");
$(document).ready(function () {
$("#downloadBtn").click(function () {
const data = editor.getValue();
$("#valueInput").val(data);
})
})
#PostMapping("/download")
Public void downloadFile(#ModelAttribute DownloadFileContent fileContent,HttpServletResponse response){
try{
response.setContentType("text/plain");
response.setHeader("content-Disposition","attachment;filename=demo.txt");
InputStream is=new ByteArrayInputStream(fileContent.getValue().getBytes());
IOUtils.copy(is,response.getOutputStream());
response.flushBuffer();
}catch(Exception e){
e.printStackTrace();
}
}
}
I have used spring boot for backend. But you can do that using other language also.
Here is a complete example of how to save a file, with a particular extension based on the selected mode.
Populate the mode selection box
Enter text you wish to save
Click the "Save" button in the toolbar
Enter a filename; a default file extension will be provided, based on the mode
Confirm
A dialog will be presented asking where to save the file
I used the following libraries:
jQuery - ace-editor requires it
tingle - nice light-weight plain js modal windows
FileSaver - an HTML5 saveAs() FileSaver implementation
const MODES = getModes();
ace.config.set('basePath', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11');
$('select[name="sel-mode"]').append(MODES.map(mode => new Option(mode.text, mode.value)));
const defaultMode = 'text';
const editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode(`ace/mode/${defaultMode}`);
editor.setShowPrintMargin(false);
$('select[name="sel-mode"]').on('change', function(e) {
editor.getSession().setMode("ace/mode/" + e.target.value);
}).val(defaultMode);
$('button[name="btn-save"]').on('click', e => saveDialog.open());
const saveDialog = new tingle.modal({
footer: true,
stickyFooter: false,
closeMethods: ['overlay', 'button', 'escape'],
closeLabel: 'Close',
cssClass: ['dialog-save'],
onOpen: function() {
$('input[name="filename"]').val(`*.${lookupFileExtension()}`);
},
onClose: function() {},
beforeClose: function() {
return true;
}
});
saveDialog.addFooterBtn('Confirm', 'tingle-btn tingle-btn--primary tingle-btn--pull-right', function() {
const filename = $('input[name="filename"]').val();
const file = new File([editor.getValue()], filename, {
type: "text/plain;charset=utf-8"
});
saveAs(file);
saveDialog.close();
});
saveDialog.addFooterBtn('Cancel', 'tingle-btn tingle-btn--danger tingle-btn--pull-right', function() {
saveDialog.close();
});
saveDialog.setContent($('<div>')
.append($('<h1>', {
text: 'Enter a filename'
}))
.append($('<input>', {
name: 'filename'
})).unwrap().html());
function lookupFileExtension() {
const selectedMode = $('select[name="sel-mode"]').val();
const mode = MODES.find(currMode => currMode.value === selectedMode);
return mode.extension || mode.value;
}
// TODO: Extensions need some more work.
// Option text/values via: https://ace.c9.io/tool/mode_creator.html
function getModes() {
return [{
"text": "ABAP",
"value": "abap"
}, {
"text": "ABC",
"value": "abc"
}, {
"text": "ActionScript",
"value": "actionscript",
"extension": "as"
}, {
"text": "ADA",
"value": "ada"
}, {
"text": "Alda",
"value": "alda"
}, {
"text": "Apache Conf",
"value": "apache_conf"
}, {
"text": "Apex",
"value": "apex"
}, {
"text": "AQL",
"value": "aql"
}, {
"text": "AsciiDoc",
"value": "asciidoc"
}, {
"text": "ASL",
"value": "asl"
}, {
"text": "Assembly x86",
"value": "assembly_x86"
}, {
"text": "AutoHotkey / AutoIt",
"value": "autohotkey",
"extension": "ahk"
}, {
"text": "BatchFile",
"value": "batchfile",
"extension": "bat"
}, {
"text": "C and C++",
"value": "c_cpp",
"extension": "cpp"
}, {
"text": "C9Search",
"value": "c9search"
}, {
"text": "Cirru",
"value": "cirru"
}, {
"text": "Clojure",
"value": "clojure",
"extension": "clj"
}, {
"text": "Cobol",
"value": "cobol",
"extension": "cob"
}, {
"text": "CoffeeScript",
"value": "coffee"
}, {
"text": "ColdFusion",
"value": "coldfusion",
"extension": "cfm"
}, {
"text": "Crystal",
"value": "crystal",
"extension": "rpt"
}, {
"text": "C#",
"value": "csharp",
"extension": "cs"
}, {
"text": "Csound Document",
"value": "csound_document",
"extension": "csd"
}, {
"text": "Csound",
"value": "csound_orchestra",
"extension": "csd"
}, {
"text": "Csound Score",
"value": "csound_score",
"extension": "csd"
}, {
"text": "CSS",
"value": "css"
}, {
"text": "Curly",
"value": "curly"
}, {
"text": "D",
"value": "d"
}, {
"text": "Dart",
"value": "dart"
}, {
"text": "Diff",
"value": "diff"
}, {
"text": "Dockerfile",
"value": "dockerfile"
}, {
"text": "Dot",
"value": "dot"
}, {
"text": "Drools",
"value": "drools",
"extension": "drl"
}, {
"text": "Edifact",
"value": "edifact",
"extension": "edi"
}, {
"text": "Eiffel",
"value": "eiffel",
"extension": "e"
}, {
"text": "EJS",
"value": "ejs"
}, {
"text": "Elixir",
"value": "elixir",
"extension": "ex"
}, {
"text": "Elm",
"value": "elm"
}, {
"text": "Erlang",
"value": "erlang",
"extension": "erl"
}, {
"text": "Forth",
"value": "forth",
"extension": "4th"
}, {
"text": "Fortran",
"value": "fortran",
"extension": "f90"
}, {
"text": "FSharp",
"value": "fsharp",
"extension": "fs"
}, {
"text": "FSL",
"value": "fsl"
}, {
"text": "FreeMarker",
"value": "ftl"
}, {
"text": "Gcode",
"value": "gcode"
}, {
"text": "Gherkin",
"value": "gherkin"
}, {
"text": "Gitignore",
"value": "gitignore"
}, {
"text": "Glsl",
"value": "glsl"
}, {
"text": "Gobstones",
"value": "gobstones"
}, {
"text": "Go",
"value": "golang",
"extension": "go"
}, {
"text": "GraphQLSchema",
"value": "graphqlschema"
}, {
"text": "Groovy",
"value": "groovy"
}, {
"text": "HAML",
"value": "haml"
}, {
"text": "Handlebars",
"value": "handlebars",
"extension": "hbs"
}, {
"text": "Haskell",
"value": "haskell",
"extension": "hs"
}, {
"text": "Haskell Cabal",
"value": "haskell_cabal",
"extension": "hs"
}, {
"text": "haXe",
"value": "haxe"
}, {
"text": "Hjson",
"value": "hjson"
}, {
"text": "HTML",
"value": "html"
}, {
"text": "HTML (Elixir)",
"value": "html_elixir"
}, {
"text": "HTML (Ruby)",
"value": "html_ruby"
}, {
"text": "INI",
"value": "ini"
}, {
"text": "Io",
"value": "io"
}, {
"text": "Jack",
"value": "jack"
}, {
"text": "Jade",
"value": "jade"
}, {
"text": "Java",
"value": "java"
}, {
"text": "JavaScript",
"value": "javascript",
"extension": "js"
}, {
"text": "JSON",
"value": "json",
"extension": "json"
}, {
"text": "JSON5",
"value": "json5",
"extension": "json"
}, {
"text": "JSONiq",
"value": "jsoniq"
}, {
"text": "JSP",
"value": "jsp",
"extension": "jsp"
}, {
"text": "JSSM",
"value": "jssm"
}, {
"text": "JSX",
"value": "jsx"
}, {
"text": "Julia",
"value": "julia"
}, {
"text": "Kotlin",
"value": "kotlin"
}, {
"text": "LaTeX",
"value": "latex",
"extension": "tex"
}, {
"text": "LESS",
"value": "less"
}, {
"text": "Liquid",
"value": "liquid"
}, {
"text": "Lisp",
"value": "lisp"
}, {
"text": "LiveScript",
"value": "livescript"
}, {
"text": "LogiQL",
"value": "logiql"
}, {
"text": "LSL",
"value": "lsl"
}, {
"text": "Lua",
"value": "lua"
}, {
"text": "LuaPage",
"value": "luapage"
}, {
"text": "Lucene",
"value": "lucene"
}, {
"text": "Makefile",
"value": "makefile"
}, {
"text": "Markdown",
"value": "markdown"
}, {
"text": "Mask",
"value": "mask"
}, {
"text": "MATLAB",
"value": "matlab"
}, {
"text": "Maze",
"value": "maze"
}, {
"text": "MediaWiki",
"value": "mediawiki"
}, {
"text": "MEL",
"value": "mel"
}, {
"text": "MIXAL",
"value": "mixal"
}, {
"text": "MUSHCode",
"value": "mushcode"
}, {
"text": "MySQL",
"value": "mysql",
"extension": "sql"
}, {
"text": "Nginx",
"value": "nginx"
}, {
"text": "Nim",
"value": "nim"
}, {
"text": "Nix",
"value": "nix"
}, {
"text": "NSIS",
"value": "nsis"
}, {
"text": "Nunjucks",
"value": "nunjucks"
}, {
"text": "Objective-C",
"value": "objectivec"
}, {
"text": "OCaml",
"value": "ocaml"
}, {
"text": "Pascal",
"value": "pascal",
"extension": "pas"
}, {
"text": "Perl",
"value": "perl",
"extension": "pl"
}, {
"text": "Perl 6",
"value": "perl6",
"extension": "pl"
}, {
"text": "pgSQL",
"value": "pgsql"
}, {
"text": "PHP",
"value": "php"
}, {
"text": "PHP (Blade Template)",
"value": "php_laravel_blade",
"extension": "php"
}, {
"text": "Pig",
"value": "pig"
}, {
"text": "Powershell",
"value": "powershell"
}, {
"text": "Praat",
"value": "praat"
}, {
"text": "Prisma",
"value": "prisma"
}, {
"text": "Prolog",
"value": "prolog"
}, {
"text": "Properties",
"value": "properties"
}, {
"text": "Protobuf",
"value": "protobuf"
}, {
"text": "Puppet",
"value": "puppet"
}, {
"text": "Python",
"value": "python",
"extension": "py"
}, {
"text": "QML",
"value": "qml"
}, {
"text": "R",
"value": "r"
}, {
"text": "Razor",
"value": "razor"
}, {
"text": "RDoc",
"value": "rdoc"
}, {
"text": "Red",
"value": "red"
}, {
"text": "RHTML",
"value": "rhtml"
}, {
"text": "RST",
"value": "rst"
}, {
"text": "Ruby",
"value": "ruby"
}, {
"text": "Rust",
"value": "rust"
}, {
"text": "SASS",
"value": "sass"
}, {
"text": "SCAD",
"value": "scad"
}, {
"text": "Scala",
"value": "scala"
}, {
"text": "Scheme",
"value": "scheme"
}, {
"text": "SCSS",
"value": "scss"
}, {
"text": "SH",
"value": "sh"
}, {
"text": "SJS",
"value": "sjs"
}, {
"text": "Slim",
"value": "slim"
}, {
"text": "Smarty",
"value": "smarty"
}, {
"text": "snippets",
"value": "snippets"
}, {
"text": "Soy Template",
"value": "soy_template"
}, {
"text": "Space",
"value": "space"
}, {
"text": "SQL",
"value": "sql"
}, {
"text": "SQLServer",
"value": "sqlserver"
}, {
"text": "Stylus",
"value": "stylus"
}, {
"text": "SVG",
"value": "svg"
}, {
"text": "Swift",
"value": "swift"
}, {
"text": "Tcl",
"value": "tcl"
}, {
"text": "Terraform",
"value": "terraform"
}, {
"text": "Tex",
"value": "tex"
}, {
"text": "Text",
"value": "text",
"extension": "txt"
}, {
"text": "Textile",
"value": "textile"
}, {
"text": "Toml",
"value": "toml"
}, {
"text": "TSX",
"value": "tsx"
}, {
"text": "Twig",
"value": "twig"
}, {
"text": "Typescript",
"value": "typescript",
"extension": "ts"
}, {
"text": "Vala",
"value": "vala"
}, {
"text": "VBScript",
"value": "vbscript"
}, {
"text": "Velocity",
"value": "velocity"
}, {
"text": "Verilog",
"value": "verilog"
}, {
"text": "VHDL",
"value": "vhdl"
}, {
"text": "Visualforce",
"value": "visualforce"
}, {
"text": "Wollok",
"value": "wollok"
}, {
"text": "XML",
"value": "xml"
}, {
"text": "XQuery",
"value": "xquery"
}, {
"text": "YAML",
"value": "yaml",
"extension": "yml"
}, {
"text": "Zeek",
"value": "zeek"
}, {
"text": "Django",
"value": "django"
}];
}
html,
body {
height: 100%;
width: 100%;
}
#page-content-wrapper {
height: 100%;
width: 100%;
}
.toolbar {
display: flex;
flex-direction: row;
height: 2em;
background: #111;
padding: 0 0.25em;
}
.toolbar button,
.toolbar select {
display: inline-block;
height: 1.67em;
margin-right: 0.5em;
align-self: center;
}
#editor {
width: 100%;
height: calc(100% - 3.33em);
}
.dialog-save h1 {
font-size: 1.5em;
font-weight: bold;
margin-bottom: 0.5em;
}
.dialog-save .tingle-modal-box__content {
padding: 2rem;
}
.dialog-save .tingle-modal-box__footer {
padding: 1rem;
}
.dialog-save .tingle-btn {
padding: 0.667rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/tingle/0.15.2/tingle.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/tingle/0.15.2/tingle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/theme-monokai.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/mode-text.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/file-saver#2.0.2/dist/FileSaver.min.js"></script>
<div id="page-content-wrapper">
<div class="toolbar">
<select name="sel-mode"></select>
<button name="btn-save">Save</button>
</div>
<pre id="editor"></pre>
</div>
<input type="text" id="input-fileName" value="Result" placeholder="Enter file name">
<button id="download2" type="submit" class="btn btn-primary">Save</button>
<script type="text/javascript">
document.getElementById("download2").addEventListener("click", ()=>{
var filename = $("#input-fileName").val()
var file = new File([editor.getValue()],filename +".h4c", {type: "text/plain;charset=utf-8"});
saveAs(file);
})
Define a button as shown in the code which will trigger the function and the function gets the user input from ace editor and process it to a file with extension, by default i have set extension to .h4c change it according to your need and for the filename i have provided textbox.

Resources