<commit_before>React = require 'react'
Editor = require './editor'
Summary = require './summary'
Chooser = require './chooser'
Choice = require './choice'
AnnotationView = require './annotation-view'

module.exports = React.createClass
  displayName: 'SurveyTask'

  statics:
    Editor: Editor
    Summary: Summary
    AfterSubject: AnnotationView

    getDefaultTask: ->
      type: 'survey'
      characteristicsOrder: []
      characteristics: {}
      choicesOrder: []
      choices: {}
      questionsOrder: []
      questions: {}
      images: {}

    getTaskText: (task) ->
      "Survey of #{task.choicesOrder.length} choices"

    getDefaultAnnotation: ->
      value: []

    isAnnotationComplete: (task, annotation) ->
      # Booleans compare to numbers as expected: true = 1, false = 0.
      annotation.value.length >= (task.required ? 0) and not annotation._choiceInProgress

    testAnnotationQuality: (unknown, knownGood) ->
      # NOTE: Currently only choices (not answers) are compared.
      unknownChoices = unknown.values.map ({choice}) ->
        choice
      knownGoodChoices = knownGood.values.map ({choice}) ->
        choice<commit_msg>Fix survey quality test<commit_after>React = require 'react'
Editor = require './editor'
Summary = require './summary'
Chooser = require './chooser'
Choice = require './choice'
AnnotationView = require './annotation-view'

module.exports = React.createClass
  displayName: 'SurveyTask'

  statics:
    Editor: Editor
    Summary: Summary
    AfterSubject: AnnotationView

    getDefaultTask: ->
      type: 'survey'
      characteristicsOrder: []
      characteristics: {}
      choicesOrder: []
      choices: {}
      questionsOrder: []
      questions: {}
      images: {}

    getTaskText: (task) ->
      "Survey of #{task.choicesOrder.length} choices"

    getDefaultAnnotation: ->
      value: []

    isAnnotationComplete: (task, annotation) ->
      # Booleans compare to numbers as expected: true = 1, false = 0.
      annotation.value.length >= (task.required ? 0) and not annotation._choiceInProgress

    testAnnotationQuality: (unknown, knownGood) ->
      # NOTE: Currently only choices (not answers) are compared.
      unknownChoices = unknown.value.map ({choice}) ->
        choice
      knownGoodChoices = knownGood.value.map ({choice}) ->
        choice
{'fraction_non_alphanumeric': 0.11719418306244654, 'fraction_numerical': 0.0025662959794696323, 'mean_word_length': 2.9377104377104377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3208937', 'n_tokens_mistral': 654, 'n_tokens_neox': 631, 'n_words': 172}