public NodeLUISPhoneDialog(TopFeatures mostDemanded, HandSets handSets, string brand, DateTime?currentModelReleaseDate, List <string> narrowedListOfModels) : base()
        {
            smallDesc = new Dictionary <EIntents, string>()
            {
                { EIntents.BatteryLife, "Battery life" },
                { EIntents.Small, "Physical Size" }
            };
            acknowledgeMessages = new Dictionary <EIntents, string[]>()
            {
                { EIntents.BandWidth, new String[] { "I've picked out the phones that have access to internet and wide bandwidth" } },
                { EIntents.BatteryLife, new String[] { "I've picked out the phones that have a big battery life", "I've picked out all the phones that have a battery life longer than {0} hours" } },
                { EIntents.Brand, new String[] { "I understand that for you the brand is important so I've picked out all the phones from {0}" } },
                { EIntents.Camera, new String[] { "I've excluded all the phones with camera resolution less than 12 MegaPixels.", "I've picked out all the phones with cameras of at least {0} MegaPixels" } },
                { EIntents.DualCamera, new String[] { "I've picked out the phones with a Dual Camera." } },
                { EIntents.DualSIM, new String[] { "I've picked out the phones with DualSIM." } },
                { EIntents.ExpandableMemory, new String[] { "I've picked out the phones with expandable memory." } },
                { EIntents.FMRadio, new String[] { "I've picked out the phones with FM Radio Antenna." } },
                { EIntents.FaceID, new String[] { "I've picked out the phones with Face ID recognition." } },
                { EIntents.GPS, new String[] { "I've picked out the phones with GPS." } },
                { EIntents.HDVoice, new String[] { "I've picked out the phones with High Definition voice." } },
                { EIntents.HighResDisplay, new String[] { "I've picked out the phones with High resolution display.", "I've picked out all the phones with display resolution higher than {0} pixels" } },
                { EIntents.LargeStorage, new String[] { "I've picked out the phones with the largest storage capability.", "I've picked out all the phones that have a storage capacity higher than {0} MB" } },
                { EIntents.OS, new String[] { "I understand that operating System is important for you and you would like to have a phone with {0}" } },
                { EIntents.ScreenSize, new String[] { "I've picked out the phones with the largest screen size.", "I've picked out all the phones that have a screen size larger than {0} inches" } },
                { EIntents.SecondaryCamera, new String[] { "I've picked out the phones with a secondary camera." } },
                { EIntents.Small, new String[] { "I've picked out the phones with the smallest dimensions.", "I've picked out the biggest phones", "I've picked out all the phones smaller than {0}", "I've picked out all the phones bigger than {0}", "Picked all the phones roughly the same size of yours" } },
                { EIntents.SmartPhone, new String[] { "I understand that you want a smartphone, not a feature phone." } },
                { EIntents.WaterResist, new String[] { "I've picked out the phones that are water resistant." } },
                { EIntents.Weight, new String[] { "I've picked out the lightest phones.", "I've picked out all the phones weighting less than {0}." } },
                { EIntents.WiFi, new String[] { "I've picked out the phones with WiFi." } },
                { EIntents.Color, new String[] { "I understand that for you the color is important so I picked the phones with your preferred colors : {0}" } },
                { EIntents.Newest, new String[] { "I've picked out the most recent models.", "I've picked out all the models that have a release date more recent than {0}" } },
                { EIntents.FeaturePhone, new String[] { "I understand that you want a simple, classic, feature phone" } }
            };

            handSetsBag             = handSets;
            brandDesired            = brand;
            ReleaseDateCurrentModel = currentModelReleaseDate;
            decoder     = mostDemanded.AssociatedDecoder;
            topButtons  = mostDemanded;
            needsScores = new ScoreFuncs(handSets);
        }
