<commit_before>#!/usr/bin/env python

#In this module we implement an "as numpy" hack which makes it possible to
#utilize Bohrium using the command line argument "python -m bohrium.as_numpy"

import sys
import os
import numpy
import bohrium
sys.modules['numpy_force'] = numpy
sys.modules['numpy'] = bohrium

sys.argv.pop(0)
if len(sys.argv) > 0:
    sys.path[0] = os.path.dirname(os.path.abspath(sys.argv[0]))
else:
    sys.path[0] = ""
if len(sys.argv) > 0:
    execfile(sys.argv[0])
else:
    print ('ERR: the "-m bohrium" does not support interactive mode')
<commit_msg>npbackend: execfile() now in python3<commit_after>#!/usr/bin/env python

#In this module we implement an "as numpy" hack which makes it possible to
#utilize Bohrium using the command line argument "python -m bohrium.as_numpy"

import sys
import os
import numpy
import bohrium

def get_execfile():
    """execfile() does not exist in Python 3"""
    try:
        import runpy
        return runpy.run_path
    except ImportError:
        return execfile

# numpy becomes bohrium
sys.modules['numpy_force'] = numpy
sys.modules['numpy'] = bohrium

# Set the module search path to the dir of the script
sys.argv.pop(0)
if len(sys.argv) > 0:
    sys.path[0] = os.path.dirname(os.path.abspath(sys.argv[0]))
else:
    sys.path[0] = ""

# Let's run the script
if len(sys.argv) > 0:
    get_execfile()(sys.argv[0])
else:
    print ('ERR: the "-m bohrium" does not support interactive mode')

{'fraction_non_alphanumeric': 0.12302405498281786, 'fraction_numerical': 0.010996563573883162, 'mean_word_length': 3.8859060402684564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4597958', 'n_tokens_mistral': 512, 'n_tokens_neox': 503, 'n_words': 162}