<commit_before>-- Copyright 2015 Boundary
-- @brief convenience variables and functions for Lua scripts
-- @file boundary.lua
local fs = require('fs')
local json = require('json')

local boundary = {argv = nil, param = nil}

-- import param.json data into a Lua table (boundary.param)
local json_blob
if (pcall(function () json_blob = fs.readFileSync("param.json") end)) then
  pcall(function () boundary.param = json.parse(json_blob) end)
end

-- create table of cmdline args (boundary.argv)
boundary.argv = process.argv or nil

return boundary<commit_msg>Local plugins param.json location support.<commit_after>-- Copyright 2015 Boundary
-- @brief convenience variables and functions for Lua scripts
-- @file boundary.lua
local fs = require('fs')
local json = require('json')

local boundary = {argv = nil, param = nil}
local plugin_basedir = "."

-- create table of cmdline args (boundary.argv)
boundary.argv = process.argv or nil
if boundary.argv ~= nil then
  -- if '--plguin-basedir' is present as the first arg, use its value as the path
  -- to the param.json file and remove it from the arg table
  if boundary.argv[1] == '--plugin-basedir' then
    plugin_basedir = boundary.argv[2]
    table.remove(boundary.argv, 1)
    table.remove(boundary.argv, 1)
  end
end

-- import param.json data into a Lua table (boundary.param)
local json_blob
if (pcall(function () json_blob = fs.readFileSync(plugin_basedir.."/param.json") end)) then
  pcall(function () boundary.param = json.parse(json_blob) end)
end

return boundary
{'fraction_non_alphanumeric': 0.11467889908256881, 'fraction_numerical': 0.007863695937090432, 'mean_word_length': 4.176271186440678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6114121', 'n_tokens_mistral': 475, 'n_tokens_neox': 453, 'n_words': 164}