<commit_before>let isElectron = false
if( process.argv[0].split( '/' ).pop().toLowerCase() === 'electron' )
  isElectron = true

const express = require( 'express' )
const http    = require( 'http' )

const path = require( 'path' )
const getAbsolutePath = ( ...args ) => path.resolve( path.join.apply( this, args ) )
const isExist = filePath => {
  try {
    fs.statSync( path.resolve( filePath ) )
    return true
  } catch( error ){
    return false
  }
}

const fs = require( 'fs' )
const read  = filePath => fs.readFileSync( filePath, 'utf-8' )
const write = ( filePath, content ) => fs.writeFileSync( filePath, content )

const removeRoute = ( app, path ) => {
  let stack = app._router.stack
  for( let i=0; i<stack.length; i++ ){
    if( stack[i].route && stack[i].route.path && stack[i].route.path === path ){
      stack.splice( i, 1 )
      break
    }
  }
}

// Use documents or appData path created by electron when we use electron command.
// Use the current directory path when we use node command.
// node
// saveDocument ./documents/path/to/file
// saveAppdata  ./appData/path/to/file
// electron
// saveDocument electron.app.getPath( 'documents' ) + /path/to/file
// saveAppdata  electron.app.getPath( 'appData' ) + /path/to/file
const savaData = ( type, chdir, filePath, content ) => {
  let basePath = chdir<commit_msg>Add method to download file<commit_after>let isElectron = false
if( process.argv[0].split( '/' ).pop().toLowerCase() === 'electron' )
  isElectron = true

const express = require( 'express' )
const http    = require( 'http' )

const path = require( 'path' )
const getAbsolutePath = ( ...args ) => path.resolve( path.join.apply( this, args ) )
const isExist = filePath => {
  try {
    fs.statSync( path.resolve( filePath ) )
    return true
  } catch( error ){
    return false
  }
}

const fs = require( 'fs' )
const read  = filePath => fs.readFileSync( filePath, 'utf-8' )
const write = ( filePath, content ) => fs.writeFileSync( filePath, content )

const removeRoute = ( app, path ) => {
  let stack = app._router.stack
  for( let i=0; i<stack.length; i++ ){
    if( stack[i].route && stack[i].route.path && stack[i].route.path === path ){
      stack.splice( i, 1 )
      break
    }
  }
}

// Download
const url  = require( 'url' )
const download = ( from, to ) => {
  return new Promise( ( resolve, reject ) => {
    let filename = url.parse( from ).pathname

    http.get( from, response => {
      if( response.statusCode < 200 || 299 < response.statusCode )
        reject( response )
      else {
        let output = fs.createWriteStream( path.resolve( to, path.basename( filename ) ) )
        output.on( 'error', reject )
        response.pipe( output )
        response.on( 'end', e => {
          output.close()
          resolve( path.basename( filename ) )
        } )
      }
    } ).on( 'error', reject )
  } )
}

// Use documents or appData path created by electron when we use electron command.
// Use the current directory path when we use node command.
// node
// saveDocument ./documents/path/to/file
// saveAppdata  ./appData/path/to/file
// electron
// saveDocument electron.app.getPath( 'documents' ) + /path/to/file
// saveAppdata  electron.app.getPath( 'appData' ) + /path/to/file
const savaData = ( type, chdir, filePath, content ) => {
  let basePath = chdir
{'fraction_non_alphanumeric': 0.15174278846153846, 'fraction_numerical': 0.004206730769230769, 'mean_word_length': 2.9210836277974086, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3331244', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1072, 'n_words': 305}