<commit_before>URL = require("url")

PatchboardAPI = require("./patchboard_api")
Dispatcher = require("./simple_dispatcher")
Documenter = require("./documenter")
Classifier = require("./classifier")
SchemaManager = require("./schema_manager2")
SchemaValidator = require("./schema_validator")
Path = require("./path")

class Service

  constructor: (api, @options={}) ->
    url = @options.url || "http://localhost:1337"

    # We construct full urls by concatenating @service_url and the path,
    # so make sure that @service_url does not end in a slash.
    if url[url.length-1] == "/"
      url = url.slice(0,-1)
    @service_url = url

    @decorator = @options.decorator
    @log = @options.log || console

    #SchemaManager.normalize(PatchboardAPI.schema)
    #SchemaManager.normalize(api.schema)

    @schema_manager = new SchemaManager(api.schema)

    @mappings = api.mappings


    @resources = {}
    @paths = {}
    @directory = {}

    for key, value of PatchboardAPI.resources
      @resources[key] = value
    for key, value of api.resources
      @resources[key] = value

    for resource_type, mapping of PatchboardAPI.mappings when mapping.path
      @directory[resource_type] =
        resource: mapping.resource
        url: "#{@service_url}#{mapping.path}"

    for resource_type, mapping of @mappings when mapping.path
      @directory[resource_type] =
        resource: mapping.resource
        url: "#{@service_url}#{mapping.path}"<commit_msg>fix directory to include query info<commit_after>URL = require("url")

PatchboardAPI = require("./patchboard_api")
Dispatcher = require("./simple_dispatcher")
Documenter = require("./documenter")
Classifier = require("./classifier")
SchemaManager = require("./schema_manager2")
SchemaValidator = require("./schema_validator")
Path = require("./path")

class Service

  constructor: (api, @options={}) ->
    url = @options.url || "http://localhost:1337"

    # We construct full urls by concatenating @service_url and the path,
    # so make sure that @service_url does not end in a slash.
    if url[url.length-1] == "/"
      url = url.slice(0,-1)
    @service_url = url

    @decorator = @options.decorator
    @log = @options.log || console

    #SchemaManager.normalize(PatchboardAPI.schema)
    #SchemaManager.normalize(api.schema)

    @schema_manager = new SchemaManager(api.schema)

    @mappings = api.mappings


    @resources = {}
    @paths = {}
    @directory = {}

    for key, value of PatchboardAPI.resources
      @resources[key] = value
    for key, value of api.resources
      @resources[key] = value


    for mappings in [PatchboardAPI.mappings, @mappings]

      for resource_type, mapping of mappings
        @directory[resource_type] =
          resource: mapping.resource
          url: "#{@service_url}#{mapping.path}"
          query: mapping.query

{'fraction_non_alphanumeric': 0.1303583977512298, 'fraction_numerical': 0.005621925509486999, 'mean_word_length': 3.4276827371695178, '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': '7525992', 'n_tokens_mistral': 867, 'n_tokens_neox': 833, 'n_words': 205}