<commit_before>React = require 'react'
ChangeListener = require '../components/change-listener'
SubjectAnnotator = require './subject-annotator'
ClassificationSummary = require './classification-summary'
{Link} = require 'react-router'
tasks = require './tasks'
drawingTools = require './drawing-tools'

unless process.env.NODE_ENV is 'production'
  mockData = require './mock-data'

Classifier = React.createClass
  displayName: 'Classifier'

  _lastAnnotationAndTool: ''

  getDefaultProps: ->
    user: null
    if mockData?
      {workflow, subject, classification} = mockData
    workflow: workflow
    subject: subject
    classification: classification
    onLoad: Function.prototype

  getInitialState: ->
    subjectLoading: false
    showingExpertClassification: false
    selectedExpertAnnotation: -1

  componentDidMount: ->
    @loadSubject @props.subject
    @prepareToClassify @props.classification

  componentWillReceiveProps: (nextProps) ->
    if nextProps.subject isnt @props.subject
      @loadSubject subject
    if nextProps.classification isnt @props.classification
      @prepareToClassify nextProps.classification

  loadSubject: (subject) ->
    @setState subjectLoading: true
    # TODO: Pre-cache subject images here and change loading state back.

  prepareToClassify: (classification) ->
    setTimeout => # TODO: Why is this here?
      classification.annotations ?= []
      if classification.annotations.length is 0
        @addAnnotationForTask @props.workflow.first_task

  render: ->
    <ChangeListener target={@props.classification}>{=>
      currentClassification = if @state.showingExpertClassification
        @props.subject.expert_classification_data
      else
        @props.classification
      window.classification = currentClassification<commit_msg>Delete current classification global<commit_after>React = require 'react'
ChangeListener = require '../components/change-listener'
SubjectAnnotator = require './subject-annotator'
ClassificationSummary = require './classification-summary'
{Link} = require 'react-router'
tasks = require './tasks'
drawingTools = require './drawing-tools'

unless process.env.NODE_ENV is 'production'
  mockData = require './mock-data'

Classifier = React.createClass
  displayName: 'Classifier'

  _lastAnnotationAndTool: ''

  getDefaultProps: ->
    user: null
    if mockData?
      {workflow, subject, classification} = mockData
    workflow: workflow
    subject: subject
    classification: classification
    onLoad: Function.prototype

  getInitialState: ->
    subjectLoading: false
    showingExpertClassification: false
    selectedExpertAnnotation: -1

  componentDidMount: ->
    @loadSubject @props.subject
    @prepareToClassify @props.classification

  componentWillReceiveProps: (nextProps) ->
    if nextProps.subject isnt @props.subject
      @loadSubject subject
    if nextProps.classification isnt @props.classification
      @prepareToClassify nextProps.classification

  loadSubject: (subject) ->
    @setState subjectLoading: true
    # TODO: Pre-cache subject images here and change loading state back.

  prepareToClassify: (classification) ->
    setTimeout => # TODO: Why is this here?
      classification.annotations ?= []
      if classification.annotations.length is 0
        @addAnnotationForTask @props.workflow.first_task

  render: ->
    <ChangeListener target={@props.classification}>{=>
      currentClassification = if @state.showingExpertClassification
        @props.subject.expert_classification_data
      else
        @props.classification
{'fraction_non_alphanumeric': 0.08971124194000561, 'fraction_numerical': 0.00112139052425007, 'mean_word_length': 3.9555555555555557, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7025563', 'n_tokens_mistral': 952, 'n_tokens_neox': 916, 'n_words': 234}