Esempio n. 1
0
        public string emitNewFact(ILambdaContext context, FactResource resource, String person, Dictionary <string, List <int> > previousFactsEmitted, bool withPreface, ref String personUsed, ref int factIndex)
        {
            Random r   = new Random();
            var    log = context.Logger;
            int    nextRandom;
            int    value = r.Next(resource.Facts.Count);

            personUsed = resource.Facts.Keys.ElementAt(value);
            int numberOfItems = resource.Facts.ElementAt(value).Value.Count;

            if (person != null && person.Length > 0)
            {
                personUsed = person;
                person     = person.ToLower();
                log.LogLine($"emitting a fact for" + person);
                if (resource.Facts.ContainsKey(person))
                {
                    log.LogLine(resource.Facts.Keys.ToString());
                    nextRandom = r.Next(resource.Facts[person].Count);
                    if (previousFactsEmitted.ContainsKey(person))
                    {
                        List <int> factsAlreadyUsed = previousFactsEmitted[person];
                        int        iter             = 0;
                        if (!factsAlreadyUsed.Contains(nextRandom))
                        {
                            log.LogLine($"This was a unique fact - using it!");
                        }
                        while (factsAlreadyUsed.Contains(nextRandom))
                        {
                            log.LogLine($"Getting another fact because that one was already used.");
                            iter++;
                            nextRandom = r.Next(resource.Facts[person].Count);
                            if (iter >= 7)
                            {
                                break;
                            }
                        }
                    }
                    factIndex = nextRandom;
                    return(resource.Facts[person][nextRandom]);
                }
                else
                {
                    return("Sorry I don't know who " + person + " is, but here is a fact." +
                           resource.Facts.ElementAt(value).Value[r.Next(numberOfItems)]);
                }
            }

            nextRandom = r.Next(numberOfItems);
            factIndex  = nextRandom;
            if (withPreface)
            {
                return(resource.GetFactMessage +
                       resource.Facts.ElementAt(value).Value[r.Next(numberOfItems)]);
            }
            return(resource.Facts.ElementAt(value).Value[r.Next(numberOfItems)]);
        }
Esempio n. 2
0
        public List <FactResource> GetResources()
        {
            List <FactResource> resources    = new List <FactResource>();
            FactResource        enUSResource = new FactResource("en-US");

            enUSResource.SkillName      = "Schwartz Family Facts";
            enUSResource.GetFactMessage = "Here's your Schwartz family fact: ";
            enUSResource.HelpMessage    = "You can say tell me a Schwartz fact, or, you can say exit... What can I help you with?";
            enUSResource.HelpReprompt   = "What can I help you with?";
            enUSResource.StopMessage    = "Goodbye!";
            Dictionary <string, List <string> > facts = new Dictionary <string, List <string> >();

            facts.Add("maya", new List <string>()
            {
                "Maya is 9 years old.",
                "Maya is a great reader - she can read up to 20 books per day",
                "Maya Maya bo baya banana fana fo faya, mee moe Maya - Maya",
                "Maya's birthday is August 29 2009 at 5:04 am",
                "Maya is beautiful",
                "Maya is a jokester ",
                "Maya is taking piano lessons",
                "Maya is in the 4th grade at Herod elementary",
                "Maya is a soccer player she has played soccer for several years."
            });
            facts.Add("coco", new List <string>()
            {
                "Coco likes to bite people",
                "Coco is a fast racer - he likes to race in the back yard",
                "Coco loves to sleep in his cage",
                "Coco is a Maltipoo and weighs 6 pounds"
            });
            facts.Add("lily", new List <string>()
            {
                "Lily is 6 years old.",
                "Lily's best friend is Liya",
                "Lily is a beautiful dancer.  She can dance hip hop an ballet.",
                "Lily likes to wear her hair in a bun",
                "Lily's birthday is April 30 2012",
                "Lily is friendly and funny!",
                "Lily is in 2nd grade at Herod elementary",
                "Lily has an ice cream cone bike!  I wish I had one of those!"
            });
            facts.Add("carlos", new List <string>()
            {
                "Carlos is 2 years old",
                "Carlos loves Cars 3.  He loves to play cars and race on the track.",
                "Carlos's favorite character is Miss Fritter",
                "Carlos's favorite song is Mika Moka",
                "Carlos is a grump grump",
                "Carlos likes to do interactive performances of Cars 3",
                "Carlos Carlos bo Barlos banana fana fo farlos, me my mo Marlos, Carlos",
                "Carlos's birthday is February 14 also known as valentines day",
                "Carlos is a cookie monster.  He eats all the cookies and all the M&Ms"
            });
            facts.Add("leslie", new List <string>()
            {
                "Leslie is cray cray",
                "Leslie is pretty",
                "Leslie has written 2 books.  They are called Fuego and Nightbloom and Cenote",
            });
            facts.Add("mommy", new List <string>()
            {
                "Mommy is nice",
            });
            facts.Add("daddy", new List <string>()
            {
                "Daddy is the best!",
                "Daddy's birthday is January 19, 1979",
                "Daddy is from Cleveland Ohio",
            });
            facts.Add("cici", new List <string>()
            {
                "Cici cici bo bici banana fana fo fici, mee my mo Mici, Cici",
                "Cici is a grandma!"
            });
            facts.Add("poppop", new List <string>()
            {
                "Pop pop is a grandpa!",
                "Pop pop's birthday is January second"
            });
            facts.Add("grandparents", new List <string>()
            {
                "Michael's parents are Kenny and Lucy also known as Pop-pop and Cici",
                "Leslie's parents are David and Amelia, also known as Pawpaw and Nana"
            });
            enUSResource.Facts = facts;
            resources.Add(enUSResource);
            return(resources);
        }