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); } } }
public static string JsonifyEpistemicStateInitiation(EpistemicState collections) { return string.Format("{{{0}}}", string.Join(", ", collections.GetAllConcepts().Select(JsonifyConceptDefinitions) .ToArray())); }