<commit_before>import React, { Component } from "react";
import "../App.css";
import request from "superagent";
const baseurl = process.env.REACT_APP_API_HOST + "/search/nick/";

class SearchBar extends Component {
  constructor() {
    super();
    this.previous_input = "";
  }

  jsonify_query(query) {
    let params = query.split(",");
    params = params.map(p => p.trim());
    params = params.filter(p => p !== "");
    return JSON.stringify(params);
  }

  request() {
    request
      .get(baseurl + this.jsonify_query(this.previous_input))
      .accept("json")
      .end((err, res) => this.handle_response(err, res));
  }

  handle_response(error, response) {
    if (error) {
    }
    if (response) {
      if (response.status === 400) {
        this.props.onSearch([]);
      } else if (response.text === "") {
        this.props.onSearch(null);
      } else {
        try {
          var responseObject = JSON.parse(response.text);
          this.props.onSearch(responseObject);
        } catch (Error) {
          // Isn't JSON so we do nothing with the response.
        }
      }
    }
  }

  render() {
    return (
      <div className="search-bar">
        <input
          id="search-input"
          className="search-input"
          type="text"
          placeholder="nick 0, nick 1, ..."<commit_msg>Rename jsonify to tokenize<commit_after>import React, { Component } from "react";
import "../App.css";
import request from "superagent";
const baseurl = process.env.REACT_APP_API_HOST + "/search/nick/";

class SearchBar extends Component {
  constructor() {
    super();
    this.previous_input = "";
  }

  tokenize_query(query) {
    let params = query.split(",");
    params = params.map(p => p.trim());
    params = params.filter(p => p !== "");
    return JSON.stringify(params);
  }

  request() {
    request
      .get(baseurl + this.tokenize_query(this.previous_input))
      .accept("json")
      .end((err, res) => this.handle_response(err, res));
  }

  handle_response(error, response) {
    if (error) {
    }
    if (response) {
      if (response.status === 400) {
        this.props.onSearch([]);
      } else if (response.text === "") {
        this.props.onSearch(null);
      } else {
        try {
          var responseObject = JSON.parse(response.text);
          this.props.onSearch(responseObject);
        } catch (Error) {
          // Isn't JSON so we do nothing with the response.
        }
      }
    }
  }

  render() {
    return (
      <div className="search-bar">
        <input
          id="search-input"
          className="search-input"
          type="text"
          placeholder="nick 0, nick 1, ..."
{'fraction_non_alphanumeric': 0.15424934481467614, 'fraction_numerical': 0.0037439161362785474, 'mean_word_length': 2.2585365853658534, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '7375476', 'n_tokens_mistral': 831, 'n_tokens_neox': 812, 'n_words': 175}