= $minLength) && ($allowNumericWords || !is_numeric($word))) { $keywords[] = PKPString::substr($word, 0, static::SEARCH_KEYWORD_MAX_LENGTH); } } return $keywords; } /** * Return list of stopwords. * FIXME: Should this be locale-specific? * * @return array Stop words (in lower case) as keys and 1 as value */ protected static function loadStopwords() { static $searchStopwords; return $searchStopwords ??= array_fill_keys( collect(file(base_path(static::SEARCH_STOPWORDS_FILE))) ->map(fn (string $word) => trim($word)) // Ignore comments/line-breaks ->filter(fn (string $word) => !empty($word) && $word[0] !== '#') // Include a map for empty words ->push('') ->toArray(), 1 ); } /** * Let the indexing back-end know that the current transaction * finished so that the index can be batch-updated. */ abstract public function submissionChangesFinished(); /** * Signal to the indexing back-end that the metadata of a submission * changed. * * Push indexing implementations will try to immediately update * the index to reflect the changes. Pull implementations will * mark articles as "changed" and let the indexing back-end decide * the best point in time to actually index the changed data. * * @param Submission $submission */ abstract public function submissionMetadataChanged($submission); /** * Remove indexed file contents for a submission * * @param Submission $submission */ abstract public function clearSubmissionFiles($submission); /** * Delete a submission's search indexing * * @param int $type optional * @param int $assocId optional */ abstract public function deleteTextIndex( int $submissionId, $type = null, $assocId = null ); } if (!PKP_STRICT_MODE) { class_alias('\PKP\search\SubmissionSearchIndex', '\SubmissionSearchIndex'); foreach (['SEARCH_STOPWORDS_FILE', 'SEARCH_KEYWORD_MAX_LENGTH'] as $constantName) { define($constantName, constant('\SubmissionSearchIndex::' . $constantName)); } }