src/Sanitizer.php
public function sanitizeWith( Tokenizer $tokenizer, StopwordAnalyzer $stopwordAnalyzer, Synonymizer $synonymizer ) {

		// Treat non-words tokenizers (Ja,Zh*) differently
		$minLength = $tokenizer->isWordTokenizer() ? $this->minLength : 1;

		$words = $tokenizer->tokenize( $this->string );

		if ( !$words || !is_array( $words ) ) {
			return $this->string;
		}

		$index = array();
		$pos = 0;

		foreach ( $words as $key => $word ) {

			$word = $synonymizer->synonymize( $word );

			// If it is not an exemption and less than the required minimum length
			// or identified as stop word it is removed
			if ( !isset( $this->whiteList[$word] ) && ( mb_strlen( $word ) < $minLength || $stopwordAnalyzer->isStopWord( $word ) ) ) {
				continue;
			}

			// Simple proximity, check for same words appearing next to each other
			if ( isset( $index[$pos-1] ) && $index[$pos-1] === $word ) {
				continue;
			}

			$index[] = trim( $word );
			$pos++;
		}

		return implode( ' ' , $index );
	}
public function sanitizeWith( Tokenizer $tokenizer, StopwordAnalyzer $stopwordAnalyzer, Synonymizer $synonymizer ) {

		// Treat non-words tokenizers (Ja,Zh*) differently
		$minLength = $tokenizer->isWordTokenizer() ? $this->minLength : 1;

		$words = $tokenizer->tokenize( $this->string );

		if ( !$words || !is_array( $words ) ) {
			return $this->string;
		}

		$index = array();
		$pos = 0;

		foreach ( $words as $key => $word ) {

			$word = $synonymizer->synonymize( $word );

			// If it is not an exemption and less than the required minimum length
			// or identified as stop word it is removed
			if ( !isset( $this->whiteList[$word] ) && ( mb_strlen( $word ) < $minLength || $stopwordAnalyzer->isStopWord( $word ) ) ) {
				continue;
			}

			// Simple proximity, check for same words appearing next to each other
			if ( isset( $index[$pos-1] ) && $index[$pos-1] === $word ) {
				continue;
			}

			$index[] = trim( $word );
			$pos++;
		}

		return implode( ' ' , $index );
	}
@since 0.1

@param Tokenizer $tokenizer
@param StopwordAnalyzer $stopwordAnalyzer

@return string