示例#1
0
        private Theme setTopFive(List <string> termsList, Theme thema)
        {
            string topPersons                  = "";
            string topOrganisations            = "";
            Dictionary <Person, int> mapPerson = new Dictionary <Person, int>();
            Dictionary <string, int> mapOrg    = new Dictionary <string, int>();
            IEnumerable <Person>     personen  = subjRepo.GetPersonen();

            foreach (Person p in personen)
            {
                int totalcounter         = 0;
                IEnumerable <Feed> feeds = feedRepo.ReadPersonFeeds(p.Full_Name);
                foreach (Feed f in feeds)
                {
                    totalcounter = totalcounter + f.GetWords().Intersect(termsList).Count();
                }
                mapPerson.Add(p, totalcounter);
            }
            var myList = mapPerson.ToList();

            myList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            foreach (KeyValuePair <Person, int> p in myList)
            {
                if (mapOrg.ContainsKey(p.Key.Organisation))
                {
                    int count;
                    mapOrg.TryGetValue(p.Key.Organisation, out count);
                    mapOrg[p.Key.Organisation] = count + p.Value;
                }
                else
                {
                    mapOrg.Add(p.Key.Organisation, p.Value);
                }
            }
            var myList2 = mapOrg.ToList();

            myList2.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            for (int i = 0; i < 5; i++)
            {
                topPersons       = topPersons + myList.ElementAt(i).Key.Full_Name + ',';
                topOrganisations = topOrganisations + myList2.ElementAt(i).Key + ',';
            }
            topPersons             = topPersons.Remove(topPersons.Length - 1);
            topOrganisations       = topOrganisations.Remove(topOrganisations.Length - 1);
            thema.TopPersons       = topPersons;
            thema.TopOrganisations = topOrganisations;
            return(thema);
        }
示例#2
0
 public IEnumerable <Person> GetPersonen()
 {
     return(repo.GetPersonen());
 }