<commit_before>module SmartAnswer
  class StatePensionThroughPartnerFlow < Flow
    def define
      content_id "42a41808-b338-4e4b-a703-47195982f4c8"
      name 'state-pension-through-partner'
      status :published
      satisfies_need "100578"

      # Q1
      multiple_choice :what_is_your_marital_status? do
        option :married
        option :widowed
        option :divorced

        on_response do |response|
          self.calculator = Calculators::StatePensionThroughPartnerCalculator.new
          calculator.marital_status = response
        end

        calculate :answers do
          answers = []
          if calculator.married?
            answers << :old1
          elsif calculator.widowed?
            answers << :widow
          end
          answers
        end

        next_node do
          if calculator.divorced?
            question :what_is_your_gender?
          else
            question :when_will_you_reach_pension_age?
          end
        end
      end

      # Q2
      multiple_choice :when_will_you_reach_pension_age? do
        option :your_pension_age_before_specific_date
        option :your_pension_age_after_specific_date

        on_response do |response|
          calculator.when_will_you_reach_pension_age = response
        end

        calculate :answers do
          if calculator.reached_pension_age_before_specific_date?
            answers << :old2
          elsif calculator.reached_pension_age_after_specific_date?
            answers << :new2
          end
          answers << :old3 if calculator.widowed?
          answers
        end

        next_node_calculation(:widow_and_new_pension) do
          answers == [:widow] && calculator.reached_pension_age_after_specific_date?
        end

        next_node_calculation(:widow_and_old_pension) do
          answers == [:widow] && calculator.reached_pension_age_before_specific_date?
        end

        next_node do
          if widow_and_new_pension
            question :what_is_your_gender?
          elsif widow_and_old_pension
            outcome :widow_and_old_pension_outcome
          else
            question :when_will_your_partner_reach_pension_age?
          end
        end
      end

      #Q3
      multiple_choice :when_will_your_partner_reach_pension_age? do
        option :partner_pension_age_before_specific_date
        option :partner_pension_age_after_specific_date

        on_response do |response|
          calculator.when_will_your_partner_reach_pension_age = response
        end

        next_node_calculation :answers do |response|
          if response == "partner_pension_age_before_specific_date"
            answers << :old3
          elsif response == "partner_pension_age_after_specific_date"
            answers << :new3
          end
          answers
        end<commit_msg>Use when_will_your_partner_reach_pension_age attribute instead of response<commit_after>module SmartAnswer
  class StatePensionThroughPartnerFlow < Flow
    def define
      content_id "42a41808-b338-4e4b-a703-47195982f4c8"
      name 'state-pension-through-partner'
      status :published
      satisfies_need "100578"

      # Q1
      multiple_choice :what_is_your_marital_status? do
        option :married
        option :widowed
        option :divorced

        on_response do |response|
          self.calculator = Calculators::StatePensionThroughPartnerCalculator.new
          calculator.marital_status = response
        end

        calculate :answers do
          answers = []
          if calculator.married?
            answers << :old1
          elsif calculator.widowed?
            answers << :widow
          end
          answers
        end

        next_node do
          if calculator.divorced?
            question :what_is_your_gender?
          else
            question :when_will_you_reach_pension_age?
          end
        end
      end

      # Q2
      multiple_choice :when_will_you_reach_pension_age? do
        option :your_pension_age_before_specific_date
        option :your_pension_age_after_specific_date

        on_response do |response|
          calculator.when_will_you_reach_pension_age = response
        end

        calculate :answers do
          if calculator.reached_pension_age_before_specific_date?
            answers << :old2
          elsif calculator.reached_pension_age_after_specific_date?
            answers << :new2
          end
          answers << :old3 if calculator.widowed?
          answers
        end

        next_node_calculation(:widow_and_new_pension) do
          answers == [:widow] && calculator.reached_pension_age_after_specific_date?
        end

        next_node_calculation(:widow_and_old_pension) do
          answers == [:widow] && calculator.reached_pension_age_before_specific_date?
        end

        next_node do
          if widow_and_new_pension
            question :what_is_your_gender?
          elsif widow_and_old_pension
            outcome :widow_and_old_pension_outcome
          else
            question :when_will_your_partner_reach_pension_age?
          end
        end
      end

      #Q3
      multiple_choice :when_will_your_partner_reach_pension_age? do
        option :partner_pension_age_before_specific_date
        option :partner_pension_age_after_specific_date

        on_response do |response|
          calculator.when_will_your_partner_reach_pension_age = response
        end

        next_node_calculation :answers do
          if calculator.when_will_your_partner_reach_pension_age == "partner_pension_age_before_specific_date"
            answers << :old3
          elsif calculator.when_will_your_partner_reach_pension_age == "partner_pension_age_after_specific_date"
            answers << :new3
          end
          answers
        end
{'fraction_non_alphanumeric': 0.04584625991037573, 'fraction_numerical': 0.013788348845225784, 'mean_word_length': 2.2078496406854615, 'pattern_counts': {'":': 0, '<': 33, '<?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': '3830509', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1702, 'n_words': 305}