<commit_before># Description:
#   evaluate code
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot eval me <lang> <code> - evaluate <code> and show the result
#   hubot eval on <lang> - start recording
#   hubot eval off|finish|done - evaluate recorded <code> and show the result
#   hubot eval cancel - cancel recording
#   hubot eval list - list available languages
#
# Author:
#   aanoaa

util = require 'util'
ready = false

module.exports = (robot) ->
  get_languages = (robot, callback) ->
    callback or= () ->
    if not ready or robot.brain?.data?.eval_langs
      callback(robot.brain?.data?.eval_langs || {})
      return

    url = "http://api.dan.co.jp/lleval.cgi"
    robot.logger.info "Loading language data from #{url}"
    robot
      .http(url)
      .query(q: "1")
      .get() (err, res, body) ->
        langs = JSON.parse(body)
        robot.brain.data.eval_langs = langs
        callback(langs)
        robot.logger.info "Brain received eval language list #{util.inspect(langs)}"

  lang_valid = (robot, lang, callback) -><commit_msg>remove eval_langs<commit_after># Description:
#   evaluate code
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot eval me <lang> <code> - evaluate <code> and show the result
#   hubot eval on <lang> - start recording
#   hubot eval off|finish|done - evaluate recorded <code> and show the result
#   hubot eval cancel - cancel recording
#   hubot eval list - list available languages
#
# Author:
#   aanoaa

util = require 'util'
ready = false

module.exports = (robot) ->
  get_languages = (robot, callback) ->
    callback or= () ->
    if not ready
      callback {}
      return

    url = "http://api.dan.co.jp/lleval.cgi"
    robot.logger.info "Loading language data from #{url}"
    robot
      .http(url)
      .query(q: "1")
      .get() (err, res, body) ->
        langs = JSON.parse(body)
        callback(langs)
        robot.logger.info "Brain received eval language list #{util.inspect(langs)}"

  lang_valid = (robot, lang, callback) ->
{'fraction_non_alphanumeric': 0.1297820823244552, 'fraction_numerical': 0.0009685230024213075, 'mean_word_length': 2.8188539741219962, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '4704266', 'n_tokens_mistral': 685, 'n_tokens_neox': 679, 'n_words': 197}