<commit_before>import debug from 'debug'
import EventEmitter from 'events'
import protocol from '../src/protocolDefinitions'

let numberOfMessages = 1

export default class MRIL extends EventEmitter {
  constructor(instruction = '') {
    super()

    this.instruction = instruction
    this.bytes = 0
    this.preparedMRILMessage = ''
    this.number = numberOfMessages++

    this.mrcp

    this.state = {
      executing: false,
      executed: false,
    }


    // remove whitespace and number
    this.preparedMRILMessage = instruction.split(' ').join('')
      .replace(new RegExp(`${protocol.MRIL.COMMAND_NUMBER}\\d+`, 'gi'), '')

    if (this.preparedMRILMessage.indexOf('#') > 0) { // remove comment
      this.preparedMRILMessage = this.preparedMRILMessage.substring(0, this.preparedMRILMessage.indexOf('#'))
    }

    if (instruction.length !== 0) { // no message number for an empty message
      this.preparedMRILMessage = protocol.MRIL.COMMAND_NUMBER + this.number + this.preparedMRILMessage
    }

    this.bytes = this.preparedMRILMessage.length
  }
/**<commit_msg>fix(MRIL): comment and empty message handling<commit_after>import debug from 'debug'
import EventEmitter from 'events'
import protocol from '../src/protocolDefinitions'

let numberOfMessages = 1

export default class MRIL extends EventEmitter {
  constructor(instruction = '') {
    super()

    this.instruction = instruction
    this.bytes = 0
    this.preparedMRILMessage = ''
    this.number = numberOfMessages++

    this.mrcp

    this.state = {
      executing: false,
      executed: false,
    }


    // remove whitespace and number
    this.preparedMRILMessage = instruction.split(' ').join('')
      .replace(new RegExp(`${protocol.MRIL.COMMAND_NUMBER}\\d+`, 'gi'), '')

    if (this.preparedMRILMessage.indexOf('#') >= 0) { // remove comment
      this.preparedMRILMessage = this.preparedMRILMessage.substring(0, this.preparedMRILMessage.indexOf('#'))
    }

    this.preparedMRILMessage = protocol.MRIL.COMMAND_NUMBER + this.number + this.preparedMRILMessage

    this.bytes = this.preparedMRILMessage.length
  }
/**
{'fraction_non_alphanumeric': 0.12304779933743493, 'fraction_numerical': 0.004259346900141978, 'mean_word_length': 3.5074626865671643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2425045', 'n_tokens_mistral': 640, 'n_tokens_neox': 601, 'n_words': 135}