Ejemplo n.º 1
0
        // return the best n top matches for person
        public Dictionary <string, double> topMatches(Dictionary <string, Dictionary <string, double> > data,
                                                      string person, delegateFunc similarity, int n = 5)
        {
            Dictionary <string, double> scores = new Dictionary <string, double>();

            foreach (var item in data)
            {
                if (item.Key != person)
                {
                    scores[item.Key] = similarity(data, person, item.Key);
                }
            }

            // return sorted descending dictionary of recommendations
            return(scores.OrderByDescending(x => x.Value).Take(n).ToDictionary(x => x.Key, x => x.Value));
        }
Ejemplo n.º 2
0
        private IEnumerator _ShowForSeconds(float seconds, string text)
        {
            UpdateText(text);

            _textFade.FadeIn();

            yield return(new WaitForSeconds(seconds));

            _textFade.FadeOut();


            if (_callbackMethod != null)
            {
                _callbackMethod();
                _callbackMethod = null;
            }
        }
Ejemplo n.º 3
0
        // Gets recommendations for a person by using a weighted average of every other user's rankings
        public Dictionary <string, double> getRecommendations(Dictionary <string, Dictionary <string, double> > data,
                                                              string person, delegateFunc similarity)
        {
            double sim = 0;

            // to store sim * rating for all persons
            Dictionary <string, double> totals = new Dictionary <string, double>();

            //to store the sum of similarities
            Dictionary <string, double> simSum = new Dictionary <string, double>();

            // to store the recommended movies
            Dictionary <string, double> rankings = new Dictionary <string, double>();

            foreach (var pers in data)
            {
                if (pers.Key == person)
                {
                    continue;
                }
                sim = similarity(data, person, pers.Key);
                if (sim <= 0)
                {
                    continue;
                }
                foreach (var movie in data[pers.Key])
                {
                    if (!data[person].ContainsKey(movie.Key) || movie.Value == 0)
                    {
                        totals[movie.Key]  = 0;
                        totals[movie.Key] += movie.Value * sim;
                        simSum[movie.Key]  = 0;
                        simSum[movie.Key] += sim;
                    }
                }
            }

            foreach (var item in totals)
            {
                double ee = (item.Value / simSum.Where(x => x.Key == item.Key).FirstOrDefault().Value);
                rankings[item.Key] = ee;
            }

            // return sorted descending dictionary of recommendations
            return(rankings.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value));
        }
Ejemplo n.º 4
0
        public void Message(string msg, delegateFunc okFunc, delegateFunc cancelFunc)
        {
            CallOkFunc     = okFunc;
            CallCancelFunc = cancelFunc;

            Console.WriteLine("Message: " + msg + " (0: ok,  1: cancel)");

            string inputStr = Console.ReadLine();

            if (inputStr.Equals("0"))
            {
                CallOkFunc();
            }
            else
            {
                CallCancelFunc();
            }
        }
Ejemplo n.º 5
0
 public void ShowForSeconds(float seconds, string text, delegateFunc callback = null)
 {
     _callbackMethod = callback;
     StartCoroutine(_ShowForSeconds(seconds, text));
 }
Ejemplo n.º 6
0
 public ComposedMission Add(delegateFunc func)
 {
     funcList.Add(func);
     return(this);
 }
Ejemplo n.º 7
0
 //constructor
 public SingleMission(delegateFunc func, string name)
 {
     this.func = func;
     this.Name = name;
 }