<commit_before>/**
 * function to check if there are errors.
 * @returns {void} - returns nothing.
 */
function checkForErrors () {
  const errorMsg = doCheck()

  if (errorMsg !== '') {
    $('#hasErrors').val('true')
    $('#status-prepare').css({'visibility': 'hidden'})
    $('#error-modal-message').html(errorMsg)
    $('#error-modal').modal()
  } else {
    $('#hasErrors').val('false')
  }
}

/**
 * function to figure out where general errors are.
 * @returns {string} - returns the appropriate error message
 */
function doCheck () {
  const noActiveDocsMsg = `You have no active documents. Please
  activate at least one document using the 
  <a href="{{ url_for("manage.manage") }}">Manage</a> tool or 
  <a href="{{ url_for("upload.upload") }}">upload</a> a new document.`
  const noCutStringMsg = 'You must provide a string to cut on.'
  const noCutValMsg = 'You must provide a default cutting value.'

  // Confirm that there are active files
  if ($('#numActiveFiles').val() === '0') {
    return noActiveDocsMsg
  }

  // If cut by milestone is checked make sure there is a milestone value
  if ($('#cutByMS').is(':checked')) {
    if ($('#MScutWord').val() === '') {
      return noCutStringMsg
    }
  } else {
    // Make sure there is a default cutting value
    if ($('#overallcutvalue').val() === '') {
      return noCutValMsg
    } else {
      return checkValues()
    }
  }
}

/**
 * function to figure out if errors with cut and overlap values.
 * @returns {string} - the error message.
 */
function checkValues () {
  const defInvalidSegSize = 'Default cutting: Invalid segment size.'
  const defInvalidOverlapVal = 'Default cutting: Invalid overlap value.'
  const indInvalidSegSize = 'Individual cutting: Invalid segment size.'
  const indInvalidOverlapVal = 'Individual cutting: Invalid overlap value.'

  const overallcutvalueStr = $('#overallcutvalue').val()
  const overallcutvalue = parseInt($('#overallcutvalue').val())
  const overallOverlapValue = parseInt($('#overallOverlapValue').val())
  const individualOverlap = parseInt($('#individualOverlap').val())
  const individualCutValueStr = $('#individualCutValue').val()
  let individualCutValue = $('#individualCutValue').val()

  // Make sure the overall segment size not negative
  if (overallcutvalue !== Math.floor(overallcutvalue)) {
    return defInvalidSegSize
  }
  // Make sure the overall segment size not a decimal
  if (overallcutvalueStr !== Math.abs(overallcutvalue).toString()) {
    return defInvalidSegSize
  }
  // Make sure the overall segment size not 0
  if (overallcutvalue === 0) {
    return defInvalidSegSize
  }
  // Make sure the overall overlap is valid
  if ((overallcutvalue <= overallOverlapValue) || (Math.abs(Math.round(overallOverlapValue)) !== overallOverlapValue)) {
    return defInvalidOverlapVal
  }
  // If there are individual segment cuts
  if (individualCutValue !== '') {
    individualCutValue = parseInt(individualCutValue)
    // Make sure the individual segment size not negative
    if (individualCutValue !== Math.floor(individualCutValue)) {
      return indInvalidSegSize
    }
    // Make sure the individual segment size not a decimal
    if (individualCutValueStr !== Math.abs(individualCutValue).toString()) {
      return indInvalidSegSize
    }
    // Make sure the individual segment size not 0
    if (individualCutValue === 0) {
      return indInvalidSegSize
    }
    // Make sure the individual overlap is valid
    if ((individualCutValue <= individualOverlap) || (Math.abs(Math.round(individualOverlap)) !== individualOverlap)) {
      return indInvalidOverlapVal
    }
  }
  return ''
}

/**
 * function to check whether the user needs a warning.
 * @returns {void} - returns nothing.
 */
