protected function format_results( array $patterns, array $exceptions, array $comments ) {
		$pattern_mapping = [];

		foreach ( $patterns as $pattern ) {
			$segment = $this->get_segment( $pattern );

			if ( ! isset( $pattern_mapping[ $segment ] ) ) {
				$pattern_mapping[ $segment ] = $this->get_sequence( $pattern );
			}
		}

		// Produce a nice exceptions mapping.
		$json_exceptions = [];
		foreach ( $exceptions as $exception ) {
			$json_exceptions[ mb_strtolower( str_replace( '-', '', $exception ) ) ] = mb_strtolower( $exception );
		}

		$json_results = [
			'language'    => $this->language,
			'source_url'  => count( $this->urls ) > 1 ? $this->urls : $this->urls[0],
			'copyright'   => array_map( 'rtrim', $comments ),
			'exceptions'  => $json_exceptions,
			'patterns'    => $pattern_mapping,
		];

		return json_encode( $json_results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
	}