private bool ExtractPhoneSizeInfo(LuisResult result)
        {
            bool   desc      = false; // By default, ascending
            double threshold = -1;

            string[] tokens;
            int      index = 0;
            bool     additionalInfoDetected = false;

            double[] volume = new double[3];

            foreach (var cEntity in result.CompositeEntities)
            {
                if (cEntity.ParentType == "SizeComposite")
                {
                    foreach (var child in cEntity.Children)
                    {
                        switch (child.Type)
                        {
                        case "OrderByWay":
                            desc = ("small" != child.Value.ToLower() && ("smallest" != child.Value.ToLower()));
                            additionalInfoDetected = true;
                            break;

                        case "buildin.number":
                            if ((index < 3) && double.TryParse(child.Value, out volume[index]))
                            {
                                ++index;
                            }
                            break;

                        case "DimensionsRegEx":
                            if (index >= 3)
                            {
                                continue;     // We already have the info we need about the desired volume threshold
                            }
                            tokens = child.Value.ToLower().Split('x');
                            if (double.TryParse(tokens[0], out volume[0]) && double.TryParse(tokens[1], out volume[1]) && double.TryParse(tokens[2], out volume[2]))
                            {
                                index = 3;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    if (index == 3)  // OK, we have valid data
                    {
                        additionalInfoDetected = true;
                        threshold = Miscellany.Product(volume);
                    }
                }
            }
            if (additionalInfoDetected)
            {
                decoder.SetSizeRequirements(threshold, desc);
            }
            return(additionalInfoDetected);
        }
        private async Task ProcessSizeChoice(IDialogContext context, IAwaitable <string> awaitable)
        {
            string          ans = await awaitable;
            string          currentModel;
            HandSetFeatures phoneFeatures;
            int             handSetsLeft, handSetsNow = decoder.CurrentNumberofHandsetsLeft();

            context.ConversationData.TryGetValue("HandsetModelKey", out currentModel);
            currentModel  = "iphone 7 plus  256gb";
            phoneFeatures = handSetsBag.GetModelFeatures(currentModel);

            if (ans == "THE SAME")
            {
                needsScores.CurrentPhone = currentModel;
                decoder.ExcludeThis(EIntents.Small);
                decoder.SetSizeRequirements(0, false);
                handSetsLeft = needsScores.GetTopFive(NodeLuisSubsNeeds.ENeeds.PhoneSize);
                await UpdateUserAsync(context, handSetsLeft, handSetsNow);
            }
            else
            {
                if (ans == "SMALLER")
                {
                    decoder.SetSizeRequirements(Miscellany.Product(phoneFeatures.BodySize), false);
                }
                else
                {
                    decoder.SetSizeRequirements(Miscellany.Product(phoneFeatures.BodySize), true);
                }
                await DecodeAndProcessIntentAsync(context);
            }
        }
Ejemplo n.º 3
0
        public double GetModelSize(string model)
        {
            HandSetFeatures features = masterDict.GetEquipmentFeatures(model);

            return(Miscellany.Product(features.BodySize));
        }