<commit_before># coding: utf8
from __future__ import unicode_literals

import platform
from pathlib import Path

from ..compat import path2str
from .. import about
from .. import util


def info(model=None, markdown=False):
    if model:
        data_path = util.get_data_path()
        data = util.parse_package_meta(data_path / model, require=True)
        model_path = Path(__file__).parent / data_path / model
        if model_path.resolve() != model_path:
            data['link'] = path2str(model_path)
            data['source'] = path2str(model_path.resolve())
        else:
            data['source'] = path2str(model_path)
        print_info(data, 'model %s' % model, markdown)
    else:
        data = {'spaCy version': about.__version__,
                'Location': path2str(Path(__file__).parent.parent),
                'Platform': platform.platform(),
                'Python version': platform.python_version(),
                'Models': list_models()}
        print_info(data, 'spaCy', markdown)


def print_info(data, title, markdown):
    title = 'Info about %s' % title
    if markdown:
        util.print_markdown(data, title=title)
    else:
        util.print_table(data, title=title)


def list_models():
    def exclude_dir(dir_name):
        # exclude common cache directories and hidden directories
        exclude = ['cache', 'pycache', '__pycache__']
        return dir_name in exclude or dir_name.startswith('.')
    data_path = util.get_data_path()
    if data_path:
        models = [f.parts[-1] for f in data_path.iterdir() if f.is_dir()]
        return ', '.join([m for m in models if not exclude_dir(m)])
    return '-'
<commit_msg>Resolve model name properly in cli.info<commit_after># coding: utf8
from __future__ import unicode_literals

import platform
from pathlib import Path

from ..compat import path2str
from .. import about
from .. import util


def info(model=None, markdown=False):
    if model:
        model_path = util.resolve_model_path(model)
        meta = util.parse_package_meta(model_path)
        if model_path.resolve() != model_path:
            meta['link'] = path2str(model_path)
            meta['source'] = path2str(model_path.resolve())
        else:
            meta['source'] = path2str(model_path)
        print_info(meta, 'model %s' % model, markdown)
    else:
        data = {'spaCy version': about.__version__,
                'Location': path2str(Path(__file__).parent.parent),
                'Platform': platform.platform(),
                'Python version': platform.python_version(),
                'Models': list_models()}
        print_info(data, 'spaCy', markdown)


def print_info(data, title, markdown):
    title = 'Info about %s' % title
    if markdown:
        util.print_markdown(data, title=title)
    else:
        util.print_table(data, title=title)


def list_models():
    def exclude_dir(dir_name):
        # exclude common cache directories and hidden directories
        exclude = ['cache', 'pycache', '__pycache__']
        return dir_name in exclude or dir_name.startswith('.')
    data_path = util.get_data_path()
    if data_path:
        models = [f.parts[-1] for f in data_path.iterdir() if f.is_dir()]
        return ', '.join([m for m in models if not exclude_dir(m)])
    return '-'

{'fraction_non_alphanumeric': 0.11621539397627015, 'fraction_numerical': 0.0042592029205962886, 'mean_word_length': 2.7577142857142856, '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': '6841347', 'n_tokens_mistral': 1003, 'n_tokens_neox': 981, 'n_words': 257}