<commit_before>import os
import argparse

from . import Porter


def main():
    parser = argparse.ArgumentParser(
        description=('Transpile trained scikit-learn models '
                     'to C, Java, JavaScript and others. '),
        epilog='More details on: https://github.com/nok/sklearn-porter')
    parser.add_argument(
        '--input', '-i',
        required=True,
        help='Set the path of an exported model in pickle (.pkl) format.')
    parser.add_argument(
        '--output', '-o',
        required=False,
        help='Set the destination directory.')
    parser.add_argument(
        '--language', '-l',
        choices=['c', 'java', 'js', 'go'],
        default='java',
        required=False,
        help="Set the target programming language ('c', 'java', 'js', 'go').")
    args = vars(parser.parse_args())

    model_path = str(args['input'])
    if model_path.endswith('.pkl') and os.path.isfile(model_path):
        # Load data:
        from sklearn.externals import joblib
        raw_model = joblib.load(model_path)
        # Port model:
        porter = Porter(language=str(args['language']), with_details=True)
        result = porter.port(raw_model)
        filename = result.get('filename')
        # Define destination path:
        if str(args['output']) != '' and os.path.isdir(str(args['output'])):
            model_path = str(args['output'])
            model_path = os.path.join(model_path, filename)
        else:
            model_path = model_path.split(os.sep)
            # if len(model_path) > 1:
            del model_path[-1]
            model_path += [filename]
            model_path = os.sep.join(model_path)
        # Save ported model:
        with open(model_path, 'w') as f:<commit_msg>Add 'php' to target programming choices<commit_after>import os
import argparse

from . import Porter


def main():
    parser = argparse.ArgumentParser(
        description=(
            'Transpile trained scikit-learn models '
            'to C, Java, JavaScript and others. '),
        epilog=(
            'More details on: '
            'https://github.com/nok/sklearn-porter'))
    parser.add_argument(
        '--input', '-i',
        required=True,
        help=(
            'Set the path of an exported model '
            'in pickle (.pkl) format.'))
    parser.add_argument(
        '--output', '-o',
        required=False,
        help='Set the destination directory.')
    parser.add_argument(
        '--language', '-l',
        choices=['c', 'java', 'js', 'go', 'php'],
        default='java',
        required=False,
        help=(
            'Set the target programming language '
            '("c", "java", "js", "go", "php").'))
    args = vars(parser.parse_args())

    model_path = str(args['input'])
    if model_path.endswith('.pkl') and os.path.isfile(model_path):
        # Load data:
        from sklearn.externals import joblib
        raw_model = joblib.load(model_path)
        # Port model:
        porter = Porter(language=str(args['language']), with_details=True)
        result = porter.port(raw_model)
        filename = result.get('filename')
        # Define destination path:
        if str(args['output']) != '' and os.path.isdir(str(args['output'])):
            model_path = str(args['output'])
            model_path = os.path.join(model_path, filename)
        else:
            model_path = model_path.split(os.sep)
            # if len(model_path) > 1:
            del model_path[-1]
            model_path += [filename]
            model_path = os.sep.join(model_path)
        # Save ported model:
        with open(model_path, 'w') as f:
{'fraction_non_alphanumeric': 0.14026402640264027, 'fraction_numerical': 0.0011001100110011, 'mean_word_length': 2.18476357267951, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '90743', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1070, 'n_words': 256}