<commit_before>module Market
  # Public: Creates a new market graph.
  #
  # Expects data to describe the stakeholders in the marketplace, along with
  # their interactions and payment rules.
  #
  # Expects a hash in the form:
  #
  #   {
  #     measurables: {
  #       'Stakeholder 2': [Network::Node, Network::Node, ...],
  #     },
  #     relations: {
  #       {
  #         name: :kwh, # Optional
  #         from: 'Stakeholder 1',
  #         to: 'Stakeholder 2',
  #         foundation: :kwh,
  #         tariff: 10.0
  #       }
  #     }
  #   }
  class Builder
    FOUNDATIONS = {
      kwh: ->(node, frame) { node.energy_at(frame) }
    }.freeze

    # Public: Creates a builder, which converts a "set-up hash" into a market
    # model.
    def initialize(data)
      @market = Graph.new
      @data   = data
    end

    # Public: Creates and returns the Market::Graph based on the data with which
    # the Builder was initialized.
    def to_market<commit_msg>Add the rest of the foundations to the lookup hash<commit_after>module Market
  # Public: Creates a new market graph.
  #
  # Expects data to describe the stakeholders in the marketplace, along with
  # their interactions and payment rules.
  #
  # Expects a hash in the form:
  #
  #   {
  #     measurables: {
  #       'Stakeholder 2': [Network::Node, Network::Node, ...],
  #     },
  #     relations: {
  #       {
  #         name: :kwh, # Optional
  #         from: 'Stakeholder 1',
  #         to: 'Stakeholder 2',
  #         foundation: :kwh,
  #         tariff: 10.0
  #       }
  #     }
  #   }
  class Builder
    FOUNDATIONS = {
      connections:    Foundations::NumberOfConnections,
      flex_potential: Foundations::FlexibilityPotential,
      flex_realised:  Foundations::FlexibilityRealised,
      load:           Foundations::InstantaneousLoad,
      kw_contracted:  ->(*) { 0.0 },
      kw_max:         Foundations::KwMax.new,
      kwh:            Foundations::Kwh.new,
      kwh_consumed:   Foundations::KwhConsumed,
      kwh_produced:   Foundations::KwhProduced
    }.freeze

    # Public: Creates a builder, which converts a "set-up hash" into a market
    # model.
    def initialize(data)
      @market = Graph.new
      @data   = data
    end

    # Public: Creates and returns the Market::Graph based on the data with which
    # the Builder was initialized.
    def to_market
{'fraction_non_alphanumeric': 0.1038961038961039, 'fraction_numerical': 0.005865102639296188, 'mean_word_length': 2.105331599479844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3716430', 'n_tokens_mistral': 772, 'n_tokens_neox': 742, 'n_words': 212}