app/controllers/publications_controller.rb
def associate_authors
    publication = @publication
    projects = publication.projects
    projects = current_person.projects if projects.empty?
    association = {}
    publication.publication_authors.each do |author|
      unless author.person
        matches = []
        #Get author by last name
        last_name_matches = Person.find_all_by_last_name(author.last_name)
        matches = last_name_matches
        #If no results, try searching by normalised name, taken from grouped_pagination.rb
        if matches.size < 1
          text = author.last_name
          #handle the characters that can't be handled through normalization
          %w[ØO].each do |s|
            text.gsub!(/[#{s[0..-2]}]/, s[-1..-1])
          end

          codepoints = text.mb_chars.normalize(:d).split(//u)
          ascii=codepoints.map(&:to_s).reject { |e| e.length > 1 }.join

          last_name_matches = Person.find_all_by_last_name(ascii)
          matches = last_name_matches
        end

        #If more than one result, filter by project
        if matches.size > 1
          project_matches = matches.select { |p| p.member_of?(projects) }
          if project_matches.size >= 1 #use this result unless it resulted in no matches
            matches = project_matches
          end
        end

        #If more than one result, filter by first initial
        if matches.size > 1
          first_and_last_name_matches = matches.select { |p| p.first_name.at(0).upcase == author.first_name.at(0).upcase }
          if first_and_last_name_matches.size >= 1 #use this result unless it resulted in no matches
            matches = first_and_last_name_matches
          end
        end

        #Take the first match as the guess
        association[author.id] = matches.first
      else
        association[author.id] = author.person
      end
    end
    
    @author_associations = association
  end
#Try and relate non_seek_authors to people in SEEK based on name and project
Try and relate non_seek_authors to people in SEEK based on name and project
Try and relate non_seek_authors to people in SEEK based on name and project
def associate_authors
    publication = @publication
    projects = publication.projects
    projects = current_person.projects if projects.empty?
    association = {}
    publication.publication_authors.each do |author|
      unless author.person
        matches = []
        last_name_matches = Person.find_all_by_last_name(author.last_name)
        matches = last_name_matches
        if matches.size < 1
          text = author.last_name
          %w[ØO].each do |s|
            text.gsub!(/[#{s[0..-2]}]/, s[-1..-1])
          end
          codepoints = text.mb_chars.normalize(:d).split(//u)
          ascii=codepoints.map(&:to_s).reject { |e| e.length > 1 }.join
          last_name_matches = Person.find_all_by_last_name(ascii)
          matches = last_name_matches
        end
        if matches.size > 1
          project_matches = matches.select { |p| p.member_of?(projects) }
          if project_matches.size >= 1 
            matches = project_matches
          end
        end
        if matches.size > 1
          first_and_last_name_matches = matches.select { |p| p.first_name.at(0).upcase == author.first_name.at(0).upcase }
          if first_and_last_name_matches.size >= 1 
            matches = first_and_last_name_matches
          end
        end
        association[author.id] = matches.first
      else
        association[author.id] = author.person
      end
    end
    @author_associations = association
  end
def associate_authors publication = @publication projects = publication . projects projects = current_person . projects if projects . empty? association = { } publication . publication_authors . each do | author | unless author . person matches = [ ] last_name_matches = Person . find_all_by_last_name ( author . last_name ) matches = last_name_matches if matches . size < 1 text = author . last_name %w[ ØO] . e ach  o  s | text . gsub! ( / [ #{ s [ 0 .. - 2 ] } ] / , s [ - 1 .. - 1 ] ) end codepoints = text . mb_chars . normalize ( :d ) . split ( / /u ) ascii = codepoints . map ( & :to_s ) . reject { | e | e . length > 1 } . join last_name_matches = Person . find_all_by_last_name ( ascii ) matches = last_name_matches end if matches . size > 1 project_matches = matches . select { | p | p . member_of? ( projects ) } if project_matches . size >= 1 matches = project_matches end end if matches . size > 1 first_and_last_name_matches = matches . select { | p | p . first_name . at ( 0 ) . upcase == author . first_name . at ( 0 ) . upcase } if first_and_last_name_matches . size >= 1 matches = first_and_last_name_matches end end association [ author . id ] = matches . first else association [ author . id ] = author . person end end @author_associations = association end
Try and relate non_seek_authors to people in SEEK based on name and project
Try and relate non_seek_authors to people in SEEK based on name and project
#Get author by last name #If no results, try searching by normalised name, taken from grouped_pagination.rb #handle the characters that can't be handled through normalization #If more than one result, filter by project #use this result unless it resulted in no matches #If more than one result, filter by first initial #use this result unless it resulted in no matches #Take the first match as the guess