<commit_before>import * as React from 'react';
import styled from 'styled-components';
import * as Autosuggest from 'react-autosuggest';
import ThemedAutosuggestButton from 'components/StyledComponents';
import { any } from 'prop-types';

const Row = styled.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
`;

interface AddFieldAutoProps {
  fields: any[];
  field: any;
  handleInputChange: any;
  onSuggestionSelected: any;
}

interface AddFieldAutoState {
  isSuggestionLoading: boolean;
  suggestions: any[];
}

class AddFieldAuto extends React.PureComponent<
  AddFieldAutoProps,
  AddFieldAutoState
> {
  state = {
    isSuggestionLoading: false,
    suggestions: [],
  };

  renderTitleSuggestion = suggestion => {
    if (suggestion.partialString) {
      return (
        <Row>
          <span>{`add "${suggestion.key}" as new label`}</span>
          <ThemedAutosuggestButton>Add</ThemedAutosuggestButton>
        </Row>
      );
    }
    return (
      <Row>
        <span>{`${suggestion.key}`}</span>
        <ThemedAutosuggestButton>Add</ThemedAutosuggestButton>
      </Row>
    );
  };

  onSuggestionsClearRequested = () => {
    this.setState({
      isSuggestionLoading: true,
    });
  };

  getSuggestionValue = suggestion => {
    return suggestion.key;
  };

  escapeRegexChars = str => {
    return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  };

  getSuggestions = (input, array) => {
    const { field } = this.props;
    const escapedValue = this.escapeRegexChars(input.trim());
    if (escapedValue === '') {
      return [];
    }

    const regex = new RegExp('^' + escapedValue, 'i');

    const newArr = array.filter(item => regex.test(item));<commit_msg>remove console logs<commit_after>import * as React from 'react';
import styled from 'styled-components';
import * as Autosuggest from 'react-autosuggest';
import ThemedAutosuggestButton from 'components/StyledComponents';
import { any } from 'prop-types';

const Row = styled.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
`;

interface AddFieldAutoProps {
  fields: any[];
  field: any;
  handleInputChange: any;
  onSuggestionSelected: any;
}

interface AddFieldAutoState {
  isSuggestionLoading: boolean;
  suggestions: any[];
}

class AddFieldAuto extends React.PureComponent<
  AddFieldAutoProps,
  AddFieldAutoState
> {
  state = {
    isSuggestionLoading: false,
    suggestions: [],
  };

  renderTitleSuggestion = suggestion => {
    if (suggestion.partialString) {
      return (
        <Row>
          <span>{`add "${suggestion.key}" as new label`}</span>
          <ThemedAutosuggestButton>Add</ThemedAutosuggestButton>
        </Row>
      );
    }
    return (
      <Row>
        <span>{`${suggestion.key}`}</span>
        <ThemedAutosuggestButton>Add</ThemedAutosuggestButton>
      </Row>
    );
  };

  onSuggestionsClearRequested = () => {
    this.setState({
      isSuggestionLoading: true,
    });
  };

  getSuggestionValue = suggestion => {
    return suggestion.key;
  };

  escapeRegexChars = str => {
    return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  };

  getSuggestions = (input, array) => {
    const escapedValue = this.escapeRegexChars(input.trim());
    if (escapedValue === '') {
      return [];
    }

    const regex = new RegExp('^' + escapedValue, 'i');

    const newArr = array.filter(item => regex.test(item));
{'fraction_non_alphanumeric': 0.1471949103528051, 'fraction_numerical': 0.0, 'mean_word_length': 3.249385749385749, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 41, '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': '5620918', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1099, 'n_words': 220}