Beispiel #1
0
        public async Task <IActionResult> AuthorSearch(AuthorSearchRequestViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var authorSearchRequest = viewModel.AuthorSearchRequest;

            var organizationAlternativeNames = OrganizationProvider.GetAlternativeNames(authorSearchRequest.Organization);

            var possibleOrganizations = new List <string>();

            if (!string.IsNullOrEmpty(authorSearchRequest.Organization))
            {
                possibleOrganizations.Add(authorSearchRequest.Organization);
                possibleOrganizations.AddRange(organizationAlternativeNames);
            }

            var profiles = new List <AuthorSearchResult>(await PageParser.GetProfilesFromAuthorSearch(authorSearchRequest.NameSurname, authorSearchRequest.NumberOfRecords, possibleOrganizations));

            IEnumerable <AuthorSearchResult> orderedProfiles = new List <AuthorSearchResult>();

            if (!string.IsNullOrEmpty(authorSearchRequest.Keywords))
            {
                var correlationProfiles = new Dictionary <AuthorSearchResult, double>();

                var lsa          = new LSA(authorSearchRequest.Keywords, profiles.Select(a => string.Join("; ", a.Publications.Select(p => p.Name))));
                var correlations = new List <CorrelationItem>(lsa.GetCorrelations());
                for (var i = 0; i < profiles.Count(); i++)
                {
                    correlationProfiles.Add(profiles[i], correlations[i].Value);
                }

                var orderedCorrelationProfiles = correlationProfiles.OrderByDescending(k => k.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
                orderedProfiles = orderedCorrelationProfiles.Keys;
            }
            else
            {
                orderedProfiles = profiles.OrderByDescending(p => p.HIndex);
            }

            return(View("AuthorSearchResults", new AuthorSearchResultsViewModel
            {
                Authors = orderedProfiles,
                PublicationActivity = viewModel.PublicationActivity,
                IsNum1 = viewModel.IsNum1,
                IsNum2 = viewModel.IsNum2
            }));
        }
Beispiel #2
0
        public IActionResult AuthorSearchWithPublicationParameters(PublicationActivityIndexViewModel publicationViewModel, bool isNum1, bool isNum2)
        {
            var profile = ViewBag.Profile as Profile;

            var viewModel = new AuthorSearchRequestViewModel
            {
                AuthorSearchRequest = new AuthorSearchRequest
                {
                    NameSurname     = string.Format("{0} {1}", profile.FirstName, profile.LastName),
                    NumberOfRecords = 10
                },
                PublicationActivity = publicationViewModel.PublicationActivity,
                IsNum1 = isNum1,
                IsNum2 = isNum2
            };

            return(View("AuthorSearch", viewModel));
        }