<commit_before><div class='speed-tag'>
  <% unless @edition.valid_as_draft? %>
    <div class='alert'>
      <strong>This edition cannot be converted to draft yet</strong>

      <ul>
        <% @edition.errors_as_draft.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <% unless @edition.document.document_sources.empty? %>
    <p>Document sources:</p>
    <ul>
      <% @edition.document.document_sources.each do |document_source| %>
        <li><%= link_to truncate(document_source.url, length: 90), document_source.url, title: document_source.url, target: '_new' %></li>
      <% end %>
    </ul>
  <% end %>


  <%= form_for [:admin, @edition], as: :edition, builder: Admin::EditionsHelper::EditionFormBuilder do |form| %>
    <%= form.label :organisation_ids, 'Organisations:' %>
    <%= form.select :organisation_ids, options_from_collection_for_select(Organisation.all, 'id', 'name', @edition.organisation_ids), {}, multiple: true, class: 'chzn-select', data: { placeholder: "Choose organisations which produced this document..." } %>
    <%= render partial: 'required_fields_for_imported_editions', locals: { form: form, edition: form.object } %>
    <% if @edition.can_be_associated_with_role_appointments? %>
      <div class="row-fluid">
        <h3>Ministers</h3>
        <% @edition.organisations.map(&:ministerial_role_appointments).flatten.each do |role_appointment| %>
          <% if role_appointment.current_at(@edition.first_published_at) %>
            <label class='checkbox'>
              <%= check_box_tag 'edition[role_appointment_ids][]', role_appointment.id, @edition.role_appointments.include?(role_appointment) %>
              <%= RoleAppointmentPresenter.new(role_appointment).person.name %>
              <span class='muted'><%= role_appointment(role_appointment) %></span>
            </label>
          <% end %>
        <% end %>
      </div>
    <% end %>
    <% if @edition.can_be_associated_with_ministers? %>
      <div class="row-fluid">
        <h3>Ministers</h3>
        <% @edition.organisations.map(&:ministerial_roles).flatten.each do |role| %>
          <label class='checkbox'>
            <%= check_box_tag 'edition[ministerial_role_ids][]', role.id, @edition.ministerial_roles.include?(role) %>
            <%= RolePresenter.new(role).current_person.name %>
            <span class='muted'><%= RolePresenter.new(role).name %></span>
          </label>
        <% end %>
      </div>
    <% end %>
    <% if @edition.can_be_related_to_policies? %>
      <div class="row-fluid">
        <h3>Related policies</h3>
        <% @edition.organisations.map(&:policies).flatten.uniq.each do |policy| %>
          <label class='checkbox'>
            <%= check_box_tag 'edition[related_document_ids][]', policy.document_id, @edition.related_documents.include?(policy.document) %>
            <%= policy.title %><br/>
          </label>
        <% end %>
      </div><commit_msg>Better duplication removal for policies while speed-tagging<commit_after><div class='speed-tag'>
  <% unless @edition.valid_as_draft? %>
    <div class='alert'>
      <strong>This edition cannot be converted to draft yet</strong>

      <ul>
        <% @edition.errors_as_draft.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <% unless @edition.document.document_sources.empty? %>
    <p>Document sources:</p>
    <ul>
      <% @edition.document.document_sources.each do |document_source| %>
        <li><%= link_to truncate(document_source.url, length: 90), document_source.url, title: document_source.url, target: '_new' %></li>
      <% end %>
    </ul>
  <% end %>


  <%= form_for [:admin, @edition], as: :edition, builder: Admin::EditionsHelper::EditionFormBuilder do |form| %>
    <%= form.label :organisation_ids, 'Organisations:' %>
    <%= form.select :organisation_ids, options_from_collection_for_select(Organisation.all, 'id', 'name', @edition.organisation_ids), {}, multiple: true, class: 'chzn-select', data: { placeholder: "Choose organisations which produced this document..." } %>
    <%= render partial: 'required_fields_for_imported_editions', locals: { form: form, edition: form.object } %>
    <% if @edition.can_be_associated_with_role_appointments? %>
      <div class="row-fluid">
        <h3>Ministers</h3>
        <% @edition.organisations.map(&:ministerial_role_appointments).flatten.each do |role_appointment| %>
          <% if role_appointment.current_at(@edition.first_published_at) %>
            <label class='checkbox'>
              <%= check_box_tag 'edition[role_appointment_ids][]', role_appointment.id, @edition.role_appointments.include?(role_appointment) %>
              <%= RoleAppointmentPresenter.new(role_appointment).person.name %>
              <span class='muted'><%= role_appointment(role_appointment) %></span>
            </label>
          <% end %>
        <% end %>
      </div>
    <% end %>
    <% if @edition.can_be_associated_with_ministers? %>
      <div class="row-fluid">
        <h3>Ministers</h3>
        <% @edition.organisations.map(&:ministerial_roles).flatten.each do |role| %>
          <label class='checkbox'>
            <%= check_box_tag 'edition[ministerial_role_ids][]', role.id, @edition.ministerial_roles.include?(role) %>
            <%= RolePresenter.new(role).current_person.name %>
            <span class='muted'><%= RolePresenter.new(role).name %></span>
          </label>
        <% end %>
      </div>
    <% end %>
    <% if @edition.can_be_related_to_policies? %>
      <div class="row-fluid">
        <h3>Related policies</h3>
        <% Policy.in_organisation(@edition.organisations).latest_edition.active.map do |policy| %>
          <label class='checkbox'>
            <%= check_box_tag 'edition[related_document_ids][]', policy.document_id, @edition.related_documents.include?(policy.document) %>
            <%= policy.title %><% if policy.topics.any? %>
            <span class="muted"><%= policy.topics.map(&:name).to_sentence%></span>
            <% end %>
          </label>
        <% end %>
      </div>
{'fraction_non_alphanumeric': 0.16631578947368422, 'fraction_numerical': 0.002591093117408907, 'mean_word_length': 3.128342245989305, 'pattern_counts': {'":': 0, '<': 153, '<?xml version=': 0, '>': 153, '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': '4936', 'n_tokens_mistral': 2107, 'n_tokens_neox': 1948, 'n_words': 320}