<commit_before><%
  new_name = @name_change.new_clone
  old_name = @name_change.old_clone
  new_desc = @desc_change.new_clone
  old_desc = @desc_change.old_clone

  watching = @user.watching?(new_name)
  is_now = :email_field_is_now.l

  # Why is this user being notified?  If the base Name changed, then look at
  # all the NameDescriptions, else only need to look at the NameDescription
  # that actually changed.  If notifiable for multiple reasons, choose the
  # least restrictive -- i.e. 'all' first, then admin, editor, author, and
  # lastly reviewer.
  email_type = if @user.email_names_all
    "all"
  elsif @user.watching?(new_name)
    "interest"
  elsif !old_name || new_name.version != old_name.version
    @user.email_names_editor   && new_name.descriptions.any? {|d| d.editor?(@user)} ? "editor"   :
    @user.email_names_author   && new_name.descriptions.any? {|d| d.author?(@user)} ? "author"   :
    @user.email_names_admin    && new_name.descriptions.any? {|d| d.is_admin?(@user)}  ? "admin"    :
    @user.email_names_reviewer && new_name.descriptions.any? {|d| d.reviewer == @user} ? "reviewer" : nil
  elsif new_desc
    @user.email_names_editor   && new_desc.editor?(@user) ? "editor"   :
    @user.email_names_author   && new_desc.author?(@user) ? "author"   :
    @user.email_names_admin    && new_desc.is_admin?(@user)  ? "admin"    :
    @user.email_names_reviewer && new_desc.reviewer == @user ? "reviewer" : nil
  else
    nil # ???
  end

  fields = ""
  fields += "*#{:Time.l}:* #{@time.email_time}\n"
  fields += "*#{:By.l}:* #{@sender.legal_name} (#{@sender.login})\n" if @sender

  one_liners = ""
  many_liners = []
  if old_name
    intro = :email_object_change_intro.l(
      type: :name,
      name: "#{old_name.display_name} (#{new_name.id})"
    )

    new_spell = new_name.correct_spelling ? new_name.correct_spelling.display_name : "--"
    license   = new_desc&.license : nil

    one_liners += "*#{:Name.l} #{is_now}:* #{new_name.real_text_name}\n" if new_name.real_text_name != old_name.real_text_name
    one_liners += "*#{:Authority.l} #{is_now}:* #{new_name.author}\n"   if new_name.author     != old_name.author
    one_liners += "*#{:Citation.l} #{is_now}:* #{new_name.citation}\n"  if new_name.citation   != old_name.citation
    one_liners += "*#{:Rank.l} #{is_now}:* #{new_name.rank}\n"          if new_name.rank       != old_name.rank
    one_liners += "*#{:License.l} #{is_now}:* #{license.display_name}\n" if license && new_desc&.license_id != old_desc&.license_id
    one_liners += "*#{:Reviewed.l} #{is_now}:* #{@review_status}\n"      if @review_status       != "no_change"
    one_liners += "*#{:Name.l} #{is_now}:* #{:Deprecated.l}\n"           if new_name.deprecated && !old_name.deprecated
    one_liners += "*#{:Status.l} #{is_now}:* #{:Accepted.l}\n"       if !new_name.deprecated && old_name.deprecated
    one_liners += "*#{:Status.l} #{is_now}:* #{:Misspelled.l}\n"     if !new_name.correct_spelling_id && !!old_name.correct_spelling_id
    one_liners += "*#{:Status.l} #{is_now}:* #{:Not_misspelled.l}\n" if !!new_name.correct_spelling_id && !old_name.correct_spelling_id
    one_liners += "*#{:Correct_spelling.l} #{is_now}:* #{new_spell} (#{new_name.correct_spelling_id}, #{old_name.correct_spelling_id})\n" if new_name.correct_spelling_id != old_name.correct_spelling_id

    if new_desc
      NameDescription.all_note_fields.each do |field|
        old_val = old_desc.send(field) rescue nil
        new_val = new_desc.send(field)
        many_liners.push([("form_names_" + field.to_s).to_sym.t, new_val]) if new_val != old_val
      end
    end
  else
    intro = :email_object_new_intro.l(
      type: :name,
      name: "#{new_name.display_name} (#{new_name.id})"
    )
  end

  handy_links = :email_handy_links.l
  if email_type
    tag = :"email_object_change_reason_#{email_type}".to_sym<commit_msg>Oops.<commit_after><%
  new_name = @name_change.new_clone
  old_name = @name_change.old_clone
  new_desc = @desc_change.new_clone
  old_desc = @desc_change.old_clone

  watching = @user.watching?(new_name)
  is_now = :email_field_is_now.l

  # Why is this user being notified?  If the base Name changed, then look at
  # all the NameDescriptions, else only need to look at the NameDescription
  # that actually changed.  If notifiable for multiple reasons, choose the
  # least restrictive -- i.e. 'all' first, then admin, editor, author, and
  # lastly reviewer.
  email_type = if @user.email_names_all
    "all"
  elsif @user.watching?(new_name)
    "interest"
  elsif !old_name || new_name.version != old_name.version
    @user.email_names_editor   && new_name.descriptions.any? {|d| d.editor?(@user)} ? "editor"   :
    @user.email_names_author   && new_name.descriptions.any? {|d| d.author?(@user)} ? "author"   :
    @user.email_names_admin    && new_name.descriptions.any? {|d| d.is_admin?(@user)}  ? "admin"    :
    @user.email_names_reviewer && new_name.descriptions.any? {|d| d.reviewer == @user} ? "reviewer" : nil
  elsif new_desc
    @user.email_names_editor   && new_desc.editor?(@user) ? "editor"   :
    @user.email_names_author   && new_desc.author?(@user) ? "author"   :
    @user.email_names_admin    && new_desc.is_admin?(@user)  ? "admin"    :
    @user.email_names_reviewer && new_desc.reviewer == @user ? "reviewer" : nil
  else
    nil # ???
  end

  fields = ""
  fields += "*#{:Time.l}:* #{@time.email_time}\n"
  fields += "*#{:By.l}:* #{@sender.legal_name} (#{@sender.login})\n" if @sender

  one_liners = ""
  many_liners = []
  if old_name
    intro = :email_object_change_intro.l(
      type: :name,
      name: "#{old_name.display_name} (#{new_name.id})"
    )

    new_spell = new_name.correct_spelling ? new_name.correct_spelling.display_name : "--"
    license   = new_desc&.license

    one_liners += "*#{:Name.l} #{is_now}:* #{new_name.real_text_name}\n" if new_name.real_text_name != old_name.real_text_name
    one_liners += "*#{:Authority.l} #{is_now}:* #{new_name.author}\n"   if new_name.author     != old_name.author
    one_liners += "*#{:Citation.l} #{is_now}:* #{new_name.citation}\n"  if new_name.citation   != old_name.citation
    one_liners += "*#{:Rank.l} #{is_now}:* #{new_name.rank}\n"          if new_name.rank       != old_name.rank
    one_liners += "*#{:License.l} #{is_now}:* #{license.display_name}\n" if license && new_desc&.license_id != old_desc&.license_id
    one_liners += "*#{:Reviewed.l} #{is_now}:* #{@review_status}\n"      if @review_status       != "no_change"
    one_liners += "*#{:Name.l} #{is_now}:* #{:Deprecated.l}\n"           if new_name.deprecated && !old_name.deprecated
    one_liners += "*#{:Status.l} #{is_now}:* #{:Accepted.l}\n"       if !new_name.deprecated && old_name.deprecated
    one_liners += "*#{:Status.l} #{is_now}:* #{:Misspelled.l}\n"     if !new_name.correct_spelling_id && !!old_name.correct_spelling_id
    one_liners += "*#{:Status.l} #{is_now}:* #{:Not_misspelled.l}\n" if !!new_name.correct_spelling_id && !old_name.correct_spelling_id
    one_liners += "*#{:Correct_spelling.l} #{is_now}:* #{new_spell} (#{new_name.correct_spelling_id}, #{old_name.correct_spelling_id})\n" if new_name.correct_spelling_id != old_name.correct_spelling_id

    if new_desc
      NameDescription.all_note_fields.each do |field|
        old_val = old_desc.send(field) rescue nil
        new_val = new_desc.send(field)
        many_liners.push([("form_names_" + field.to_s).to_sym.t, new_val]) if new_val != old_val
      end
    end
  else
    intro = :email_object_new_intro.l(
      type: :name,
      name: "#{new_name.display_name} (#{new_name.id})"
    )
  end

  handy_links = :email_handy_links.l
  if email_type
    tag = :"email_object_change_reason_#{email_type}".to_sym
{'fraction_non_alphanumeric': 0.16507362438646345, 'fraction_numerical': 0.0, 'mean_word_length': 3.8454317897371713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '401131', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2929, 'n_words': 504}