Detect intent in prompt choice - botframework

I use the Node Botframework Sdk, and the user have to fill out a questionnaire.
This questionnaire have three questions with the same answer "yes", "no", "maybe".
But if the user answer is "yep" or "yes of course" or "always" that can match "yes" (affirmative answer)
If the user answer is "sometimes" or "it depends" or "rarely" that can match "maybe"(nuance answer)
In the future, we must be able to predict new answer not expected at the begining (add easily new answer).
Unfortunately Prompts.choice() don't permit to bind a choice to a intent.
So Two solutions :
Use Prompts.choice() synonyms
Use Prompts.text() and create 3 differents intents (affirmative, nuance, negative) and pass the answer to luis. On the luis response save the good answer (yes | no | maybe)
Which one is the best solution ? Other solution exist ?

Probably the way to go here is using the synonyms of the Prompts.choice; however an alternative you can also explore is overriding some of the behaviors of the Prompts.choice to also call LUIS before parsing the response and returning if it's valid or not.

Why don't you use buttons to get user entry using buttons ? However you can type this code in ResumeAfterAsync function
var r = await result;
if(r.ToLower.Contains("yes") || r.ToLower.Contains("yea" || .....)
{
}
but I think using buttons is a better way

Related

Change the way an object is displayed in debugger/inspector variable-value table

I would like to know if there is a message I can override in Pharo so that my custom classes display more descriptive information in the inspector/debuger much like simple variable types do, like Integers or Strings. For instance:
Instead of that, I would like it to show a more custom and informative description consisting of its internal variales so as to have a tighter/tidier view of the variables instead of having to click on it and open another chart (therefore losing sight of the information on the previous chart). I know you can increase the amount of charts shown below, but that is not the point of the question. I would like to achieve something like this:
I have browsed the pharo forums and found nothing, I have also tried overriding over 30 methods hoping that one of them changed the output. Only the class message seemed to change the output, but I could only return an instance of Metaclass and besides messing with this message would break a lot of stuff. Finally I tried to reverse engineer the debugger and then the inspector to see at which point is the table constructed and what values are used or which messages are sent to build said values, but it was just too much for me, the callstack kept growing and I couldn't even scratch the surface.
Luckily, doing this in any Smalltalk is very easy. Types inherited from Object are expected to answer to the message printString, and ultimately printOn: aStream. Those messages are expected to give a description of the object. So, you should just override printOn: in your class (printString uses printOn:) and all the browsers and inspectors will automatically use it. There other possibilities in Pharo, if you want to provide more complex information in different tabs, but I think printOn: will suffice for you.
An example would be:
MyPoint>>printOn: aStream
aStream nextPut: ${.
x printOn: aStream.
aStream nextPutAll: ', '
y printOn: aStream.
aStream nextPut: $}
In Smalltalk, every time you observe something you don't like or understand, you ask the question: Which message is doing this?
In your case, the question would be: Which message creates the string a MyPoint that I see everywhere?
Next, to answer your question you need to find a good place for inserting a halt and then debug from there until you find the culprit. To do this just find the simplest expression that would reproduce the issue and debug it. In your case the right-click command in the Playground will do. So,
Write and select (MyPoint on: 14 and: -5) halt in a Playground.
Right-click and issue the Print it command (I'm assuming you already checked that this command produces the string 'a MyPoint').
Debug
Go over the evaluation of #DoIt, which answers the result
Continue this way alternating between Into and Over to make sure you follow the result to where it's being taken
Eventually you will reach the implementation of Object >> #printString. Bingo!
Now you can open a System Browser and take a look at this method, study how it's been implemented in different classes, etc. Your investigation should show you that the most basic message for printing is #printOn:. You may also want to take a look at other implementors so to better understand what people usually do. (Bear in mind that writing good #printOn:s is a minimalist art)
Overriding printOn: will work for simple cases where you want to just change description.
Pharo allows a lot more than that!
Due the extensible (moldable) nature of our inspector, you do not need to override a method to get your own visualisation of the object.
For example, look this array visualisation:
This is obtained adding this method to Collection:
gtInspectorItemsIn: composite
<gtInspectorPresentationOrder: 0>
^ composite fastList
title: 'Items';
display: [ self asOrderedCollection ];
beMultiple;
format: [ :each | GTObjectPrinter asTruncatedTextFrom: each ];
send: [ :result |
result
ifNil: [ nil ]
ifNotNil: [ result size = 1
ifTrue: [ result anyOne ]
ifFalse: [ self species withAll: result ]
]
]
if you browse for senders of gtInspectorPresentationOrder: you will see there are already a lot of special visualisations in the image.
You can take those as an example on how to create your own, adapted exactly to what you need :)

OBIEE 12C: use of presentation variables

I have a question concerning the use of presentation variables:
1) What's the correct syntax for filtering on a presentation variable is used? You allow a user to select multiple values in a filter eg. A and B. If you use the syntax = '#{PV}{%}' it will result in this sql: = 'A, B' which of course won't exist in the data. I'd like to have this result: in ('A', 'B').
I've already found this syntax: (#{PV}['#']) which gives the correct sql, only thing here is that this doesn't work when you have a dashboard prompt where you allow 'all column values'. When no value is passed to this presentation variable, the analysis throws an error. I have no idea how to put a default value in this one. Any ideas on this?
2) Is there any configuration or setting where you can push obi to use a presentation variable in stead of using the 'normal' way of filtering as shown here:
The obi way is that it changes the relation to the relation in the prompt (if the prompt says 'is greater than' it will change here as well, even though you've put here 'is equal to'), but it will also use a value for this dimension if there's ever been a value for this, rather than listening to the value in the presentation variable of the dashboard prompt. I know that you can translate this to SQL but that's not the way to go for me. The behaviour I'd like is (in this exact order):
- when there is a value in the presentation variable in the dashboard prompt, take this.
- when there is a value for this role of the dimension, take that.
The reason why is because we have this dimension 'Afdeling' which can take up many roles but our customer asked for the roles to be hidden from the end user. This means that even though you switch roles, the end user always sees 'Afdeling' and couldn't care less in which role it is looking at its 'Afdeling'. They can switch between different dashboard pages and if I'd put on top of the page the dashboardprompt of the 'Afdeling' in the role it needed to be, the value won't pass through when switching pages to another dashboardprompt of another role. That way the end user would know something was up. So the value needs to pass through the prompt on each page, no matter what the role of that dimension.
After a bit of googling I've found the answer to question 1 myself. Thanks to this website https://www.obieetips.com/2014/05/obiee-11g-using-multiple-value-for.html I now know that the correct syntax is (#{pv_region}['#']{'West '})

Suggestions for Designing UI for Grouping Search Conditions

I'm building an advanced search page for my site where users can select a search category for a condition and then enter a value for it. A user can enter as many conditions as they want and each condition can be linked to the next with either an AND or OR clause. As a visual, this is very similar to what I'm going for: http://blog.lib.umn.edu/jeffryes/biomedical/Copy%20of%20Web%20of%20Science.png
I also want to allow users to be able to group conditions search conditions. For example, the Web of Science interface only allows these kind of queries:
a == apple AND b == 10 OR c == cranberry AND d == 20
However I would like my users to be able to do something like this:
(a == apple AND b == 10) OR (c == cranberry AND d == 20)
But I'm having trouble coming up with an intuitive and easy-to-use way to implement the UI to allow the users to group search conditions like that. Any suggestions or example websites with something similar that I could draw some inspiration from?
Although this really depends on who your target audience is and how technical they are. Since you are describing pretty sophisticated conditional filtering, I'll assume that the target user is comfortable writing out logic.
I liked how salesforce.com implemented similar filtering in their reporting engine. As a user, you can add as many conditions as you like by clicking a plus sign (icon). By default, all of them are AND, however, you have a text field where you can enter the logic.
For example:
1. a == apple
2. b == 10
3. c == cranberry
4. d == 20
Conditional Logic: (1 and 2) or (3 and 4)
As stated above, this would make sense for a business application or somewhere in a consumer app, where the user has self-selected to be fairly savvy. It's definitely not the right approach if you are expecting consumers to use this without some advanced prep.

ComplexPhraseQueryParser

I would like to implement for my website a fuzzy phrase search using Hibernate Search. I've read from some people that ComplexPhraseQueryParser is ok for this.
But the thing is that I have some missunderstandings or issues related to it.
So for instance let's consider a test title like this (I have a lot of this and I need to let users search whatever they like):
"Do you know how to be in shape?"
If someone will type
"do you cnow how to be in shape?" my ComplexPhraseQueryParser will not find anyting. But if I put a "~" character after the misspeled word like "cnow~" it will work and return a result.
What is the reason of this? Doesn't ComplexPhraseQueryParser support such situations?
I would like to make my search deal with few misspelled words and return results (similar to google search).
ComplexPhraseQueryParser quizTitlePhraseQuery = new ComplexPhraseQueryParser(Version.LUCENE_30, "title", new StandardAnalyzer(
Version.LUCENE_30)) ;
quizTitlePhraseQuery.setPhraseSlop(100);
quizTitlePhraseQuery.setDefaultOperator(Operator.AND);
quizTitlePhraseQuery.setFuzzyMinSim(0.1f);
Thank you in advance!

Where can I learn more about the Google search "did you mean" algorithm? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How do you implement a “Did you mean”?
I am writing an application where I require functionality similar to Google's "did you mean?" feature used by their search engine:
Is there source code available for such a thing or where can I find articles that would help me to build my own?
You should check out Peter Norvigs article about implementing the spell checker in a few lines of python:
How to Write a Spelling Corrector It also has links for implementations in other languages (i.e. C#)
I attended a seminar by a Google engineer a year and a half ago, where they talked about their approach to this. The presenter was saying that (at least part of) their algorithm has little intelligence at all; but rather, utilises the huge amounts of data they have access to. They determined that if someone searches for "Brittany Speares", clicks on nothing, and then does another search for "Britney Spears", and clicks on something, we can have a fair guess about what they were searching for, and can suggest that in future.
Disclaimer: This may have just been part of their algorithm
Python has a module called difflib. It provides a functionality called get_close_matches. From the Python Documentation:
get_close_matches(word, possibilities[, n][, cutoff])
Return a list of the best "good
enough" matches. word is a sequence
for which close matches are desired
(typically a string), and
possibilities is a list of sequences against which to match
word (typically a list of strings).
Optional argument n (default
3) is the maximum number of close
matches to return; n must be
greater than 0.
Optional argument cutoff (default
0.6) is a float in the range [0,
1]. Possibilities that don't score
at least that similar to word are
ignored.
The best (no more than n) matches
among the possibilities are returned
in a list, sorted by similarity
score, most similar first.
>>> get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'])
['apple', 'ape']
>>> import keyword
>>> get_close_matches('wheel', keyword.kwlist)
['while']
>>> get_close_matches('apple', keyword.kwlist)
[]
>>> get_close_matches('accept', keyword.kwlist)
['except']
Could this library help you?
You can use http://developer.yahoo.com/search/web/V1/spellingSuggestion.html which would give a similar functionality.
You can check out the source code for Xapian which provides this functionality, as do a lot of other search libraries. http://xapian.org/
I am not sure if it serves your purpose but a String Edit distance Algorithm with a dictionary might suffice for a small Application.
I'd take a look at this article on google bombing. It shows that it just suggests answers based off previously entered results.
AFAIK the "did you mean ?" feature doesn't check the spelling. It only gives you another query based on the content parsed by google.
A great chapter to this topic can be found in the openly available Introduction to Information Retrieval.
U could use ngram for the comparisment: http://en.wikipedia.org/wiki/N-gram
Using python ngram module: http://packages.python.org/ngram/index.html
import ngram
G2 = ngram.NGram([ "iis7 configure ftp 7.5",
"ubunto configre 8.5",
"mac configure ftp"])
print "String", "\t", "Similarity"
for i in G2.search("iis7 configurftp 7.5", threshold=0.1):
print i[0], "\t", i[1]
U get:
>>>
String Similarity
"iis7 configure ftp 7.5" 0.76
"mac configure ftp 0.24"
"ubunto configre 8.5" 0.19
take a look at Levenshtein-Automata

Resources