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; }