mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-13 05:07:03 +03:00
Simplify function
This commit is contained in:
parent
ce7eec846b
commit
5c966d0874
|
@ -83,16 +83,11 @@ def print_markdown(data, title=None):
|
||||||
data (dict or list of tuples): Label/value pairs.
|
data (dict or list of tuples): Label/value pairs.
|
||||||
title (unicode or None): Title, will be rendered as headline 2.
|
title (unicode or None): Title, will be rendered as headline 2.
|
||||||
"""
|
"""
|
||||||
|
markdown = []
|
||||||
def excl_value(value):
|
for key, value in data.items():
|
||||||
# contains path, i.e. personal info
|
if isinstance(value, basestring_) and Path(value).exists():
|
||||||
return isinstance(value, basestring_) and Path(value).exists()
|
continue
|
||||||
|
markdown.append("* **{}:** {}".format(key, unicode_(value)))
|
||||||
if isinstance(data, dict):
|
|
||||||
data = list(data.items())
|
|
||||||
markdown = [
|
|
||||||
"* **{}:** {}".format(l, unicode_(v)) for l, v in data if not excl_value(v)
|
|
||||||
]
|
|
||||||
if title:
|
if title:
|
||||||
print("\n## {}".format(title))
|
print("\n## {}".format(title))
|
||||||
print("\n{}\n".format("\n".join(markdown)))
|
print("\n{}\n".format("\n".join(markdown)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user