From f4809e562f8d1330ee7d91cd90e1b6ca24d232f4 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 25 Jul 2015 18:11:36 +0200 Subject: [PATCH] * Allow json to be used as a fallback if ujson is not available --- spacy/gold.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spacy/gold.pyx b/spacy/gold.pyx index 57473b002..183eed0cf 100644 --- a/spacy/gold.pyx +++ b/spacy/gold.pyx @@ -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