<commit_before><?php

/**
 * Manage attachments.
 *
 * @package wp-cli
 */
class Media_Command extends WP_CLI_Command {

	/**
	 * Regenerate thumbnail(s).
	 *
	 * ## OPTIONS
	 *
	 * [<attachment-id>...]
	 * : One or more IDs of the attachments to regenerate.
	 *
	 * [--yes]
	 * : Answer yes to the confirmation message.
	 *
	 * ## EXAMPLES
	 *
	 *     # re-generate all thumbnails, without confirmation
	 *     wp media regenerate --yes
	 *
	 *     # re-generate all thumbnails that have IDs between 1000 and 2000
	 *     seq 1000 2000 | xargs wp media regenerate
	 */
	function regenerate( $args, $assoc_args = array() ) {
		global $wpdb;

		if ( empty( $args ) ) {
			WP_CLI::confirm( 'Do you realy want to regenerate all images?', $assoc_args );
		}

		$query_args = array(
			'post_type' => 'attachment',
			'post__in' => $args,
			'post_mime_type' => 'image',
			'post_status' => 'any',
			'posts_per_page' => -1,
			'fields' => 'ids'
		);

		$images = new WP_Query( $query_args );

		$count = $images->post_count;

		if ( !$count ) {
			WP_CLI::warning( 'No images found.' );
			return;
		}

		WP_CLI::log( sprintf( 'Found %1$d %2$s to regenerate.', $count,
			ngettext( 'image', 'images', $count ) ) );

		foreach ( $images->posts as $id ) {<commit_msg>wp media regenerate: check if there is platform support for generating images before starting<commit_after><?php

/**
 * Manage attachments.
 *
 * @package wp-cli
 */
class Media_Command extends WP_CLI_Command {

	/**
	 * Regenerate thumbnail(s).
	 *
	 * ## OPTIONS
	 *
	 * [<attachment-id>...]
	 * : One or more IDs of the attachments to regenerate.
	 *
	 * [--yes]
	 * : Answer yes to the confirmation message.
	 *
	 * ## EXAMPLES
	 *
	 *     # re-generate all thumbnails, without confirmation
	 *     wp media regenerate --yes
	 *
	 *     # re-generate all thumbnails that have IDs between 1000 and 2000
	 *     seq 1000 2000 | xargs wp media regenerate
	 */
	function regenerate( $args, $assoc_args = array() ) {
		if ( !wp_image_editor_supports() ) {
			WP_CLI::error( 'No support for generating images found. ' .
				'Please install the Imagick or GD PHP extensions.' );
		}

		if ( empty( $args ) ) {
			WP_CLI::confirm( 'Do you realy want to regenerate all images?', $assoc_args );
		}

		$query_args = array(
			'post_type' => 'attachment',
			'post__in' => $args,
			'post_mime_type' => 'image',
			'post_status' => 'any',
			'posts_per_page' => -1,
			'fields' => 'ids'
		);

		$images = new WP_Query( $query_args );

		$count = $images->post_count;

		if ( !$count ) {
			WP_CLI::warning( 'No images found.' );
			return;
		}

		WP_CLI::log( sprintf( 'Found %1$d %2$s to regenerate.', $count,
			ngettext( 'image', 'images', $count ) ) );

		foreach ( $images->posts as $id ) {
{'fraction_non_alphanumeric': 0.15345454545454545, 'fraction_numerical': 0.013818181818181818, 'mean_word_length': 2.9525862068965516, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '6850179', 'n_tokens_mistral': 1102, 'n_tokens_neox': 939, 'n_words': 266}