<commit_before>import React from 'react';
import {Button} from 'react-bootstrap';
import ActivitySpinner from './ActivitySpinner.jsx';
import {remote} from 'electron';
import ShellOpen from './ShellOpen.jsx';
const dialog = remote.require('dialog');
import strftime from 'strftime';
import path from 'path';
import csv from 'fast-csv';
import fs from 'fs';

export default class Logger extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      currentFile: false,
      selectedFolder: false,
    }
  }

  static propTypes = {
    transformer: React.PropTypes.func.isRequired,
  };

  DisplayOpenFolder() {
    // Open system dialog
    dialog.showOpenDialog({properties: ['openDirectory']}, directory => {
      // User canceled
      if (!directory) return;

      // No dir selected
      if (!directory[0]) return;

      // Set folder mode
      this.setState({selectedFolder: directory[0]});
    });
  }

  NewLogFileInCurrentFolder() {
    if (!this.state.selectedFolder) return;

    var filename = '';

    filename += this.state.selectedFolder;

    filename += path.sep;

    filename += strftime(this.refs.filename.value);

    filename += '.csv';


    this.logToFile(filename);
  }

  DisplaySelectFile() {
    // Open system dialog
    dialog.showSaveDialog({filters: [
      { name: 'CSV (Comma Separated Values)', extensions: ['csv'] },
      { name: 'All Files', extensions: ['*'] },
    ]}, file => {
      // User canceled
      if (!file) return;

      this.setState({selectedFolder: false});<commit_msg>Start filename directly with folder selection<commit_after>import React from 'react';
import {Button} from 'react-bootstrap';
import ActivitySpinner from './ActivitySpinner.jsx';
import {remote} from 'electron';
import ShellOpen from './ShellOpen.jsx';
const dialog = remote.require('dialog');
import strftime from 'strftime';
import path from 'path';
import csv from 'fast-csv';
import fs from 'fs';

export default class Logger extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      currentFile: false,
      selectedFolder: false,
    }
  }

  static propTypes = {
    transformer: React.PropTypes.func.isRequired,
  };

  DisplayOpenFolder() {
    // Open system dialog
    dialog.showOpenDialog({properties: ['openDirectory']}, directory => {
      // User canceled
      if (!directory) return;

      // No dir selected
      if (!directory[0]) return;

      // Set folder mode
      this.setState({selectedFolder: directory[0]});
    });
  }

  NewLogFileInCurrentFolder() {
    if (!this.state.selectedFolder) return;

    var filename = this.state.selectedFolder;

    filename += path.sep;

    filename += strftime(this.refs.filename.value);

    filename += '.csv';


    this.logToFile(filename);
  }

  DisplaySelectFile() {
    // Open system dialog
    dialog.showSaveDialog({filters: [
      { name: 'CSV (Comma Separated Values)', extensions: ['csv'] },
      { name: 'All Files', extensions: ['*'] },
    ]}, file => {
      // User canceled
      if (!file) return;

      this.setState({selectedFolder: false});
{'fraction_non_alphanumeric': 0.1382944746087512, 'fraction_numerical': 0.0012775471095496647, 'mean_word_length': 3.1871657754010694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1519342', 'n_tokens_mistral': 924, 'n_tokens_neox': 882, 'n_words': 239}