mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
Tidy up info
This commit is contained in:
parent
189ed56777
commit
dc5d535659
|
@ -34,34 +34,36 @@ def info(
|
||||||
data = info_model(model, silent=silent)
|
data = info_model(model, silent=silent)
|
||||||
else:
|
else:
|
||||||
title = "Info about spaCy"
|
title = "Info about spaCy"
|
||||||
data = info_spacy(silent=silent)
|
data = info_spacy()
|
||||||
|
raw_data = {k.lower().replace(" ", "_"): v for k, v in data.items()}
|
||||||
|
if "Models" in data and isinstance(data["Models"], dict):
|
||||||
|
data["Models"] = ", ".join(f"{n} ({v})" for n, v in data["Models"].items())
|
||||||
markdown_data = get_markdown(data, title=title)
|
markdown_data = get_markdown(data, title=title)
|
||||||
if markdown:
|
if markdown:
|
||||||
if not silent:
|
if not silent:
|
||||||
print(markdown_data)
|
print(markdown_data)
|
||||||
return markdown_data
|
return markdown_data
|
||||||
if not silent:
|
if not silent:
|
||||||
msg.table(data, title=title)
|
table_data = dict(data)
|
||||||
return {k.lower().replace(" ", "_"): v for k, v in data.items()}
|
msg.table(table_data, title=title)
|
||||||
|
return raw_data
|
||||||
|
|
||||||
|
|
||||||
def info_spacy(*, silent: bool = True) -> Dict[str, any]:
|
def info_spacy() -> Dict[str, any]:
|
||||||
"""Generate info about the current spaCy intallation.
|
"""Generate info about the current spaCy intallation.
|
||||||
|
|
||||||
silent (bool): Don't print anything, just return.
|
|
||||||
RETURNS (dict): The spaCy info.
|
RETURNS (dict): The spaCy info.
|
||||||
"""
|
"""
|
||||||
all_models = {}
|
all_models = {}
|
||||||
for pkg_name in util.get_installed_models():
|
for pkg_name in util.get_installed_models():
|
||||||
package = pkg_name.replace("-", "_")
|
package = pkg_name.replace("-", "_")
|
||||||
all_models[package] = util.get_package_version(pkg_name)
|
all_models[package] = util.get_package_version(pkg_name)
|
||||||
models = ", ".join(f"{name} ({version})" for name, version in all_models.items())
|
|
||||||
return {
|
return {
|
||||||
"spaCy version": about.__version__,
|
"spaCy version": about.__version__,
|
||||||
"Location": str(Path(__file__).parent.parent),
|
"Location": str(Path(__file__).parent.parent),
|
||||||
"Platform": platform.platform(),
|
"Platform": platform.platform(),
|
||||||
"Python version": platform.python_version(),
|
"Python version": platform.python_version(),
|
||||||
"Models": models,
|
"Models": all_models,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user