Get the replacement for given word

@param  string $word Original word
@return string       Replacement if the word is censored, or the original word otherwise
13941
protected function getReplacement($word)
	{
		if ($this->isAllowed($word))
		{
			return $word;
		}

		foreach ($this->replacements as list($regexp, $replacement))
		{
			if (preg_match($regexp, $word))
			{
				return $replacement;
			}
		}

		return $this->defaultReplacement;
	}
709644
public function getWord(string $word)
    {
        if (isset($this->words[strtolower($word)])) {
            return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]);
        }

        return new Word($word);
    }
1331601
public function underscore($word)
    {
        if (false !== stristr($word, '-')) {
            $parts = explode('-', $word);
            foreach ($parts as &$part) {
                $part = ucfirst(strtolower($part));
            }
            $word = implode('', $parts);
        }
        return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
    }
370650
public static function pluralize(string $word): string
    {
        if (isset(static::$inflectorCache['pluralize'][$word])) {
            return static::$inflectorCache['pluralize'][$word];
        }

        if (!isset(static::$inflectorCache['irregular']['pluralize'])) {
            static::$inflectorCache['irregular']['pluralize'] = '(?:' . implode('|', array_keys(static::$irregular)) . ')';
        }

        if (preg_match('/(.*?(?:\\b|_))(' . static::$inflectorCache['irregular']['pluralize'] . ')$/i', $word, $regs)) {
            static::$inflectorCache['pluralize'][$word] = $regs[1] . substr($regs[2], 0, 1) .
                substr(static::$irregular[strtolower($regs[2])], 1);

            return static::$inflectorCache['pluralize'][$word];
        }

        if (!isset(static::$inflectorCache['uninflected'])) {
            static::$inflectorCache['uninflected'] = '(?:' . implode('|', static::$uninflected) . ')';
        }

        if (preg_match('/^(' . static::$inflectorCache['uninflected'] . ')$/i', $word, $regs)) {
            static::$inflectorCache['pluralize'][$word] = $word;

            return $word;
        }

        foreach (static::$plural as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                static::$inflectorCache['pluralize'][$word] = preg_replace($rule, $replacement, $word);

                return static::$inflectorCache['pluralize'][$word];
            }
        }

        return $word;
    }
228311
public function delete($word) {
    	try{
			if (empty($word))
				throw new Exception('Paramer "word" is required');


    		$params = array (
    		'word' => $word
    		);

    		$ret = $this->SendRequest->curl('/wordfilter/delete.json',$params,'urlencoded','im','POST');
    		if(empty($ret))
    			throw new Exception('bad request');
    		return $ret;

    	}catch (Exception $e) {
    		print_r($e->getMessage());
    	}
   }
940153
public String replace(String word) {
        int flags = 0;
        if (ignoreCase) {
            flags = flags | Pattern.CASE_INSENSITIVE;
        }
        return Pattern.compile(pattern, flags).matcher(word).replaceAll(replacement);
    }
552091
public static function plural(string $word) : string
    {
        // Check that `$word` is countable.
        if(in_array($word, Inflector::$_uncontable)) {
            return $word;
        }

        // Now check that `$word` is regular.
        if(isset(Inflector::$_plural["irregular"][$word])) {
            return Inflector::$_plural["irregular"][$word];
        }

        // Now check that `$word` can be pluralize.
        foreach(Inflector::$_plural["uninflected"] as $rule) {
            if(preg_match("/^". $rule ."$/", $word)) {
                return $word;
            }
        }

        // Now the word follows a rule, so apply it
        foreach(Inflector::$_plural["rules"] as $key => $value) {
            if(preg_match($key, $word)) {
                return preg_replace($key, $value, $word);
            }
        }

        // Well, right now the word couldn't be pluralized
        // so return it as it was (or throw an exception?)
        return $word;
    }
464688
private static function step2($word)
	{
		switch (substr($word, -2, 1))
		{
			case 'a':
					self::replace($word, 'ational', 'ate', 0)
				or self::replace($word, 'tional', 'tion', 0);
				break;

			case 'c':
					self::replace($word, 'enci', 'ence', 0)
				or self::replace($word, 'anci', 'ance', 0);
				break;

			case 'e':
				self::replace($word, 'izer', 'ize', 0);
				break;

			case 'g':
				self::replace($word, 'logi', 'log', 0);
				break;

			case 'l':
					self::replace($word, 'entli', 'ent', 0)
				or self::replace($word, 'ousli', 'ous', 0)
				or self::replace($word, 'alli', 'al', 0)
				or self::replace($word, 'bli', 'ble', 0)
				or self::replace($word, 'eli', 'e', 0);
				break;

			case 'o':
					self::replace($word, 'ization', 'ize', 0)
				or self::replace($word, 'ation', 'ate', 0)
				or self::replace($word, 'ator', 'ate', 0);
				break;

			case 's':
					self::replace($word, 'iveness', 'ive', 0)
				or self::replace($word, 'fulness', 'ful', 0)
				or self::replace($word, 'ousness', 'ous', 0)
				or self::replace($word, 'alism', 'al', 0);
				break;

			case 't':
					self::replace($word, 'biliti', 'ble', 0)
				or self::replace($word, 'aliti', 'al', 0)
				or self::replace($word, 'iviti', 'ive', 0);
				break;
		}

		return $word;
	}
