<commit_before>module SmartAnswer
  class RegisterABirthFlow < Flow
    def define
      content_id "bb68ca88-b56b-4df2-a33d-3aaec66a5098"
      name 'register-a-birth'
      status :published
      satisfies_need "101003"

      country_name_query = SmartAnswer::Calculators::CountryNameFormatter.new
      reg_data_query = SmartAnswer::Calculators::RegistrationsDataQuery.new
      translator_query = SmartAnswer::Calculators::TranslatorLinks.new
      exclude_countries = %w(holy-see british-antarctic-territory)

      # Q1
      country_select :country_of_birth?, exclude_countries: exclude_countries do
        save_input_as :country_of_birth

        calculate :registration_country do |response|
          reg_data_query.registration_country_slug(response)
        end

        calculate :registration_country_name_lowercase_prefix do
          country_name_query.definitive_article(registration_country)
        end

        define_predicate :country_has_no_embassy do |response|
          %w(iran syria yemen).include?(response)
        end

        next_node_if(:no_embassy_result, country_has_no_embassy)
        next_node_if(:commonwealth_result, reg_data_query.responded_with_commonwealth_country?)
        next_node(:who_has_british_nationality?)
      end

      # Q2
      multiple_choice :who_has_british_nationality? do
        option :mother
        option :father
        option :mother_and_father
        option :neither

        save_input_as :british_national_parent

        permitted_next_nodes = [
          :married_couple_or_civil_partnership?,
          :no_registration_result<commit_msg>Move responded_with_commonwealth_country? predicate<commit_after>module SmartAnswer
  class RegisterABirthFlow < Flow
    def define
      content_id "bb68ca88-b56b-4df2-a33d-3aaec66a5098"
      name 'register-a-birth'
      status :published
      satisfies_need "101003"

      country_name_query = SmartAnswer::Calculators::CountryNameFormatter.new
      reg_data_query = SmartAnswer::Calculators::RegistrationsDataQuery.new
      translator_query = SmartAnswer::Calculators::TranslatorLinks.new
      exclude_countries = %w(holy-see british-antarctic-territory)

      # Q1
      country_select :country_of_birth?, exclude_countries: exclude_countries do
        save_input_as :country_of_birth

        calculate :registration_country do |response|
          reg_data_query.registration_country_slug(response)
        end

        calculate :registration_country_name_lowercase_prefix do
          country_name_query.definitive_article(registration_country)
        end

        define_predicate :country_has_no_embassy do |response|
          %w(iran syria yemen).include?(response)
        end

        define_predicate :responded_with_commonwealth_country? do |response|
          Calculators::RegistrationsDataQuery::COMMONWEALTH_COUNTRIES.include?(response)
        end

        next_node_if(:no_embassy_result, country_has_no_embassy)
        next_node_if(:commonwealth_result, responded_with_commonwealth_country?)
        next_node(:who_has_british_nationality?)
      end

      # Q2
      multiple_choice :who_has_british_nationality? do
        option :mother
        option :father
        option :mother_and_father
        option :neither

        save_input_as :british_national_parent

        permitted_next_nodes = [
          :married_couple_or_civil_partnership?,
          :no_registration_result
{'fraction_non_alphanumeric': 0.05930232558139535, 'fraction_numerical': 0.014534883720930232, 'mean_word_length': 3.445736434108527, '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': '5205517', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1016, 'n_words': 155}