<commit_before><?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Entities\ShowSong;
use Entities\Track;
use Entities\TrackType;

class ClassifyMLPMA extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'mlpma:classify';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Adds Pony.fm-specific metadata to imported MLPMA tracks.';

	/**
	 * A counter for the number of processed tracks.
	 *
	 * @var int
	 */
	protected $currentTrack = 0;

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		// Get the list of tracks that need classification
		$tracks = DB::table('mlpma_tracks')
			->orderBy('id')
			->get();

		$this->comment('Importing tracks...');

		$totalTracks = sizeof($tracks);

		$fileToStartAt = (int) $this->option('startAt') - 1;
		$this->comment("Skipping $fileToStartAt files..." . PHP_EOL);

		$tracks = array_slice($tracks, $fileToStartAt);
		$this->currentTrack = $fileToStartAt;

		foreach ($tracks as $track) {
			$this->currentTrack++;
			$this->comment('[' . $this->currentTrack . '/' . $totalTracks . '] Classifying track [' . $track->filename . ']...');

			$parsedTags = json_decode($track->parsed_tags, true);


			//==========================================================================================================
			// Original, show song remix, fan song remix, show audio remix, or ponified song?
			//==========================================================================================================
			$sanitizedTrackTitle = $parsedTags['title'];
			$sanitizedTrackTitle = str_replace([' - ', 'ft.', '*'], ' ', $sanitizedTrackTitle);

			$queriedTitle = DB::connection()->getPdo()->quote($sanitizedTrackTitle);
			$officialSongs = ShowSong::select(['id', 'title'])
				->whereRaw("
				MATCH (title)
                AGAINST ($queriedTitle IN BOOLEAN MODE)
                ")
				->get();


			// If it has "Ingram" in the name, it's definitely an official song remix.
			if (Str::contains(Str::lower($track->filename), 'ingram')) {
				$this->info('This is an official song remix!');

				list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, true);

<commit_msg>T357: Removed + symbols from the classifier's fulltext query.<commit_after><?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Entities\ShowSong;
use Entities\Track;
use Entities\TrackType;

class ClassifyMLPMA extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'mlpma:classify';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Adds Pony.fm-specific metadata to imported MLPMA tracks.';

	/**
	 * A counter for the number of processed tracks.
	 *
	 * @var int
	 */
	protected $currentTrack = 0;

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		// Get the list of tracks that need classification
		$tracks = DB::table('mlpma_tracks')
			->orderBy('id')
			->get();

		$this->comment('Importing tracks...');

		$totalTracks = sizeof($tracks);

		$fileToStartAt = (int) $this->option('startAt') - 1;
		$this->comment("Skipping $fileToStartAt files..." . PHP_EOL);

		$tracks = array_slice($tracks, $fileToStartAt);
		$this->currentTrack = $fileToStartAt;

		foreach ($tracks as $track) {
			$this->currentTrack++;
			$this->comment('[' . $this->currentTrack . '/' . $totalTracks . '] Classifying track [' . $track->filename . ']...');

			$parsedTags = json_decode($track->parsed_tags, true);


			//==========================================================================================================
			// Original, show song remix, fan song remix, show audio remix, or ponified song?
			//==========================================================================================================
			$sanitizedTrackTitle = $parsedTags['title'];
			$sanitizedTrackTitle = str_replace(['-', '+', 'ft.', '*'], ' ', $sanitizedTrackTitle);

			$queriedTitle = DB::connection()->getPdo()->quote($sanitizedTrackTitle);
			$officialSongs = ShowSong::select(['id', 'title'])
				->whereRaw("
				MATCH (title)
                AGAINST ($queriedTitle IN BOOLEAN MODE)
                ")
				->get();


			// If it has "Ingram" in the name, it's definitely an official song remix.
			if (Str::contains(Str::lower($track->filename), 'ingram')) {
				$this->info('This is an official song remix!');

				list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, true);


{'fraction_non_alphanumeric': 0.23401306671946148, 'fraction_numerical': 0.0013858641853098396, 'mean_word_length': 3.881159420289855, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '219192', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1468, 'n_words': 361}