<commit_before>'''
experiment.py: part of expfactory package
Functions to work with javascript experiments

'''

from expfactory.utils import find_directories, remove_unicode_dict
from glob import glob
import filecmp
import numpy
import json
import re
import os


def get_validation_fields():
    '''get_validation_fields
    Returns a list of tuples (each a field)

    ..note:: 

          specifies fields required for a valid json
          (field,value,type)
          field: the field name
          value: indicates minimum required entires
                 0: not required, no warning
                 1: required, not valid
                 2: not required, warning      
          type: indicates the variable type

    '''
    return [("run",1,list),
            ("name",2,str), 
            ("contributors",0,str),
            ("time",1,int), 
            ("notes",0,str),
            ("reference",2,str), 
            ("exp_id",1,str),
            ("cognitive_atlas_task_id",2,str),
            ("experiment_variables",0,list),
            ("publish",1,str),
            ("deployment_variables",0,str),
            ("template",1,str)]

def notvalid(reason):
    print reason
    return False

def dowarning(reason):
    print reason

def get_valid_templates():
    return ['jspsych','survey','phaser']

def get_acceptable_values(package_name):
    acceptable_values = dict()
    acceptable_values["jspsych"] =["display_element",
                                   "on_finish",
                                   "on_trial_start",<commit_msg>adding "custom" as template option to close #123<commit_after>'''
experiment.py: part of expfactory package
Functions to work with javascript experiments

'''

from expfactory.utils import find_directories, remove_unicode_dict
from glob import glob
import filecmp
import numpy
import json
import re
import os


def get_validation_fields():
    '''get_validation_fields
    Returns a list of tuples (each a field)

    ..note:: 

          specifies fields required for a valid json
          (field,value,type)
          field: the field name
          value: indicates minimum required entires
                 0: not required, no warning
                 1: required, not valid
                 2: not required, warning      
          type: indicates the variable type

    '''
    return [("run",1,list),
            ("name",2,str), 
            ("contributors",0,str),
            ("time",1,int), 
            ("notes",0,str),
            ("reference",2,str), 
            ("exp_id",1,str),
            ("cognitive_atlas_task_id",2,str),
            ("experiment_variables",0,list),
            ("publish",1,str),
            ("deployment_variables",0,str),
            ("template",1,str)]

def notvalid(reason):
    print reason
    return False

def dowarning(reason):
    print reason

def get_valid_templates():
    return ['jspsych','survey','phaser','custom']

def get_acceptable_values(package_name):
    acceptable_values = dict()
    acceptable_values["jspsych"] =["display_element",
                                   "on_finish",
                                   "on_trial_start",
{'fraction_non_alphanumeric': 0.10723350253807107, 'fraction_numerical': 0.010469543147208122, 'mean_word_length': 2.2107942973523422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7625356', 'n_tokens_mistral': 873, 'n_tokens_neox': 826, 'n_words': 232}