<commit_before>import React, { PropTypes } from 'react';
import TextField from 'material-ui/lib/text-field';
import Checkbox from 'material-ui/lib/checkbox';
import SelectField from 'material-ui/lib/select-field';
import MenuItem from 'material-ui/lib/menus/menu-item';

export default function MaterialUIField({
  type, value, title, description, placeholder, required, recommended, onChangeValue, long, choices, ...rest
}) {
  // TODO: present description?
  
  let errorText;

  if (required && !!value) {
    errorText = 'Required';
  }

  const onChange = (event) => {
    const { target } = event;

    onChangeValue((typeof target.value !== 'undefined') ? target.value : target.checked);

    if (!!rest.onChange) {
      rest.onChange(event);
    }
  }

  if (type === 'boolean') {
    return (
      <Checkbox checked={ value } label={ title } errorText={ errorText } { ...rest } onChange={ onChange } />
    );
  }
  else if (type === 'choice') {
    return (
      <SelectField value={ value } floatingLabelText={ title } errorText={ errorText } { ...rest } onChange={ onChange }>
        { choices.map(choice =>
          <MenuItem key={ choice.id } value={ choice.id } primaryText={ choice.title } />
        ) }
      </SelectField>
    );
  }
  else {
    if (long) {
      return (
        <TextField value={ value } floatingLabelText={ title } hintText={ placeholder} multiLine rows={ 2 } rowsMax={ 6 } errorText={ errorText } { ...rest } onChange={ onChange } />
      )
    } else {
      return (
        <TextField type={ type } value={ value } floatingLabelText={ title } hintText={ placeholder} errorText={ errorText } { ...rest } onChange={ onChange } />
      );
    }
  }
}
<commit_msg>Fix retrieving of values in MaterialUIField<commit_after>import React, { PropTypes } from 'react';
import TextField from 'material-ui/lib/text-field';
import Checkbox from 'material-ui/lib/checkbox';
import SelectField from 'material-ui/lib/select-field';
import MenuItem from 'material-ui/lib/menus/menu-item';

export default function MaterialUIField({
  type, value, title, description, placeholder, required, recommended, onChangeValue, long, choices, ...rest
}) {
  // TODO: present description?

  let errorText;

  if (required && !!value) {
    errorText = 'Required';
  }

  const onSelectChange = (event, index, value) => {
    onChangeValue(value);
  }

  const onFieldChange = (event) => {
    onChangeValue(event.target.value);
  }

  const onCheckedChange = (event) => {
    onChangeValue(event.target.checked);
  }

  if (type === 'boolean') {
    return (
      <Checkbox checked={ value } label={ title } errorText={ errorText } { ...rest } onChange={ onCheckedChange } />
    );
  }
  else if (type === 'choice') {
    return (
      <SelectField value={ value } floatingLabelText={ title } fullWidth errorText={ errorText } { ...rest } onChange={ onSelectChange }>
        { choices.map(choice =>
          <MenuItem key={ choice.id } value={ choice.id } primaryText={ choice.title } />
        ) }
      </SelectField>
    );
  }
  else {
    if (long) {
      return (
        <TextField value={ value } floatingLabelText={ title } hintText={ placeholder} fullWidth multiLine rows={ 2 } rowsMax={ 6 } errorText={ errorText } { ...rest } onChange={ onFieldChange } />
      )
    } else {
      return (
        <TextField type={ type } value={ value } floatingLabelText={ title } hintText={ placeholder} fullWidth errorText={ errorText } { ...rest } onChange={ onFieldChange } />
      );
    }
  }
}

{'fraction_non_alphanumeric': 0.1502546689303905, 'fraction_numerical': 0.0011318619128466328, 'mean_word_length': 3.0446224256292904, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '5266220', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1030, 'n_words': 278}