<commit_before>EntCount = (string, id, callback)=>
  Meteor.npmRequire('shelljs/global')

  string = "'#{string}'"
  console.log string.length
  exec 'cd ../../../../../private && lua parser.lua ' + string, (code, output)->
    #    console.log output
    if code != 0
      Meteor.Error "Something is wrong with the blueprint string"
    try
      data = JSON.parse output
    catch error
      console.log error
      return
    entStorage = {}
    _.each data.entities, (ent)->
      if not entStorage[ent.name]
        entStorage[ent.name] = 1
      else
        entStorage[ent.name] = entStorage[ent.name] + 1

    entStorage

    counts = []

    _.each entStorage, (value, key)->
      entData = new Object
      entData.amount = value
      entData.item = key
      counts.push(entData)
    counts

    callback null, [counts, data]

wrappedEntCount = Async.wrap(EntCount)


Meteor.methods
  'bluePrintParser': (string, bluePrintId)->
    counts = wrappedEntCount(string, bluePrintId)
    console.log typeof JSON.stringify counts[1]
    bluePrints.update(bluePrintId, {
      $set:
        requirements: counts[0]
        parsed: JSON.stringify counts[1]
    })<commit_msg>updates to handle parser location<commit_after>Meteor.startup ()->
  if process.env.NODE_ENV == 'production'
    @parserLoc = '/home/parser'
  else
    @parserLoc = '../../../../../private'


EntCount = (string, id, callback)=>
  Meteor.npmRequire('shelljs/global')
  string = "'#{string}'"

  cmd = "cd #{@parserLoc} && lua parser.lua  #{string}"
  exec cmd, (code, output)->
    if code != 0
      Meteor.Error "Something is wrong with the blueprint string"
    try
      data = JSON.parse output
    catch error
      console.log error
      return
    entStorage = {}
    _.each data.entities, (ent)->
      if not entStorage[ent.name]
        entStorage[ent.name] = 1
      else
        entStorage[ent.name] = entStorage[ent.name] + 1

    counts = []

    _.each entStorage, (value, key)->
      entData = new Object
      entData.amount = value
      entData.item = key
      counts.push(entData)
    counts

    callback null, [counts, data]

wrappedEntCount = Async.wrap(EntCount)


Meteor.methods
  'bluePrintParser': (string, bluePrintId)->
    counts = wrappedEntCount(string, bluePrintId)
    bluePrints.update(bluePrintId, {
      $set:
        requirements: counts[0]
        parsed: JSON.stringify counts[1]
    })
{'fraction_non_alphanumeric': 0.1294068851099129, 'fraction_numerical': 0.004562422231439237, 'mean_word_length': 2.552282768777614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '4814576', 'n_tokens_mistral': 768, 'n_tokens_neox': 755, 'n_words': 188}