<commit_before>flags = require './lib/flags'
Controller = require 'zooniverse/controllers/base-controller'
User = require 'zooniverse/models/user'
Subject = require 'zooniverse/models/subject'
Classification = require 'zooniverse/models/classification'

IS_DEV = if flags.dev?
  flags.dev is 1
else
  +location.port > 1023

class Classifier extends Controller
  CREATE: "zooniverse-readymade:classifier:create"
  LOAD_SUBJECT: "zooniverse-readymade:classifier:load_subject"
  LOAD_CLASSIFICATION: "zooniverse-readymade:classifier:load_classification"
  CREATE_CLASSIFICATION: "zooniverse-readymade:classifier:create_classification"
  FINISH_SUBJECT: "zooniverse-readymade:classifier:finish_subject"
  SEND_CLASSIFICATION: "zooniverse-readymade:classifier:send_classification"

  Subject: null
  subjectGroup: Subject::subjectGroup

  className: 'readymade-classifier'

  constructor: ->
    @Subject = class extends Subject

    super

    @Subject.group = @subjectGroup

    @listenTo User, 'change', (e, user) =>
      @onUserChange user

    @listenTo @Subject, 'getting-next', =>
      @onSubjectGettingNext()

    @listenTo @Subject, 'select', (e, subject) =>
      @onSubjectSelect subject

    @listenTo @Subject, 'no-more', (e) =>
      @onNoMoreSubjects

    if IS_DEV
      window.classifier = this

    @trigger @CREATE, this

  # TODO: This should totally be built in.
  listenTo: (thing, eventName, handler) ->
    addEvent = if 'on' of thing then 'on' else 'addEventListener'
    removeEvent = if 'off' of thing then 'off' else 'removeEventListener'

    thing[addEvent] eventName, handler

    @on 'destroy', ->
      thing[removeEvent] eventName, handler

  onUserChange: (user) ->
    unless @classification?
      @Subject.next()

  onSubjectGettingNext: -><commit_msg>Actually call the onNoMoreSubjects method<commit_after>flags = require './lib/flags'
Controller = require 'zooniverse/controllers/base-controller'
User = require 'zooniverse/models/user'
Subject = require 'zooniverse/models/subject'
Classification = require 'zooniverse/models/classification'

IS_DEV = if flags.dev?
  flags.dev is 1
else
  +location.port > 1023

class Classifier extends Controller
  CREATE: "zooniverse-readymade:classifier:create"
  LOAD_SUBJECT: "zooniverse-readymade:classifier:load_subject"
  LOAD_CLASSIFICATION: "zooniverse-readymade:classifier:load_classification"
  CREATE_CLASSIFICATION: "zooniverse-readymade:classifier:create_classification"
  FINISH_SUBJECT: "zooniverse-readymade:classifier:finish_subject"
  SEND_CLASSIFICATION: "zooniverse-readymade:classifier:send_classification"

  Subject: null
  subjectGroup: Subject::subjectGroup

  className: 'readymade-classifier'

  constructor: ->
    @Subject = class extends Subject

    super

    @Subject.group = @subjectGroup

    @listenTo User, 'change', (e, user) =>
      @onUserChange user

    @listenTo @Subject, 'getting-next', =>
      @onSubjectGettingNext()

    @listenTo @Subject, 'select', (e, subject) =>
      @onSubjectSelect subject

    @listenTo @Subject, 'no-more', (e) =>
      @onNoMoreSubjects()

    if IS_DEV
      window.classifier = this

    @trigger @CREATE, this

  # TODO: This should totally be built in.
  listenTo: (thing, eventName, handler) ->
    addEvent = if 'on' of thing then 'on' else 'addEventListener'
    removeEvent = if 'off' of thing then 'off' else 'removeEventListener'

    thing[addEvent] eventName, handler

    @on 'destroy', ->
      thing[removeEvent] eventName, handler

  onUserChange: (user) ->
    unless @classification?
      @Subject.next()

  onSubjectGettingNext: ->
{'fraction_non_alphanumeric': 0.10710321864594895, 'fraction_numerical': 0.002774694783573807, 'mean_word_length': 4.437405731523379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '4515172', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1089, 'n_words': 258}