<commit_before>import React from 'react';
import sortIntoColumns from 'sort-into-columns';
import Translate from 'react-translate-component';
import TriggeredModalForm from 'modal-form/triggered';
import counterpart from 'counterpart';

// key codes
const BACKSPACE = 8;
const UP = 38;
const DOWN = 40;

class Chooser extends React.Component {
  constructor() {
    super();
    this.choiceButtons = [];
    this.handleClearFilters = this.handleClearFilters.bind(this);
  }

  componentDidMount() {
    this.sortChoiceButtons();
  }

  componentDidUpdate() {
    this.sortChoiceButtons();
  }

  getFilteredChoices() {
    return this.props.task.choicesOrder.map((choiceId) => {
      const choice = this.props.task.choices[choiceId];
      let rejected = false;
      Object.keys(this.props.filters).map((characteristicId) => {
        const valueId = this.props.filters[characteristicId];
        if (choice.characteristics[characteristicId].indexOf(valueId) > -1) {
          rejected = true;
        }
      });
      if (rejected) {
        return null;
      } else {
        return choiceId;
      }
    }).filter(Boolean);
  }

  howManyColumns({ length }) {
    if (length <= 5) {
      return 1;
    } else if (length <= 20) {
      return 2;
    } else {
      return 3;<commit_msg>Reject filtered choices correctly Reject if the filter value is not in the choice characteristics array.<commit_after>import React from 'react';
import sortIntoColumns from 'sort-into-columns';
import Translate from 'react-translate-component';
import TriggeredModalForm from 'modal-form/triggered';
import counterpart from 'counterpart';

// key codes
const BACKSPACE = 8;
const UP = 38;
const DOWN = 40;

class Chooser extends React.Component {
  constructor() {
    super();
    this.choiceButtons = [];
    this.handleClearFilters = this.handleClearFilters.bind(this);
  }

  componentDidMount() {
    this.sortChoiceButtons();
  }

  componentDidUpdate() {
    this.sortChoiceButtons();
  }

  getFilteredChoices() {
    return this.props.task.choicesOrder.map((choiceId) => {
      const choice = this.props.task.choices[choiceId];
      let rejected = false;
      Object.keys(this.props.filters).map((characteristicId) => {
        const valueId = this.props.filters[characteristicId];
        if (choice.characteristics[characteristicId].indexOf(valueId) === -1) {
          rejected = true;
        }
      });
      if (rejected) {
        return null;
      } else {
        return choiceId;
      }
    }).filter(Boolean);
  }

  howManyColumns({ length }) {
    if (length <= 5) {
      return 1;
    } else if (length <= 20) {
      return 2;
    } else {
      return 3;
{'fraction_non_alphanumeric': 0.12206047032474804, 'fraction_numerical': 0.008958566629339306, 'mean_word_length': 2.935389133627019, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '7234810', 'n_tokens_mistral': 818, 'n_tokens_neox': 792, 'n_words': 186}