mirror of https://github.com/explosion/spaCy.git
Use pathlib instead of os.path
This commit is contained in:
parent
956dc36785
commit
958b12dec8
|
@ -139,9 +139,10 @@ def _min_edit_path(cand_words, gold_words):
|
||||||
|
|
||||||
|
|
||||||
def read_json_file(loc, docs_filter=None):
|
def read_json_file(loc, docs_filter=None):
|
||||||
if path.isdir(loc):
|
loc = Path(loc)
|
||||||
for filename in os.listdir(loc):
|
if loc.is_dir():
|
||||||
yield from read_json_file(path.join(loc, filename))
|
for filename in loc.iterdir():
|
||||||
|
yield from read_json_file(loc / filename)
|
||||||
else:
|
else:
|
||||||
with io.open(loc, 'r', encoding='utf8') as file_:
|
with io.open(loc, 'r', encoding='utf8') as file_:
|
||||||
docs = json.load(file_)
|
docs = json.load(file_)
|
||||||
|
|
Loading…
Reference in New Issue