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 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 TestSubgroup() { mock(); model.AddPropertyGroup(new PropertyGroup("SIZE", PropertyType.Ordinal)); model.AddPropertyGroup(new PropertyGroup("COLOR", PropertyType.Nominal)); Concept round = new Concept("round", ConceptType.PROPERTY, ConceptMode.L); Concept big = new Concept("big", ConceptType.PROPERTY, ConceptMode.L); big.SubgroupName = "SIZE"; Concept small = new Concept("small", ConceptType.PROPERTY, ConceptMode.L); small.SubgroupName = "SIZE"; Concept blue = new Concept("blue", ConceptType.PROPERTY, ConceptMode.L); blue.SubgroupName = "COLOR"; Concept red = new Concept("red", ConceptType.PROPERTY, ConceptMode.L); red.SubgroupName = "COLOR"; model.AddConcept(round); model.AddConcept(big); model.AddConcept(small); model.AddConcept(blue); model.AddConcept(red); var json = Jsonifier.JsonifyEpistemicStateInitiation(model); Debug.Log(json); model.InitiateEpisim(); }
public void UpdateEpisim(Concept[] updatedConcepts, Relation[] updatedRelations) { if (isConnected) { Post(EpisimUpdateRoute, Jsonifier.JsonifyUpdates(this, updatedConcepts, updatedRelations)); } }
public void Setup() { var innerJsonifier = new Jsonifier(); _jsonifier = Substitute.For <IJsonifier>(); _jsonifier .ParseJson <List <FetchedQuote> >(Arg.Any <string>()) .Returns(args => innerJsonifier.ParseJson <List <FetchedQuote> >((string)args[0])); _sut = new FetchHandler(_jsonifier); }
public void TestInit() { mock(); // for logging var json = Jsonifier.JsonifyEpistemicStateInitiation(model); Debug.Log(json); // this would do the actual http request model.InitiateEpisim(); }
public void TestActualModel() { model = EpistemicModel.initModel(); model.SetEpisimUrl("http://localhost:5000"); // var json = Jsonifier.JsonifyEpistemicState(model); // Debug.Log(json); model.InitiateEpisim(); var moveL = model.GetConcept("PUT", ConceptType.ACTION, ConceptMode.L); var pushL = model.GetConcept("PUSH", ConceptType.ACTION, ConceptMode.L); if ((moveL != null) && (pushL != null)) { moveL.Certainty = -1; pushL.Certainty = -1; var json = Jsonifier.JsonifyEpistemicStateInitiation(model); Debug.Log(json); model.UpdateEpisim(new[] { moveL, pushL }, new Relation[] { }); } }
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 InitiateEpisim() { Post(EpisimInitRoute, Jsonifier.JsonifyEpistemicStateInitiation(this)); }
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); } } }