public void TestUpdate() { mock(); // retrieve a concept var yesL = model.GetConcept("posack", ConceptType.ACTION, ConceptMode.L); // set certainty value yesL.Certainty = 1.0; // retrive a relation var yesG = model.GetConcept("POSACK", ConceptType.ACTION, ConceptMode.G); var r = model.GetRelation(yesL, yesG); // set certainty value if (r != null) { r.Certainty = 1.0; } // for logging var json = Jsonifier.JsonifyUpdates(model, new[] { yesL }, new[] { r }); Debug.Log(json); // this would do the actual http request: need to pass two arrays for each model.UpdateEpisim(new[] { yesL }, new[] { r }); }
public void TestSideload() { mock(); // retrieve a concept var yesL = model.GetConcept("posack", ConceptType.ACTION, ConceptMode.L); // set certainty value yesL.Certainty = .99; // retrive a relation var yesG = model.GetConcept("POSACK", ConceptType.ACTION, ConceptMode.G); var r = model.GetRelation(yesL, yesG); // set certainty value if (r != null) { r.Certainty = 0.43; } // for logging var json = Jsonifier.JsonifyUpdates(model, new[] { yesL }, new[] { r }); Debug.Log(json); mock(); model.SideloadCertaintyState(json); }
public void UpdateEpisim(Concept[] updatedConcepts, Relation[] updatedRelations) { if (isConnected) { Post(EpisimUpdateRoute, Jsonifier.JsonifyUpdates(this, updatedConcepts, updatedRelations)); } }
public void TestUpdate2() { second_mock(); model.InitiateEpisim(); var json = Jsonifier.JsonifyEpistemicStateInitiation(model); Debug.Log(json); var conceptG = model.GetConcept("push", ConceptType.ACTION, ConceptMode.G); Debug.Log(conceptG); var conceptL = model.GetConcept("RIGHT", ConceptType.PROPERTY, ConceptMode.L); Debug.Log(conceptL); if (conceptG.Certainty < 0.5 || conceptL.Certainty < 0.5) { conceptG.Certainty = 0.5; conceptL.Certainty = 0.5; json = Jsonifier.JsonifyUpdates(model, new[] { conceptG, conceptL }, new Relation[] { }); Debug.Log(json); model.UpdateEpisim(new[] { conceptG, conceptL }, new Relation[] { }); } }
public void SaveUserModel(string userID) { List <Concept> stateConcepts = new List <Concept>(); List <Relation> stateRelations = new List <Relation>(); List <Concept> gestureConcepts = new List <Concept>(); List <Concept> linguisticConcepts = new List <Concept>(); if (state != null) { foreach (Concepts conceptsByMode in state.GetAllConcepts()) { if (conceptsByMode.GetConcepts().ContainsKey(ConceptMode.G)) { gestureConcepts = conceptsByMode.GetConcepts()[ConceptMode.G]; } if (conceptsByMode.GetConcepts().ContainsKey(ConceptMode.L)) { linguisticConcepts = conceptsByMode.GetConcepts()[ConceptMode.L]; } foreach (Concept gestureConcept in gestureConcepts) { if (!stateConcepts.Contains(gestureConcept)) { stateConcepts.Add(gestureConcept); foreach (Concept relatedConcept in state.GetRelated(gestureConcept)) { Relation relation = state.GetRelation(gestureConcept, relatedConcept); if (!stateRelations.Contains(relation)) { stateRelations.Add(relation); } } } } foreach (Concept linguisticConcept in linguisticConcepts) { if (!stateConcepts.Contains(linguisticConcept)) { stateConcepts.Add(linguisticConcept); foreach (Concept relatedConcept in state.GetRelated(linguisticConcept)) { Relation relation = state.GetRelation(linguisticConcept, relatedConcept); if (!stateRelations.Contains(relation)) { stateRelations.Add(relation); } } } } } string jsonifiedCertaintyState = Jsonifier.JsonifyUpdates(state, stateConcepts.ToArray(), stateRelations.ToArray()); Debug.Log(jsonifiedCertaintyState); using (StreamWriter sw = new StreamWriter(GetUserModelPath(userID))) { sw.Write(jsonifiedCertaintyState); } } }