Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //I chose to write this as a console app because it was both simple (as in the exercise wouldn't get lost in the boilerplate of the project)
            // and because console apps can very practically be converted into azure web jobs, which would be a likely method to employ this code.

            if (args.Length < 1)
            {
                Console.WriteLine("You must pass the root service URL as a parameter to this exe");
            }
            else
            {
                string rootServiceURL                = args[0];
                SubstitutionController c             = new SubstitutionController();
                List <RxModel>         prescriptions = c.GetRxList(rootServiceURL + "prescriptions");
                //We may want to limit the number we process at any given time.
                //List<RxModel> subsetOfPrescriptions = prescriptions.GetRange(1, 10);
                List <RxUpdateModel> updates = c.GenerateRxSubstituionList(rootServiceURL, prescriptions);

                //convert the result set to a string
                string jsonResult = JsonConvert.SerializeObject(updates);

                //the secnario wasn't precisely clear how the output was to be formatted
                // (written to a file? submitted to another service?), so for now I'm outputting it to the console.
                Console.Write(jsonResult);
            }
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void TestGetRxList()
        {
            //set up
            SubstitutionController c = new SubstitutionController();
            string serviceURL        = "http://api-sandbox.pillpack.com/prescriptions";
            //execute
            List <RxModel> prescriptions = c.GetRxList(serviceURL);

            //test
            Assert.IsTrue(prescriptions.Count > 0);
        }
Exemplo n.º 3
0
        public void TestGetDrugList()
        {
            //set up
            SubstitutionController c = new SubstitutionController();
            string serviceURL        = "http://api-sandbox.pillpack.com/medications";
            string drugId            = "564aab6f3032360003010000"; // Bayer 10mg
            //execute
            List <DrugModel> drugs = c.GetDrugOptions(serviceURL, drugId);

            //test
            Assert.IsTrue(drugs.Count > 0);
        }
Exemplo n.º 4
0
        public void TestGenerateSubstitutionList()
        {
            //set up
            SubstitutionController c             = new SubstitutionController();
            string         serviceRootURL        = "http://api-sandbox.pillpack.com/";
            List <RxModel> prescriptions         = c.GetRxList(serviceRootURL + "prescriptions");
            List <RxModel> subsetOfPrescriptions = prescriptions.GetRange(1, 10); //for testing purposes, only do the first 10.
            //execute
            List <RxUpdateModel> updates = c.GenerateRxSubstituionList(serviceRootURL, subsetOfPrescriptions);

            //test
            Assert.IsTrue(updates.Count > 0);
        }
        public void AnalyzeAndLearn_TestDecisionTreeEvolutions_DecisionTreeChanged()
        {
            //ARRANGE
            //"C:\\Sysdev\\RNPC\\RNPC\\DTO\\Learning\\Resources\\DecisionTreeSubstitutions.xml";
            var controller = new SubstitutionController(new SubstitutionDocumentConverter(), new DecisionTreeFileController(), new SubstitutionMapper());
            MainDecisionTreeLearningStrategy strategy = new MainDecisionTreeLearningStrategy(controller, new DecisionTreeBuilder());

            var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid());

            var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent)
            {
                FileController      = new DecisionTreeFileController(),
                DecisionTreeBuilder = new DecisionTreeBuilder()
            };

            //Initial Action
            //Friendly Greeting
            Action greeting = new Action
            {
                EventType  = EventType.Interaction,
                ActionType = ActionType.Verbal,
                Intent     = Intent.Friendly,
                Message    = "Hi!",
                Target     = character.MyName,
                EventName  = "Greeting",
                Source     = "The Friend"
            };

            var reaction = new Reaction
            {
                Tone          = Tone.Neutral,
                Target        = greeting.Source,
                Intent        = Intent.Neutral,
                ActionType    = ActionType.Verbal,
                InitialEvent  = greeting,
                EventType     = EventType.Interaction,
                ReactionScore = 0,
                EventName     = "Greeting",
                Message       = "Hello.", //TODO: Randomize
                Source        = greeting.Target
            };

            character.MyMemory.AddActionToLongTermMemory(reaction);
            character.MyMemory.AddActionToLongTermMemory(reaction);
            character.MyMemory.AddActionToLongTermMemory(reaction);

            //ACT
            strategy.AnalyzeAndLearn(character);
            //ASSERT
        }
Exemplo n.º 6
0
        internal MainLearningMethod(IXmlFileController fileController, ITreeBuilder builder)
        {
            ActionLearningStrategy = new MainActionLearningStrategy();

            var controller = new SubstitutionController(new SubstitutionDocumentConverter(), fileController, new SubstitutionMapper());

            DecisionTreeLearningStrategy = new MainDecisionTreeLearningStrategy(controller, builder);
            DesireLearningStrategy       = new MainDesireLearningStrategy();
            EmotionLearningStrategy      = new MainEmotionLearningStrategy();

            MemoryLearningStrategy        = new MainMemoryLearningStrategy();
            OpinionLearningStrategy       = new MainOpinionLearningStrategy();
            PersonalValueLearningStrategy = new MainPersonalValueLearningStrategy(new PersonalValueAssociations());

            QualityLearningStrategy = new MainQualityLearningStrategy();
        }
        public void AnalyzeAndLearn_NoLearningDone_NoDecisionTreeChanged()
        {
            //ARRANGE
            //"C:\\Sysdev\\RNPC\\RNPC\\DTO\\Learning\\Resources\\DecisionTreeSubstitutions.xml";
            var controller = new SubstitutionController(new SubstitutionDocumentConverter(), new DecisionTreeFileController(), new SubstitutionMapper());
            MainDecisionTreeLearningStrategy strategy = new MainDecisionTreeLearningStrategy(controller, new DecisionTreeBuilder());

            var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid());

            var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent)
            {
                FileController      = new DecisionTreeFileController(),
                DecisionTreeBuilder = new DecisionTreeBuilder()
            };

            //ACT
            strategy.AnalyzeAndLearn(character);
            //ASSERT
            Assert.IsFalse(strategy.DecisionTreeEvolved);
        }