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