Example #2
0
 public ScoreFuncs(HandSets bag)
 {
     basket             = bag;
     comparingFunctions = new Dictionary <NodeLuisSubsNeeds.ENeeds, sgn>()
     {
         { NodeLuisSubsNeeds.ENeeds.MovieWatcher, x => - Math.Sign(MovieWatcherScore(x.Item1) - MovieWatcherScore(x.Item2)) },
         { NodeLuisSubsNeeds.ENeeds.PictureLover, x => - Math.Sign(PictureLoverScore(x.Item1) - PictureLoverScore(x.Item2)) },
         { NodeLuisSubsNeeds.ENeeds.GamesAddict, x => - Math.Sign(GamesAddictScore(x.Item1) - GamesAddictScore(x.Item2)) },
         { NodeLuisSubsNeeds.ENeeds.Camera, x => - Math.Sign(CameraScore(x.Item1) - CameraScore(x.Item2)) },
         { NodeLuisSubsNeeds.ENeeds.PhoneSize, x => - Math.Sign(SameSizeScore(x.Item1) - SameSizeScore(x.Item2)) }
     };
     getters = new Dictionary <NodeLuisSubsNeeds.ENeeds, HandSets.accessor>()
     {
         { NodeLuisSubsNeeds.ENeeds.MovieWatcher, x => MovieWatcherScore(x) },
         { NodeLuisSubsNeeds.ENeeds.PictureLover, x => PictureLoverScore(x) },
         { NodeLuisSubsNeeds.ENeeds.GamesAddict, x => GamesAddictScore(x) },
         { NodeLuisSubsNeeds.ENeeds.ShowOff, x => 1 },
         { NodeLuisSubsNeeds.ENeeds.PhoneSize, x => SameSizeScore(x) },
         { NodeLuisSubsNeeds.ENeeds.Camera, x => CameraScore(x) }
     };
 }
