IranCahtBot
V.I.P
Posts: 27
Joined: Sat Feb 25, 2017 7:36 pm

Enumeration Recognize

Mon Jun 19, 2017 6:58 pm

Hello Dear FranzZ,

I appreciate you for taking time to solve my problem in using "Enumeration Recognize".
In the following code, when I enter "N", the response is "N". I think, the correct response should be "X".
Would you please help me, what is wrong in my application?
var perfumeSellerRobot = new OscovaBot();
perfumeSellerRobot.Dialogs.Add(new PerfumeSellerRobot());
perfumeSellerRobot.CreateRecognizer<ProductPerfumeSuitableFors>("ProductPerfumeSuitableFors");
perfumeSellerRobot.Trainer.StartTraining();
var perfumeSellerEvaluationResult = perfumeSellerRobot.Evaluate("N");
perfumeSellerEvaluationResult.Invoke();
perfumeSellerRobot.MainUser.ResponseReceived += (sender, eventArgs) =>
{
string output = eventArgs.Response.Text.Trim();
};


enum ProductPerfumeSuitableFors
{
[Synonyms("O", "M", "N")]
X,

[Synonyms("P", "Q")]
Y
}

[Expression("@ProductPerfumeSuitableFors")]
public void FindSuitableFors(Context context, Result result)
{
var productPerfumeSuitableFors = result.Entities.OfType("ProductPerfumeSuitableFors").Value;
result.SendResponse("4" + "+" + productPerfumeSuitableFors + "+");
}.

With regards
Ebrahimi

User avatar
Fantom
Help & Support
Posts: 320
Joined: Fri Oct 25, 2013 9:20 pm

Re: Enumeration Recognize

Mon Jun 19, 2017 8:38 pm

The Value property will always return the matched part in user input. This is by design.

therefore result.Entities.OfType("ProductPerfumeSuitableFors").Value; being N is correct.

try getting the value as an enum as shown below:

CSharp Code

var entity = result.Entities.OfType<Entity>("ProductPerfumeSuitableFors");
var enumValue = entity.ValueAs<ProductPerfumeSuitableFors>(); //Will return enum value X
Hope that helps :)

IranCahtBot
V.I.P
Posts: 27
Joined: Sat Feb 25, 2017 7:36 pm

Re: Enumeration Recognize

Tue Jun 20, 2017 9:33 am

Hello Dear FranzZ,

I sincerely appreciate the information you have provided me and I thank very much the prompt reply.

With regards
Ebrahimi

Return to “Feature Request and Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest