* Allow json to be used as a fallback if ujson is not available

This commit is contained in:
Matthew Honnibal 2015-07-25 18:11:36 +02:00
parent 9da06671cf
commit f4809e562f
1 changed files with 6 additions and 3 deletions

View File

@ -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