<commit_before># Copyright (C) 2015 SINTEF ICT,
# Applied Mathematics, Norway.
#
# Contact information:
# E-mail: <EMAIL>
# SINTEF ICT, Department of Applied Mathematics,
# P.O. Box 4760 Sluppen,
# 7045 Trondheim, Norway.
#
# This file is part of BADGER.
#
# BADGER is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# BADGER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with BADGER. If not, see
# <http://www.gnu.org/licenses/>.
#
# In accordance with Section 7(b) of the GNU Affero General Public
# License, a covered work must retain the producer line in every data
# file that is created or manipulated using BADGER.
#
# Other Usage
# You can be released from the requirements of the license by purchasing
# a commercial license. Buying such a license is mandatory as soon as you
# develop commercial activities involving BADGER without disclosing the
# source code of your own applications.
#
# This file may be used in accordance with the terms contained in a
# written agreement between you and SINTEF ICT.

import operator
import shlex
import shutil
import subprocess
import tempfile

from functools import reduce
from socket import gethostname
from datetime import datetime
from itertools import chain, product
from os.path import join, dirname
from operator import methodcaller
from jinja2 import Environment, FileSystemLoader

from sett import output, input, log
from sett.utils import *


def interpolate_vars(string, namespace):
    for name, value in namespace.items():
        string = string.replace('$' + name, str(value))
    return string


def build_initial_namespace(setup, parameters):
    namespace = dict(zip(setup.parameters, parameters))
    for name, expr in setup.dependencies.items():
        try:
            namespace[name] = eval(expr, {}, namespace)
        except (TypeError, SyntaxError):
            namespace[name] = expr<commit_msg>Catch nameerror in formula evaluation<commit_after># Copyright (C) 2015 SINTEF ICT,
# Applied Mathematics, Norway.
#
# Contact information:
# E-mail: <EMAIL>
# SINTEF ICT, Department of Applied Mathematics,
# P.O. Box 4760 Sluppen,
# 7045 Trondheim, Norway.
#
# This file is part of BADGER.
#
# BADGER is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# BADGER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with BADGER. If not, see
# <http://www.gnu.org/licenses/>.
#
# In accordance with Section 7(b) of the GNU Affero General Public
# License, a covered work must retain the producer line in every data
# file that is created or manipulated using BADGER.
#
# Other Usage
# You can be released from the requirements of the license by purchasing
# a commercial license. Buying such a license is mandatory as soon as you
# develop commercial activities involving BADGER without disclosing the
# source code of your own applications.
#
# This file may be used in accordance with the terms contained in a
# written agreement between you and SINTEF ICT.

import operator
import shlex
import shutil
import subprocess
import tempfile

from functools import reduce
from socket import gethostname
from datetime import datetime
from itertools import chain, product
from os.path import join, dirname
from operator import methodcaller
from jinja2 import Environment, FileSystemLoader

from sett import output, input, log
from sett.utils import *


def interpolate_vars(string, namespace):
    for name, value in namespace.items():
        string = string.replace('$' + name, str(value))
    return string


def build_initial_namespace(setup, parameters):
    namespace = dict(zip(setup.parameters, parameters))
    for name, expr in setup.dependencies.items():
        try:
            namespace[name] = eval(expr, {}, namespace)
        except (TypeError, SyntaxError, NameError):
            namespace[name] = expr
{'fraction_non_alphanumeric': 0.06400170104188815, 'fraction_numerical': 0.00637890708058686, 'mean_word_length': 4.20353982300885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1821620', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1225, 'n_words': 618}