<commit_before>/**
 * Boilerplate that all Plugins share - and should not be used
 * directly. It also shows which methods final plugins should implement/override,
 * this deciding on structure.
 *
 * @param {object} main Uppy core object
 * @param {object} object with plugin options
 * @return {array | string} files or success/fail message
 */
export default class Plugin {

  constructor (core, opts) {
    this.core = core
    this.opts = opts
    this.type = 'none'
    this.name = this.constructor.name
  }

  /**
   * Check if supplied `target` is a `string` or an `object`.
   * If object (that means its a plugin), search `plugins` for
   * a plugin with same name and return its target.
   *
   * @param {String|Object} target
   *
   */
  getTarget (target, callerPlugin) {
    if (typeof target === 'string') {
      // this.core.log('string is a target')
      return target
    } else {
      // this.core.log('plugin is a target')

      let targetPlugin = this.core.getPlugin(target.name)

      return targetPlugin.prepareTarget(callerPlugin)
    }
  }

  extractFiles (results) {
    console.log({
      class: 'Plugin',
      method: 'extractFiles',
      results: results
    })

    // check if the results array is empty
    // if (!results || !results.count) {
    //   return results
    // }

    const files = []
    results.forEach((result) => {
      try {
        Array.from(result.files).forEach((file) => files.push(file))
      } catch (e) {
        console.log(e)
      }
    })

    // const files = [];
    // for (let i in results) {
    //   for (let j in results[i].files) {
    //     files.push(results[i].files.item(j));
    //   for (let j in results[i].files) {
    //     // files.push(results[i].files.item(j));
    //   }
    // }

    // return Array.from(fileList);
    return files
  }

  focus () {
    console.log('focus pocus!')
    return
  }

  install () {
    return
  }

  run (results) {
    return results
  }
}
<commit_msg>generateFileID function — a unique ID for each acquired file<commit_after>/**
 * Boilerplate that all Plugins share - and should not be used
 * directly. It also shows which methods final plugins should implement/override,
 * this deciding on structure.
 *
 * @param {object} main Uppy core object
 * @param {object} object with plugin options
 * @return {array | string} files or success/fail message
 */
export default class Plugin {

  constructor (core, opts) {
    this.core = core
    this.opts = opts
    this.type = 'none'
    this.name = this.constructor.name
  }

  /**
   * Check if supplied `target` is a `string` or an `object`.
   * If object (that means its a plugin), search `plugins` for
   * a plugin with same name and return its target.
   *
   * @param {String|Object} target
   *
   */
  getTarget (target, callerPlugin) {
    if (typeof target === 'string') {
      // this.core.log('string is a target')
      return target
    } else {
      // this.core.log('plugin is a target')

      let targetPlugin = this.core.getPlugin(target.name)

      return targetPlugin.prepareTarget(callerPlugin)
    }
  }

  /**
   * Takes a fileName and turns it into fileID, by converting to lowercase,
   * removing extra characters and adding unix timestamp
   *
   * @param {String} fileName
   *
   */
  generateFileID (fileName) {
    let fileID = fileName.toLowerCase()
    fileID = fileID.replace(/[^A-Z0-9]/ig, '')
    fileID = fileID + Date.now()
    return fileID
  }

  extractFiles (results) {
    console.log({
      class: 'Plugin',
      method: 'extractFiles',
      results: results
    })

    // check if the results array is empty
    // if (!results || !results.count) {
    //   return results
    // }

    const files = []
    results.forEach((result) => {
      try {
        Array.from(result.files).forEach((file) => files.push(file))
      } catch (e) {
        console.log(e)
      }
    })

    // const files = [];
    // for (let i in results) {
    //   for (let j in results[i].files) {
    //     files.push(results[i].files.item(j));
    //   for (let j in results[i].files) {
    //     // files.push(results[i].files.item(j));
    //   }
    // }

    // return Array.from(fileList);
    return files
  }

  focus () {
    console.log('focus pocus!')
    return
  }

  install () {
    return
  }

  run (results) {
    return results
  }
}

{'fraction_non_alphanumeric': 0.13423279213354677, 'fraction_numerical': 0.000457351932311914, 'mean_word_length': 2.2544642857142856, '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': '2320110', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1339, 'n_words': 397}