<commit_before>angular.module('chinchilla').factory 'ChContext', ($log) ->
  # context wrapper with some helper functions to fetch actions and association
  # context information.
  class ChContext
    # @param [Object] data context data
    constructor: (@data = {}) ->

    # @param [String] name name of property
    property: (name) ->
      context = @data && @data['@context']
      context && context.properties && context.properties[name]

    # @param [String] name name of association
    association: (name) ->
      assoc = @property(name)
      assoc if _.isPlainObject(assoc) && assoc.type && assoc.type.match(/^(http|https)\:/)

    # @param [String] name name of member action
    member_action: (name) ->
      context = @data && @data['@context']
      action  = context && context.member_actions && context.member_actions[name]
      unless action
        $log.warn("requested non-existing member action '#{name}'")
        $log.debug(@data)

      action

    # @param [String] name name of collection action
    collection_action: (name) ->
      context = @data && @data['@context']
      action  = context && context.collection_actions && context.collection_actions[name]
      unless action
        $log.warn("requested non-existing collection action '#{name}'")
        $log.debug(@data)

      action<commit_msg>add interface to read context constants<commit_after>angular.module('chinchilla').factory 'ChContext', ($log) ->
  # context wrapper with some helper functions to fetch actions and association
  # context information.
  class ChContext
    # @param [Object] data context data
    constructor: (@data = {}) ->

    # @param [String] name name of property
    property: (name) ->
      context = @data && @data['@context']
      context && context.properties && context.properties[name]

    # @param [String] name name of constant
    constant: (name) ->
      context = @data && @data['@context']
      context && context.constants && context.constants[name]

    # @param [String] name name of association
    association: (name) ->
      assoc = @property(name)
      assoc if _.isPlainObject(assoc) && assoc.type && assoc.type.match(/^(http|https)\:/)

    # @param [String] name name of member action
    member_action: (name) ->
      context = @data && @data['@context']
      action  = context && context.member_actions && context.member_actions[name]
      unless action
        $log.warn("requested non-existing member action '#{name}'")
        $log.debug(@data)

      action

    # @param [String] name name of collection action
    collection_action: (name) ->
      context = @data && @data['@context']
      action  = context && context.collection_actions && context.collection_actions[name]
      unless action
        $log.warn("requested non-existing collection action '#{name}'")
        $log.debug(@data)

      action
{'fraction_non_alphanumeric': 0.1366481223922114, 'fraction_numerical': 0.0, 'mean_word_length': 3.157514450867052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '750921', 'n_tokens_mistral': 798, 'n_tokens_neox': 788, 'n_words': 226}