<commit_before>_        = require 'underscore'
Backbone = require 'backbone-rel'
degrees  = require('upon').degrees
polyglot = require('there').polyglot
nestCollection = require './nest-collection'


# It would be better if we don't have to instantite all the 360 portions
# ... and setup dispositor relations for each!
class Portion extends Backbone.RelationalModel


# Not sure if dispositors.coffee would be reintroduced...  For now, the
# dispositors stuff scattered around.  Perhaps later it should be extracted
# and mixed-in according to Cosmos preferences.
# The various dispositor-fetching methods return a model from `Cosmos.ensemble`.
class TrigonLords extends Backbone.Collection

  initialize: (@attributes, @representation) ->
    # Just for setting the `@representation`.

  dispositor: (id) ->
    @representation.collection.cosmos.ensemble.get id

  day: ->
    @dispositor (@get('D').get 'lord')

  night: ->
    @dispositor (@get('N').get 'lord')

  cooperating: ->
    @dispositor (@get('C').get 'lord')


class Confines extends Backbone.Collection

  initialize: (@attributes, @representation, scheme) ->
    # EC is for Egyptian Confines, there are at least also PC for Ptolemy's.
    @scheme = scheme ? (_.first @attributes).scheme # the first scheme
    @schemes = _.unique _.pluck @attributes, 'scheme' # array of all the schemes

  dispositor: (id) ->
    @representation.collection.cosmos.ensemble.get id

  # Get the confines dispositors of several (all possible) schemes.
  # Zodiac degrees array nicknamed `zodeg`.
  # TODO: change it back to degrees after the missing attributed bug is fixed.
  variants: (zodeg, schemes = @schemes) ->
    # TODO: this reprtesentation-relative further-more portion --
    # should probably be improved with mod('30').top() - which looks better...
    # mod is chainable degrees, instantiating new degrees
    # after taking the modulo.
    # TODO: furthermore, it is inappropriate to pass the representation number.
    # Just the relative degrees are needed.  The second parameter should come
    # from `@representation.get('idz')` - which attribute is currently missing!
    portion = degrees.lon(zodeg[1], zodeg[0]).rep('top')[1]
    dispositors = {}
    results = @filter (bounds) ->
      _.include(schemes, bounds.get 'scheme') and
      bounds.get('from') <= portion and
      bounds.get('till') >= portion
    for item in results
      dispositors[item.attributes.scheme] = @dispositor item.attributes.lord
    dispositors

  # Get the confines dispositor of just one (preferred) scheme.
  followed: (degrees, scheme = @scheme) ->
    (@variants degrees, [ scheme ])[scheme]


# Cosmic / canonical representation (is no longer called sign, nor image)
class Representation extends Backbone.RelationalModel

  # Dispositor getters - named as simple (i.e. short) as descriptively possible.

  domicile: ->
    @collection.cosmos.ensemble.get(@get "domicile")

  exaltation: ->
    # Signs without exaltation...  An `id` of `null` got with `getNone()`.
    # TODO: consider extending `Ensemble.get`.
    @collection.cosmos.ensemble.get(@get "exaltation") ? # or N/A (on next line)
    @collection.cosmos.ensemble.getNone()

  # TODO: each representation will have its 30 portions (nestedCollection)
  # which will point to a dispositor for monomoria and confines.
  # Decanic faces probably deserve their own (nested?) collection...
  initialize: (attributes) ->

    # The trigons attribute is tied to a `@trigons` nested collection.
    if attributes.trigons?
      @trigons = new TrigonLords (@get 'trigons'), @
      nestCollection @, 'trigons', @trigons

    # The confines attribute is tied to a `@confines` nested collection.
    if attributes.confines?
      @confines = new Confines (@get 'confines'), @
      nestCollection @, 'confines', @confines


# The 12 representations (instances and their relations)
class Zodiac extends Backbone.Collection

  model: Representation

  zoidia:
    the:
      [ [ 'PI' ] , [ 'AR' ] , [ 'TA' ]
      , [ 'GE' ] , [ 'CN' ] , [ 'LE' ]
      , [ 'VI' ] , [ 'LI' ] , [ 'SC' ]
      , [ 'SG' ] , [ 'CP' ] , [ 'AQ' ]
      ]<commit_msg>something has changed about how Backbone / CoffeeScript instantiates<commit_after>_        = require 'underscore'
