public FilterSettings GetRequirements(NodeLUISPhoneDialog.EIntents intent) { FilterSettings returnVal = new FilterSettings(); if (intent == NodeLUISPhoneDialog.EIntents.Newest) { if (DateThreshold == new DateTime(1980, 1, 1)) { return(returnVal); } returnVal.IsDate = returnVal.FiltersSet = true; returnVal.DateThreshold = DateThreshold; return(returnVal); } if ((intent == NodeLUISPhoneDialog.EIntents.OS) || (intent == NodeLUISPhoneDialog.EIntents.Brand) || (intent == NodeLUISPhoneDialog.EIntents.Color)) { returnVal.FiltersSet = true; returnVal.Enumerated = StrKeyWords; return(returnVal); } if (intent == NodeLUISPhoneDialog.EIntents.Small) { returnVal.FiltersSet = !(returnVal.Desc = desc); } if (Threshold != -1) { returnVal.FiltersSet = true; returnVal.Threshold = Threshold; } return(returnVal); }
public bool KnocksSomeButNotAll(NodeLUISPhoneDialog.EIntents desiredFeature) { Dictionary <NodeLUISPhoneDialog.EIntents, NumberOfDifferent> enumerated = new Dictionary <NodeLUISPhoneDialog.EIntents, NumberOfDifferent>() { { NodeLUISPhoneDialog.EIntents.Color, () => handSets.GetBagColors().Count }, { NodeLUISPhoneDialog.EIntents.Brand, () => handSets.GetBagBrands().Count }, { NodeLUISPhoneDialog.EIntents.OS, () => handSets.GetBagOSes().Count } }; Predicate <HandSetFeatures> predicate; int count = handSets.BagCount(); int knockOutNumber; if (booleanFilters.TryGetValue(desiredFeature, out predicate)) // It's boolean { knockOutNumber = handSets.KnockOutNumber(predicate); return((knockOutNumber != count) && (knockOutNumber != 0)); } else if (intentFilters.TryGetValue(desiredFeature, out predicate)) { if (!enumerated.ContainsKey(desiredFeature)) { double highStandardThreshold; intent = desiredFeature; highStandardThreshold = handSets.GetHighStandardThreshold(this, getters[desiredFeature]); if (desiredFeature == NodeLUISPhoneDialog.EIntents.Newest) { DateThreshold = new DateTime((long)highStandardThreshold); } else { Threshold = highStandardThreshold; } knockOutNumber = handSets.KnockOutNumber(predicate); return((knockOutNumber != count) && (knockOutNumber != 0)); } else { return((enumerated[desiredFeature])() != 1); } } throw new Exception("Error...received a feature I don't know about:" + desiredFeature.ToString()); }
public void SetNewFreq(NodeLUISPhoneDialog.EIntents feature, StringBuilder debug) { string englishDesc; int freq; for (int i = 0; i < ranking.Count; ++i) { debug.Append(this.ranking[i].Item1 + " ==> "); debug.Append($"name: {ranking[i].Item1}, description : {ranking[i].Item2}"); debug.Append("\r\n"); } if (!englishDescriptions.TryGetValue(feature, out englishDesc)) { return; } englishDesc = englishDescriptions[feature]; freq = numberOfHits[englishDesc]; numberOfHits[englishDesc] = ++freq; MongoDBAccess.Instance.SetFeatureFrequency(englishDescriptions[feature], freq); ranking.Sort((x, y) => - Math.Sign(x.Item3 - y.Item3)); }
private void ExtractEntityInfo(NodeLUISPhoneDialog.EIntents intent, LuisResult result) { switch (intent) { case NodeLUISPhoneDialog.EIntents.BatteryLife: GetBatteryLifeComposedEntityData(result); break; case NodeLUISPhoneDialog.EIntents.Brand: break; case NodeLUISPhoneDialog.EIntents.Camera: GetCameraCompositeEntityData(result); break; case NodeLUISPhoneDialog.EIntents.HighResDisplay: GetHighResDisplayCompositeData(result); break; case NodeLUISPhoneDialog.EIntents.LargeStorage: GetMemoryCompositeEntityData(result); break; case NodeLUISPhoneDialog.EIntents.OS: break; case NodeLUISPhoneDialog.EIntents.ScreenSize: GetScreenSizeCompositeEntityData(result); break; case NodeLUISPhoneDialog.EIntents.Small: break; case NodeLUISPhoneDialog.EIntents.Weight: GetWeightCompositeEntity(result); break; case NodeLUISPhoneDialog.EIntents.Color: break; case NodeLUISPhoneDialog.EIntents.Newest: GetDateThreshold(result); break; case NodeLUISPhoneDialog.EIntents.BandWidth: case NodeLUISPhoneDialog.EIntents.DualCamera: case NodeLUISPhoneDialog.EIntents.DualSIM: case NodeLUISPhoneDialog.EIntents.ExpandableMemory: case NodeLUISPhoneDialog.EIntents.FMRadio: case NodeLUISPhoneDialog.EIntents.FaceID: case NodeLUISPhoneDialog.EIntents.FeaturePhone: case NodeLUISPhoneDialog.EIntents.GPS: case NodeLUISPhoneDialog.EIntents.HDVoice: case NodeLUISPhoneDialog.EIntents.SecondaryCamera: case NodeLUISPhoneDialog.EIntents.WaterResist: case NodeLUISPhoneDialog.EIntents.WiFi: break; default: break; } }
public KnockOutIntent(NodeLUISPhoneDialog.EIntents a, int b) { intent = a; numberOfKnockOuts = b; }
public int DecodeIntent(NodeLUISPhoneDialog.EIntents intent2Decode, LuisResult result, System.Text.StringBuilder stringDeDebug = null) { int handSetsLeft; Predicate <HandSetFeatures> predicate; intent = intent2Decode; if (result != null) { Threshold = -1; DateThreshold = new DateTime(1980, 1, 1); ExtractEntityInfo(intent2Decode, result); } intents2Exclude.Add(intent2Decode); if (intentFilters.TryGetValue(intent2Decode, out predicate)) // it is numeric or date or string { if ((intent2Decode == NodeLUISPhoneDialog.EIntents.Color) || (intent2Decode == NodeLUISPhoneDialog.EIntents.OS) || (intent2Decode == NodeLUISPhoneDialog.EIntents.Brand)) // strings, enumerated { if ((StrKeyWords == null) || (StrKeyWords.Count == 0)) { throw new Exception("Error...Either color, brand or OS selected and no string was supplied"); } if (handSets.KnockOutNumber(predicate) == handSets.BagCount()) { return(0); } if (!FeatureOrSmartPhoneDecision && handSets.TooManyFeaturePhones(predicate)) { return(-1); } handSets.EliminateFromBag(predicate); return(handSets.BagCount()); } else if ((Threshold != -1) || (DateThreshold != new DateTime(1980, 1, 1))) { if (stringDeDebug != null) { stringDeDebug.Append($" The threshold extracted is : {Threshold}"); } if (handSets.KnockOutNumber(predicate) == handSets.BagCount()) { return(0); } if (!FeatureOrSmartPhoneDecision && handSets.TooManyFeaturePhones(predicate)) { return(-1); } handSets.EliminateFromBag(predicate); return(handSets.BagCount()); } else // Subs said he wants the best of a certain feature without specifying a value { if (NodeLUISPhoneDialog.EIntents.Newest == intent2Decode) { DateThreshold = new DateTime((long)handSets.GetHighStandardThreshold(this, getters[intent2Decode])); } else { Threshold = handSets.GetHighStandardThreshold(this, getters[intent2Decode]); } if (handSets.KnockOutNumber(predicate) == handSets.BagCount()) { return(0); } handSetsLeft = handSets.SortAndGetTop(this, getters[intent2Decode]); if (handSetsLeft == 0) { return(0); } if (stringDeDebug != null) { stringDeDebug.Append("handSetsLeft = " + handSetsLeft); } if (!FeatureOrSmartPhoneDecision && handSets.TooManyFeaturePhones(predicate, handSetsLeft, stringDeDebug)) { return(-1); } handSets.removeAllButTop(handSetsLeft); handSets.EliminateFromBag(predicate); return(handSetsLeft); } } /*** still here ? Boolean situation ****/ if (booleanFilters.TryGetValue(intent2Decode, out predicate)) { if (handSets.BagCount() == handSets.KnockOutNumber(predicate)) { return(0); } if ((intent2Decode != NodeLUISPhoneDialog.EIntents.SmartPhone) && (intent2Decode != NodeLUISPhoneDialog.EIntents.FeaturePhone) && !FeatureOrSmartPhoneDecision && handSets.TooManyFeaturePhones(predicate)) { return(-1); } handSets.EliminateFromBag(predicate); return(handSets.BagCount()); } throw new Exception("IntentDecoder : Error...Intent not recongized"); }
public void ExcludeThis(NodeLUISPhoneDialog.EIntents intentFeature2Exclude) { intents2Exclude.Add(intentFeature2Exclude); }