934393
private static function _getPrefix($word)
    {
        $questionMarkPosition = strpos($word, '?');
        $astrericPosition     = strpos($word, '*');

        if ($questionMarkPosition !== false) {
            if ($astrericPosition !== false) {
                return substr($word, 0, min($questionMarkPosition, $astrericPosition));
            }

            return substr($word, 0, $questionMarkPosition);
        } else if ($astrericPosition !== false) {
            return substr($word, 0, $astrericPosition);
        }

        return $word;
    }
31514
private static function step3($word)
    {
        switch (substr($word, -2, 1)) {
            case 'a':
                self::replace($word, 'ical', 'ic', 0);
                break;

            case 's':
                self::replace($word, 'ness', '', 0);
                break;

            case 't':
                self::replace($word, 'icate', 'ic', 0)
                || self::replace($word, 'iciti', 'ic', 0);
                break;

            case 'u':
                self::replace($word, 'ful', '', 0);
                break;

            case 'v':
                self::replace($word, 'ative', '', 0);
                break;

            case 'z':
                self::replace($word, 'alize', 'al', 0);
                break;
        }

        return $word;
    }
1005318
public static function singularize($word)
    {

        static::$uncountables = array(
            'equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'media'
        );
        static::$irregulars = array(
            'person'  => 'people',
            'man'     => 'men',
            'child'   => 'children',
            'sex'     => 'sexes',
            'move'    => 'moves'
        );
        $lowerCasedWord = strtolower($word);
        foreach (static::$uncountables as $uncountable) {
            if (substr($lowerCasedWord, (-1 * strlen($uncountable))) == $uncountable) {
                return $word;
            }
        }
        foreach (static::$irregulars as $plural => $singular) {
            if (preg_match('/(' . $singular.')$/i', $word, $arr)) {
                return preg_replace(
                    '/(' . $singular . ')$/i',
                    substr($arr[0], 0, 1) . substr($plural, 1),
                    $word
                );
            }
        }
        foreach (static::$singulars as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                return preg_replace($rule, $replacement, $word);
            }
        }

        return $word;
    }
906711
public static function underscore($word) {
		if (isset(static::$_underscored[$word])) {
			return static::$_underscored[$word];
		}
		return static::$_underscored[$word] = strtolower(static::slug($word, '_'));
	}
369384
public function grep( $word ) {
		$found = array();
		foreach($this->logs as $log) {
			if (strpos($log,$word)!==false) {
				$found[] = $log;
			}
		}
		return $found;
	}
1280870
public static function stem($word)
    {
        $word = mb_strtolower($word);
        //check for invalid characters
        preg_match("#.#u", $word);
        if (preg_last_error() !== 0) {
            throw new \InvalidArgumentException("Word '$word' seems to be errornous. Error code from preg_last_error(): " . preg_last_error());
        }
        if (!isset(self::$cache[$word])) {
            $result             = self::getStem($word);
            self::$cache[$word] = $result;
        }

        return self::$cache[$word];
    }
1104998
public static function underscore($word)
        {
            if (isset(static::$_underscored[$word])) {
                return static::$_underscored[$word];
            }

            return static::$_underscored[$word] = static::lower(static::slug($word, '_'));
        }
180508
public static function Stem($word)
    {
        if (strlen($word) <= 2) {
            return $word;
        }

        $word = self::step1ab($word);
        $word = self::step1c($word);
        $word = self::step2($word);
        $word = self::step3($word);
        $word = self::step4($word);
        $word = self::step5($word);

        return $word;
    }
307107
private static function step5($word)
	{
		// Part a
		if (substr($word, -1) == 'e')
		{
			if (self::m(substr($word, 0, -1)) > 1)
			{
				self::replace($word, 'e', '');
			}
			elseif (self::m(substr($word, 0, -1)) == 1)
			{
				if (!self::cvc(substr($word, 0, -1)))
				{
					self::replace($word, 'e', '');
				}
			}
		}

		// Part b
		if (self::m($word) > 1 && self::doubleConsonant($word) && substr($word, -1) == 'l')
		{
			$word = substr($word, 0, -1);
		}

		return $word;
	}