Backbone = require 'backbone-rel'
degrees  = require('upon').degrees
polyglot = require('there').polyglot
nestCollection = require './nest-collection'


# It would be better if we don't have to instantite all the 360 portions
# ... and setup dispositor relations for each!
class Portion extends Backbone.RelationalModel


# Not sure if dispositors.coffee would be reintroduced...  For now, the
# dispositors stuff scattered around.  Perhaps later it should be extracted
# and mixed-in according to Cosmos preferences.
# The various dispositor-fetching methods return a model from `Cosmos.ensemble`.
class TrigonLords extends Backbone.Collection

  initialize: (@attributes, o) ->
    @representation = o.representation

  dispositor: (id) ->
    @representation.collection.cosmos.ensemble.get id

  day: ->
    @dispositor (@get('D').get 'lord')

  night: ->
    @dispositor (@get('N').get 'lord')

  cooperating: ->
    @dispositor (@get('C').get 'lord')


class Confines extends Backbone.Collection

  initialize: (@attributes, o) ->
    @representation = o.representation
    # EC is for Egyptian Confines, there are at least also PC for Ptolemy's.
    @scheme = o.scheme ? (_.first @attributes).scheme # the first scheme
    @schemes = _.unique _.pluck @attributes, 'scheme' # array of all the schemes

  dispositor: (id) ->
    @representation.collection.cosmos.ensemble.get id

  # Get the confines dispositors of several (all possible) schemes.
  # Zodiac degrees array nicknamed `zodeg`.
  # TODO: change it back to degrees after the missing attributed bug is fixed.
  variants: (zodeg, schemes = @schemes) ->
    # TODO: this reprtesentation-relative further-more portion --
    # should probably be improved with mod('30').top() - which looks better...
    # mod is chainable degrees, instantiating new degrees
    # after taking the modulo.
    # TODO: furthermore, it is inappropriate to pass the representation number.
    # Just the relative degrees are needed.  The second parameter should come
    # from `@representation.get('idz')` - which attribute is currently missing!
    portion = degrees.lon(zodeg[1], zodeg[0]).rep('top')[1]
    dispositors = {}
    results = @filter (bounds) ->
      _.include(schemes, bounds.get 'scheme') and
      bounds.get('from') <= portion and
      bounds.get('till') >= portion
    for item in results
      dispositors[item.attributes.scheme] = @dispositor item.attributes.lord
    dispositors

  # Get the confines dispositor of just one (preferred) scheme.
  followed: (degrees, scheme = @scheme) ->
    (@variants degrees, [ scheme ])[scheme]


# Cosmic / canonical representation (is no longer called sign, nor image)
class Representation extends Backbone.RelationalModel

  # Dispositor getters - named as simple (i.e. short) as descriptively possible.

  domicile: ->
    @collection.cosmos.ensemble.get(@get "domicile")

  exaltation: ->
    # Signs without exaltation...  An `id` of `null` got with `getNone()`.
    # TODO: consider extending `Ensemble.get`.
    @collection.cosmos.ensemble.get(@get "exaltation") ? # or N/A (on next line)
    @collection.cosmos.ensemble.getNone()

  # TODO: each representation will have its 30 portions (nestedCollection)
  # which will point to a dispositor for monomoria and confines.
  # Decanic faces probably deserve their own (nested?) collection...
  initialize: (attributes) ->

    # The trigons attribute is tied to a `@trigons` nested collection.
    if attributes.trigons?
      @trigons = new TrigonLords (@get "trigons"), representation: @
      nestCollection @, 'trigons', @trigons

    # The confines attribute is tied to a `@confines` nested collection.
    if attributes.confines?
      @confines = new Confines (@get "confines"), representation: @
      nestCollection @, 'confines', @confines


# The 12 representations (instances and their relations)
class Zodiac extends Backbone.Collection

  model: Representation

  zoidia:
    the:
      [ [ 'PI' ] , [ 'AR' ] , [ 'TA' ]
      , [ 'GE' ] , [ 'CN' ] , [ 'LE' ]
      , [ 'VI' ] , [ 'LI' ] , [ 'SC' ]
      , [ 'SG' ] , [ 'CP' ] , [ 'AQ' ]
      ]
{'fraction_non_alphanumeric': 0.11714183466539425, 'fraction_numerical': 0.0028629368960992486, 'mean_word_length': 3.4906266738082485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '1953189', 'n_tokens_mistral': 2551, 'n_tokens_neox': 2431, 'n_words': 833}