<commit_before># coding: utf8
from __future__ import unicode_literals

import sys
import ujson
from pathlib import Path


def read_json(location):
    """Open and load JSON from file.

    location (Path): The file path. "-" for reading from stdin.
    RETURNS (dict): Loaded JSON content.
    """
    if location == "-":  # reading from sys.stdin
        data = sys.stdin.read()
        return ujson.load(data)
    file_path = _force_path(location)
    with file_path.open("r", encoding="utf8") as f:
        return ujson.load(f)


def write_json(location, contents, indent=2):
    """Create a .json file and dump contents.

    location (unicode / Path): The file path. "-" for writing to stdout.
    contents: The JSON-serializable contents to output.
    indent (int): Number of spaces used to indent JSON.
    """
    data = _json_dumps(contents, indent=indent)
    if location == "-":  # writing to stdout
        sys.stdout.write(data)
        return<commit_msg>Import ujson from srsly.json<commit_after># coding: utf8
from __future__ import unicode_literals

import sys
from pathlib import Path

from .json import ujson


def read_json(location):
    """Open and load JSON from file.

    location (Path): The file path. "-" for reading from stdin.
    RETURNS (dict): Loaded JSON content.
    """
    if location == "-":  # reading from sys.stdin
        data = sys.stdin.read()
        return ujson.load(data)
    file_path = _force_path(location)
    with file_path.open("r", encoding="utf8") as f:
        return ujson.load(f)


def write_json(location, contents, indent=2):
    """Create a .json file and dump contents.

    location (unicode / Path): The file path. "-" for writing to stdout.
    contents: The JSON-serializable contents to output.
    indent (int): Number of spaces used to indent JSON.
    """
    data = _json_dumps(contents, indent=indent)
    if location == "-":  # writing to stdout
        sys.stdout.write(data)
        return
{'fraction_non_alphanumeric': 0.1078880407124682, 'fraction_numerical': 0.0030534351145038168, 'mean_word_length': 2.9717171717171715, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2169461', 'n_tokens_mistral': 599, 'n_tokens_neox': 586, 'n_words': 206}