Example #3
0
        public IntentDecoder(HandSets hand_sets, string brand, DateTime?releaseDate, List <string> identifiedMatches)
        {
            handSets        = hand_sets;
            intents2Exclude = new List <NodeLUISPhoneDialog.EIntents>();
            if (identifiedMatches == null)
            {
                handSets.InitializeBag(brand, releaseDate);
            }
            else
            {
                handSets.InitializeBag(identifiedMatches);
            }

            planNamesMapping = new Dictionary <string, string>()
            {
                { "BeYou 80", "Be You 80" },
                { "BeYou 60", "Be You 60" },
                { "BeYou 40", "Be You 40" },
                { "BeYou SIM", "Be You 12 (PAYG)" }
            };
            intentFilters = new Dictionary <NodeLUISPhoneDialog.EIntents, Predicate <HandSetFeatures> >()
            {
                { NodeLUISPhoneDialog.EIntents.BatteryLife, x => x.BatteryLife < Threshold },
                { NodeLUISPhoneDialog.EIntents.Camera, y => y.Camera < Threshold },
                { NodeLUISPhoneDialog.EIntents.HighResDisplay, y => Prod(y.DisplayResolution) < Threshold },
                { NodeLUISPhoneDialog.EIntents.LargeStorage, y => y.MemoryMB < Threshold },
                { NodeLUISPhoneDialog.EIntents.ScreenSize, y => !desc ^ (y.ScreenSize < Threshold) },
                { NodeLUISPhoneDialog.EIntents.Cheap, y => y.Price[chosenPlan] > Threshold },
                { NodeLUISPhoneDialog.EIntents.Small, y => desc ^ (Prod(y.BodySize) > Threshold) },
                { NodeLUISPhoneDialog.EIntents.Weight, y => y.Weight > Threshold },
                { NodeLUISPhoneDialog.EIntents.Color, y => !y.Colors.Exists(x => StrKeyWords.Contains(x.ToLower())) },
                { NodeLUISPhoneDialog.EIntents.OS, y => !StrKeyWords.Contains(y.OS.ToLower()) },
                { NodeLUISPhoneDialog.EIntents.Brand, y => !StrKeyWords.Contains(y.Brand.ToLower()) },
                { NodeLUISPhoneDialog.EIntents.Newest, y => y.ReleaseDate < DateThreshold },
                { NodeLUISPhoneDialog.EIntents.SecondaryCamera, y => y.SecondaryCamera < Threshold },
                { NodeLUISPhoneDialog.EIntents.DualCamera, y => y.DualCamera < Threshold }
            };
            comparingFunctions = new Dictionary <NodeLUISPhoneDialog.EIntents, sgn>()
            {
                { NodeLUISPhoneDialog.EIntents.BatteryLife, x => - Math.Sign(x.Item1.BatteryLife - x.Item2.BatteryLife) },
                { NodeLUISPhoneDialog.EIntents.Camera, x => - Math.Sign(x.Item1.Camera - x.Item2.Camera) },
                { NodeLUISPhoneDialog.EIntents.HighResDisplay, x => - Math.Sign(Prod(x.Item1.DisplayResolution) - Prod(x.Item2.DisplayResolution)) },
                { NodeLUISPhoneDialog.EIntents.LargeStorage, y => - Math.Sign(y.Item1.MemoryMB - y.Item2.MemoryMB) },
                { NodeLUISPhoneDialog.EIntents.ScreenSize, y => (desc ? -1 : 1) * Math.Sign(y.Item1.ScreenSize - y.Item2.ScreenSize) },
                { NodeLUISPhoneDialog.EIntents.Cheap, y => Math.Sign(y.Item1.Price["Be You 60"] - y.Item2.Price["Be You 60"]) },
                { NodeLUISPhoneDialog.EIntents.Small, y => (desc ? -1 : 1) * Math.Sign(Prod(y.Item1.BodySize) - Prod(y.Item2.BodySize)) },
                { NodeLUISPhoneDialog.EIntents.Weight, y => Math.Sign(y.Item1.Weight - y.Item2.Weight) },
                { NodeLUISPhoneDialog.EIntents.Newest, y => (y.Item2.ReleaseDate > y.Item1.ReleaseDate) ? 1 : -1 },
                { NodeLUISPhoneDialog.EIntents.SecondaryCamera, x => - Math.Sign(x.Item1.SecondaryCamera - x.Item2.SecondaryCamera) },
                { NodeLUISPhoneDialog.EIntents.DualCamera, x => - Math.Sign(x.Item1.DualCamera - x.Item2.DualCamera) }
            };

            getters = new Dictionary <NodeLUISPhoneDialog.EIntents, HandSets.accessor>()
            {
                { NodeLUISPhoneDialog.EIntents.BatteryLife, x => x.BatteryLife },
                { NodeLUISPhoneDialog.EIntents.Camera, x => x.Camera },
                { NodeLUISPhoneDialog.EIntents.HighResDisplay, x => Prod(x.DisplayResolution) },
                { NodeLUISPhoneDialog.EIntents.LargeStorage, y => y.MemoryMB },
                { NodeLUISPhoneDialog.EIntents.ScreenSize, y => y.ScreenSize },
                { NodeLUISPhoneDialog.EIntents.Cheap, y => y.Price["Be You 60"] },
                { NodeLUISPhoneDialog.EIntents.Small, y => Prod(y.BodySize) },
                { NodeLUISPhoneDialog.EIntents.Weight, y => y.Weight },
                { NodeLUISPhoneDialog.EIntents.Newest, y => y.ReleaseDate.Ticks },
                { NodeLUISPhoneDialog.EIntents.SecondaryCamera, y => y.SecondaryCamera },
                { NodeLUISPhoneDialog.EIntents.DualCamera, y => y.DualCamera }
            };

            booleanFilters = new Dictionary <NodeLUISPhoneDialog.EIntents, Predicate <HandSetFeatures> >()
            {
                { NodeLUISPhoneDialog.EIntents.BandWidth, x => !x.Connectivity_4G },
                { NodeLUISPhoneDialog.EIntents.FMRadio, x => !x.HasFMRadio },
                { NodeLUISPhoneDialog.EIntents.DualSIM, x => !x.DualSIM },
                { NodeLUISPhoneDialog.EIntents.ExpandableMemory, x => !x.ExpandableMemory },
                { NodeLUISPhoneDialog.EIntents.FaceID, x => !x.FaceId },
                { NodeLUISPhoneDialog.EIntents.FeaturePhone, x => x.IsSmartphone },
                { NodeLUISPhoneDialog.EIntents.GPS, x => !x.GPS },
                { NodeLUISPhoneDialog.EIntents.SmartPhone, x => !x.IsSmartphone },
                { NodeLUISPhoneDialog.EIntents.WiFi, x => !x.WiFi },
                { NodeLUISPhoneDialog.EIntents.HDVoice, x => !x.HDVoice },
                { NodeLUISPhoneDialog.EIntents.WaterResist, x => !x.WaterResist },
            };

            FeatureOrSmartPhoneDecision = false;
        }
Example #4
0
 private void InitializeDataStruct()
 {
     handSets = mongoDBAccess.GetCompleteHandSetData();
 }
Example #5
0
        public static void ComposeBrandsCarousel(Activity reply, IEnumerable <string> brands, HandSets hs)
        {
            List <string> listOfBrands = new List <string>(brands);
            int           len;
            HeroCard      heroCard;

            listOfBrands.Sort();
            len = listOfBrands.Count;
            for (int n = 0; n < len; ++n)
            {
                heroCard = new HeroCard
                {
                    Title    = Miscellany.Capitalize(listOfBrands[n]),
                    Subtitle = Miscellany.Capitalize(listOfBrands[n]),
                    Text     = "",
                    Images   = new List <CardImage> {
                        new CardImage(hs.GetBrandLogo(listOfBrands[n]), "img/jpeg")
                    },
                    Buttons = new List <CardAction> {
                        new CardAction {
                            Title = "Pick Me!", Type = ActionTypes.ImBack, Value = "I want " + Miscellany.Capitalize(listOfBrands[n])
                        }
                    },
                };
                reply.Attachments.Add(heroCard.ToAttachment());
            }
            reply.AttachmentLayout = "carousel";
        }