<commit_before>import * as React from "react";
import { t } from "i18next";
import { Button, Classes, MenuItem } from "@blueprintjs/core";
import { ISelectItemRendererProps, Select } from "@blueprintjs/labs";
import { DropDownItem, NULL_CHOICE } from "./fb_select";

const SelectComponent = Select.ofType<DropDownItem | undefined>();

type PossibleReferences =
  | "Sequence"
  | "Regimen";

interface ParentMenu {
  title: string;
  value: string | number;
  subMenus: DropDownItem[];
  reference: PossibleReferences;
}

interface Props {
  items: DropDownItem[];
  selectedItem: DropDownItem;
  onChange: (item: DropDownItem) => void;
  isASubMenu?: boolean;
}

interface State {
  item?: DropDownItem | undefined;
  filterable?: boolean;
  minimal?: boolean;
  resetOnSelect?: boolean;
  parentMenus: ParentMenu[];
  subMenus: DropDownItem[];
}

export class FilterSearch extends React.Component<Props, Partial<State>> {

  public state: State = {
    item: this.props.selectedItem,
    minimal: false,
    resetOnSelect: false,
    parentMenus: [],
    subMenus: []
  };

  render() {
    const { item, minimal, ...flags } = this.state;
    return <SelectComponent
      {...flags}
      items={this.props.items}
      itemPredicate={this.filter}
      itemRenderer={this.default}
      noResults={<MenuItem disabled text="No results." />}
      onItemSelect={this.handleValueChange}
      popoverProps={{ popoverClassName: minimal ? Classes.MINIMAL : "" }}>
      <Button
        rightIconName="double-caret-vertical"
        text={item ? item.label : t("(No selection)")} />
    </SelectComponent>;
  }

  styleFor(item: DropDownItem): string {
    const styles = ["filter-search-item"];
    if (Object.is(item, NULL_CHOICE)) {
      styles.push("filter-search-item-none");
    }
    return styles.join(" ");
  }

  private default = (params: ISelectItemRendererProps<DropDownItem>) => {
    const { handleClick, item, index } = params;
    return <MenuItem
      className={this.styleFor(item)}
      key={item.label || index}
      onClick={handleClick}
      text={`${item.label}`} />;
  }

  private filter(query: string, item: DropDownItem, index: number) {
    return `${index + 1}. ${item.label.toLowerCase()}`
      .indexOf(query.toLowerCase()) >= 0;
  }

  private handleValueChange = (item: DropDownItem | undefined) => {
    if (item) {
      this.props.onChange(item);
      this.setState({ item });
    }
  }

}
<commit_msg>fix filter search number bug<commit_after>import * as React from "react";
import { t } from "i18next";
import { Button, Classes, MenuItem } from "@blueprintjs/core";
import { ISelectItemRendererProps, Select } from "@blueprintjs/labs";
import { DropDownItem, NULL_CHOICE } from "./fb_select";

const SelectComponent = Select.ofType<DropDownItem | undefined>();

type PossibleReferences =
  | "Sequence"
  | "Regimen";

interface ParentMenu {
  title: string;
  value: string | number;
  subMenus: DropDownItem[];
  reference: PossibleReferences;
}

interface Props {
  items: DropDownItem[];
  selectedItem: DropDownItem;
  onChange: (item: DropDownItem) => void;
  isASubMenu?: boolean;
}

interface State {
  item?: DropDownItem | undefined;
  filterable?: boolean;
  minimal?: boolean;
  resetOnSelect?: boolean;
  parentMenus: ParentMenu[];
  subMenus: DropDownItem[];
}

export class FilterSearch extends React.Component<Props, Partial<State>> {

  public state: State = {
    item: this.props.selectedItem,
    minimal: false,
    resetOnSelect: false,
    parentMenus: [],
    subMenus: []
  };

  render() {
    const { item, minimal, ...flags } = this.state;
    return <SelectComponent
      {...flags}
      items={this.props.items}
      itemPredicate={this.filter}
      itemRenderer={this.default}
      noResults={<MenuItem disabled text="No results." />}
      onItemSelect={this.handleValueChange}
      popoverProps={{ popoverClassName: minimal ? Classes.MINIMAL : "" }}>
      <Button
        rightIconName="double-caret-vertical"
        text={item ? item.label : t("(No selection)")} />
    </SelectComponent>;
  }

  styleFor(item: DropDownItem): string {
    const styles = ["filter-search-item"];
    if (Object.is(item, NULL_CHOICE)) {
      styles.push("filter-search-item-none");
    }
    return styles.join(" ");
  }

  private default = (params: ISelectItemRendererProps<DropDownItem>) => {
    const { handleClick, item, index } = params;
    return <MenuItem
      className={this.styleFor(item)}
      key={item.label || index}
      onClick={handleClick}
      text={`${item.label}`} />;
  }

  private filter(query: string, item: DropDownItem, index: number) {
    return item.label.toLowerCase().indexOf(query.toLowerCase()) >= 0;
  }

  private handleValueChange = (item: DropDownItem | undefined) => {
    if (item) {
      this.props.onChange(item);
      this.setState({ item });
    }
  }

}

{'fraction_non_alphanumeric': 0.14353085913471397, 'fraction_numerical': 0.0014353085913471396, 'mean_word_length': 3.593220338983051, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, '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': '898961', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1508, 'n_words': 335}