mirror of https://github.com/explosion/spaCy.git
* Allow json to be used as a fallback if ujson is not available
This commit is contained in:
parent
9da06671cf
commit
f4809e562f
|
@ -1,7 +1,5 @@
|
|||
import numpy
|
||||
import codecs
|
||||
import json
|
||||
import ujson
|
||||
import random
|
||||
import re
|
||||
import os
|
||||
|
@ -9,6 +7,11 @@ from os import path
|
|||
|
||||
from libc.string cimport memset
|
||||
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
|
||||
def tags_to_entities(tags):
|
||||
entities = []
|
||||
|
@ -128,7 +131,7 @@ def read_json_file(loc, docs_filter=None):
|
|||
yield from read_json_file(path.join(loc, filename))
|
||||
else:
|
||||
with open(loc) as file_:
|
||||
docs = ujson.load(file_)
|
||||
docs = json.load(file_)
|
||||
for doc in docs:
|
||||
if docs_filter is not None and not docs_filter(doc):
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue