<commit_before>"""
``revscoring model_info -h``
::

    Prints formatted information about a model file.


    Usage:
        module_info -h | --help
        module_info <model-file> [--as-json]

    Options:
        -h --help     Prints this documentation
        <model-file>  Path to a model file
        --as-json     Output model info as a JSON blob
"""
import json

import docopt

from ..scoring import Model


def main(argv=None):
    args = docopt.docopt(__doc__, argv=argv)
    scorer_model = Model.load(open(args['<model-file>'], 'rb'))
    as_json = args['--as-json']

    run(scorer_model, as_json)


def run(scorer_model, as_json):
    if not as_json:
        print(scorer_model.format())
    else:
        print(json.dumps(scorer_model.format(formatting="json")))
<commit_msg>Implements info paths in model_info utility.<commit_after>"""
``revscoring model_info -h``
::

    Prints formatted information about a model file.


    Usage:
        module_info -h | --help
        module_info <model-file> <path>... --formatting=<type>

    Options:
        -h --help            Prints this documentation
        <model-file>         Path to a model file
        <path>               A model information path.  If no path is provided,
                             all default fields will be in the output.
        --formatting=<type>  What format to output the information?  "str" or
                             "json" [default: str]
"""
import json

import docopt

from ..scoring import Model


def main(argv=None):
    args = docopt.docopt(__doc__, argv=argv)
    model = Model.load(open(args['<model-file>'], 'rb'))
    paths = args['path']
    formatting = args['--formatting']

    run(model, paths, formatting)


def run(model, paths, formatting):
    formatted = model.info.format(paths, formatting=formatting)
    if formatting == "json":
        formatted = json.dumps(formatted, indent=2)

    print(formatted)

{'fraction_non_alphanumeric': 0.11956521739130435, 'fraction_numerical': 0.0005175983436853002, 'mean_word_length': 2.4395017793594307, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3933220', 'n_tokens_mistral': 604, 'n_tokens_neox': 580, 'n_words': 170}