*/ public array $unique_words; /** * @since 1.0.0 * * @param string $text The phrase text. * @param string $sentence Optional. Surrounding sentence. * Default empty (treats phrase as its own sentence). * @param int $index Optional. Position within source. Default 0. * @param array $unique_words Optional. Stemmed word counts. Default []. */ public function __construct( string $text, string $sentence = '', int $index = 0, array $unique_words = array() ) { $this->text = $text; $this->sentence = '' !== $sentence ? $sentence : $text; $this->index = $index; $this->unique_words = $unique_words; } /** * Returns whether this phrase contains the given stemmed word. * * @since 1.0.0 * * @param string $stemmed_word Already-stemmed word to look up. * * @return bool True when present. */ public function contains_word( string $stemmed_word ): bool { return isset( $this->unique_words[ $stemmed_word ] ); } }