function checkForWarnings () {
  let needsWarning = false
  const maxSegs = 100
  const defCutTypeValue = $("input[name='cutType']:checked").val() // Cut Type
  const cutVal = parseInt($("input[name='cutValue']").val()) // Segment Size
  const overVal = parseInt($('#overallOverlapValue').val()) // Overlap Size
  const indivDivs = $('.cuttingoptionswrapper.ind') // All individual cutsets
  const eltsWithoutIndividualOpts = [] // Elements without individual cutsets

  // Check each individual cutset
  indivDivs.each(function () {
    let thisCutVal = $('#individualCutValue', this).val() // Individual segment size
    let thisOverVal = $('#individualOverlap', this).val() // Individual overlap size
    // Parse as integers
    if (thisCutVal !== '') {
      thisCutVal = parseInt(thisCutVal)
      thisOverVal = parseInt(thisOverVal)<commit_msg>Better documentation.<commit_after>/**
 * function to check if there are errors.
 * @returns {void} - returns nothing.
 */
function checkForErrors () {
  // search for error messages
  const errorMsg = doCheck()

  // throw error modal if error found.
  if (errorMsg !== '') {
    $('#hasErrors').val('true')
    $('#status-prepare').css({'visibility': 'hidden'})
    $('#error-modal-message').html(errorMsg)
    $('#error-modal').modal()
  } else {
    $('#hasErrors').val('false')
  }
}

/**
 * function to figure out where general errors are.
 * @returns {string} - returns the appropriate error message
 */
function doCheck () {
  const noActiveDocsMsg = `You have no active documents. Please
  activate at least one document using the 
  <a href="{{ url_for("manage.manage") }}">Manage</a> tool or 
  <a href="{{ url_for("upload.upload") }}">upload</a> a new document.`
  const noCutStringMsg = 'You must provide a string to cut on.'
  const noCutValMsg = 'You must provide a default cutting value.'

  // Confirm that there are active files
  if ($('#numActiveFiles').val() === '0') {
    return noActiveDocsMsg
  }

  // If cut by milestone is checked make sure there is a milestone value
  if ($('#cutByMS').is(':checked')) {
    if ($('#MScutWord').val() === '') {
      return noCutStringMsg
    }
  } else {
    // Make sure there is a default cutting value
    if ($('#overallcutvalue').val() === '') {
      return noCutValMsg
    } else {
      return checkValues()
    }
  }
}

/**
 * function to figure out if errors with cut and overlap values.
 * @returns {string} - the error message.
 */
function checkValues () {
  const defInvalidSegSize = 'Default cutting: Invalid segment size.'
  const defInvalidOverlapVal = 'Default cutting: Invalid overlap value.'
  const indInvalidSegSize = 'Individual cutting: Invalid segment size.'
  const indInvalidOverlapVal = 'Individual cutting: Invalid overlap value.'

  const overallcutvalueStr = $('#overallcutvalue').val()
  const overallcutvalue = parseInt($('#overallcutvalue').val())
  const overallOverlapValue = parseInt($('#overallOverlapValue').val())
  const individualOverlap = parseInt($('#individualOverlap').val())
  const individualCutValueStr = $('#individualCutValue').val()
  let individualCutValue = $('#individualCutValue').val()

  // Make sure the overall segment size not negative
  if (overallcutvalue !== Math.floor(overallcutvalue)) {
    return defInvalidSegSize
  }
  // Make sure the overall segment size not a decimal
  if (overallcutvalueStr !== Math.abs(overallcutvalue).toString()) {
    return defInvalidSegSize
  }
  // Make sure the overall segment size not 0
  if (overallcutvalue === 0) {
    return defInvalidSegSize
  }
  // Make sure the overall overlap is valid
  if ((overallcutvalue <= overallOverlapValue) || (Math.abs(Math.round(overallOverlapValue)) !== overallOverlapValue)) {
    return defInvalidOverlapVal
  }
  // If there are individual segment cuts
  if (individualCutValue !== '') {
    individualCutValue = parseInt(individualCutValue)
    // Make sure the individual segment size not negative
    if (individualCutValue !== Math.floor(individualCutValue)) {
      return indInvalidSegSize
    }
    // Make sure the individual segment size not a decimal
    if (individualCutValueStr !== Math.abs(individualCutValue).toString()) {
      return indInvalidSegSize
    }
    // Make sure the individual segment size not 0
    if (individualCutValue === 0) {
      return indInvalidSegSize
    }
    // Make sure the individual overlap is valid
    if ((individualCutValue <= individualOverlap) || (Math.abs(Math.round(individualOverlap)) !== individualOverlap)) {
      return indInvalidOverlapVal
    }
  }
  // no errors
  return ''
}

/**
 * function to check whether the user needs a warning.
 * @returns {void} - returns nothing.
 */
function checkForWarnings () {
  let needsWarning = false
  const maxSegs = 100
  const defCutTypeValue = $("input[name='cutType']:checked").val() // Cut Type
  const cutVal = parseInt($("input[name='cutValue']").val()) // Segment Size
  const overVal = parseInt($('#overallOverlapValue').val()) // Overlap Size
  const indivDivs = $('.cuttingoptionswrapper.ind') // All individual cutsets
  const eltsWithoutIndividualOpts = [] // Elements without individual cutsets

  // Check each individual cutset
  indivDivs.each(function () {
    let thisCutVal = $('#individualCutValue', this).val() // Individual segment size
    let thisOverVal = $('#individualOverlap', this).val() // Individual overlap size
    // Parse as integers
    if (thisCutVal !== '') {
      thisCutVal = parseInt(thisCutVal)
      thisOverVal = parseInt(thisOverVal)
{'fraction_non_alphanumeric': 0.13161012385568122, 'fraction_numerical': 0.0017232094776521271, 'mean_word_length': 3.779207411219763, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4798641', 'n_tokens_mistral': 2651, 'n_tokens_neox': 2560, 'n_words': 802}