public void LoadGlobals(JSONNode sheet) { // The globals sheet is a bit more intricate, we CAN have more presets or "pages" if you will of globals / default values. // First, lets iterate through the [headers] to find how many "preset-#" we have. JSONArray headers = sheet["headers"].AsArray; JSONArray datas = sheet["data"].AsArray; //Assigns the first (top-left) cell content, basically the property-header loopup to check on each data rows. string propertyHeader = headers[0]; for (int g = 1; g < headers.Count; g++) { string header = headers[g].AsDecodedURL(); GlobalsValuesDictionary globalValues = new GlobalsValuesDictionary(); foreach (JSONNode globalJSON in datas) { string strProp = globalJSON[propertyHeader].AsDecodedURL(); string strValue = globalJSON[header].AsDecodedURL(); GlobalProps globProp = strProp.AsEnum <GlobalProps>(); globalValues.AddOrSet(globProp, strValue); } _globalData.AddOrSet(header, globalValues); } }
//Allows a user to query the knowledge base and determines if a logical sentence entails the KB public bool checkEntailment(Sentence newSentence) { if (kBase.Count == 0) { return(true); } // if there are any new variables in the new sentence truthTable.GenerateTable(kBase, newSentence); kProps = truthTable.InvovledProps; List <bool[]> criticalVals = truthTable.valuesToMatch(true); for (int i = 0; i < criticalVals.Count; i++) { GlobalProps.setPropositions(criticalVals[i], kProps); if (newSentence.getValue() == false) { return(false); } } if (criticalVals.Count == 0) { return(false); } return(true); }
public float GetGlobalAsFloat(GlobalProps globalProp, float defaultValue = -1f, string preset = null) { string str = GetGlobalAsString(globalProp, preset); if (str == null) { return(defaultValue); } return(float.Parse(str)); }
public int GetGlobalAsInt(GlobalProps globalProp, int defaultValue = -1, string preset = null) { string str = GetGlobalAsString(globalProp, preset); if (str == null) { return(defaultValue); } return(int.Parse(str)); }
public bool GetGlobalAsBool(GlobalProps globalProp, bool defaultValue = false, string preset = null) { string str = GetGlobalAsString(globalProp, preset); if (str == null) { return(defaultValue); } str = str.Trim().ToLower(); return(str == "true" || str == "yes" || str == "y" || int.Parse(str) > 0); }
public string GetGlobalAsString(GlobalProps globalProp, string defaultValue = null, string preset = null) { if (preset == null) { preset = currentGlobalPreset; } if (!_globalData.ContainsKey(preset)) { Tracer.traceError("Incorrect currentGlobalPreset selected: " + preset + " try one of these: " + _globalData.Keys.ToArray().Join(", ")); return(defaultValue); } if (!_globalData[preset].ContainsKey(globalProp)) { Tracer.traceError("Missing global-property on global preset: " + globalProp + " on " + preset); return(defaultValue); } return(_globalData[preset][globalProp]); }
public static string GetString(this GlobalProps prop, string defaultValue = null, string preset = null) { return(DataManager.globals.GetGlobalAsString(prop, defaultValue, preset)); }
public static bool GetBool(this GlobalProps prop, bool defaultValue = false, string preset = null) { return(DataManager.globals.GetGlobalAsBool(prop, defaultValue, preset)); }
public static float GetFloat(this GlobalProps prop, float defaultValue = -1, string preset = null) { return(DataManager.globals.GetGlobalAsFloat(prop, defaultValue, preset)); }
public static int GetInt(this GlobalProps prop, int defaultValue = -1, string preset = null) { return(DataManager.globals.GetGlobalAsInt(prop, defaultValue, preset)); }