Stems a word. Simple huh?

@param  string $word Word to stem
@return string       Stemmed 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;
    }
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;
    }
395030
public static function singular($word)
    {
        if(is_array($word)) {
            $keys = array_keys($word);
            $size = sizeof($keys);

            for($i = 0; $i < $size; $i++) {
                $word[$keys[$size]] = Str::singular($word);
            }

            return $word;
        }

        return Inflector::singular($word);
    }
1334227
protected function stemSingularWord($word)
    {
        $context = new Context($word, $this->dictionary, $this->visitorProvider);
        $context->execute();

        return $context->getResult();
    }
367707
public static function pluralize($word)
    {
        if (isset(self::$_cache['pluralize'][$word])) {
            return self::$_cache['pluralize'][$word];
        }

        if (!isset(self::$_plural['merged']['irregular'])) {
            self::$_plural['merged']['irregular'] = self::$_plural['irregular'];
        }

        if (!isset(self::$_plural['merged']['uninflected'])) {
            self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected);
        }

        if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) {
            self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')';
            self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')';
        }

        if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
            return self::$_cache['pluralize'][$word];
        }

        if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $word;
            return $word;
        }

        foreach (self::$_plural['rules'] as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
                return self::$_cache['pluralize'][$word];
            }
        }
    }
1282599
public static function singularize(string $word): string
	{
		if (isset(static::$_cache['singularize'][$word])) {
			return static::$_cache['singularize'][$word];
		}

		if (!isset(static::$_cache['irregular']['singular'])) {
			static::$_cache['irregular']['singular'] = '(?:' . \implode('|', static::$_irregular) . ')';
		}

		if (\preg_match('/(.*?(?:\\b|_))(' . static::$_cache['irregular']['singular'] . ')$/i', $word, $regs)) {
			static::$_cache['singularize'][$word] = $regs[1] . $regs[2][0] .
				\substr(\array_search(\strtolower($regs[2]), static::$_irregular, true), 1);

			return static::$_cache['singularize'][$word];
		}

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

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

			return $word;
		}

		foreach (static::$_singular as $rule => $replacement) {
			if (\preg_match($rule, $word)) {
				static::$_cache['singularize'][$word] = \preg_replace($rule, $replacement, $word);

				return static::$_cache['singularize'][$word];
			}
		}
		static::$_cache['singularize'][$word] = $word;

		return $word;
	}
827281
public static function pluralize(string $word): string
	{
		if (isset(static::$_cache['pluralize'][$word])) {
			return static::$_cache['pluralize'][$word];
		}

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

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

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

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

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

			return $word;
		}

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

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

		return $word;
	}
312841
protected function singularize($word)
    {
        $result = strval($word);

        if (in_array(strtolower($result), $this->uncountableWords())) {
            return $result;
        } else {
            foreach ($this->singularRules() as $rule => $replacement) {
                if (preg_match($rule, $result)) {
                    $result = preg_replace($rule, $replacement, $result);
                    break;
                }
            }

            return $result;
        }
    }
935364
public static function pluralize($word)
    {
        //Get the cached noun of it exists
        if(isset(self::$_cache['pluralized'][$word])) {
            return self::$_cache['pluralized'][$word];
        }

        //Create the plural noun
        if (in_array($word, self::$_rules['countable'])) {
            self::$_cache['pluralized'][$word] = $word;
            return $word;
        }

        foreach (self::$_rules['pluralization'] as $regexp => $replacement)
        {
            $matches = null;
            $plural = preg_replace($regexp, $replacement, $word, -1, $matches);
            if ($matches > 0) {
                self::$_cache['pluralized'][$word] = $plural;
                return $plural;
            }
        }

        return $word;
    }
1209435
public function stem($word)
    {
        $this->j=0;
        $this->b = $word;
        $this->k = strlen($word)-1;
        if ($this->k<=1)
            return $word;

        $this->step1ab();
        $this->step1c();
        $this->step2();
        $this->step3();
        $this->step4();
        $this->step5();

        return substr($this->b,0,$this->k+1);
    }
445040
private static function step0a($word)
    {
        $word = str_replace(array('ä','ö','ü'), array('A','O','U'), $word);
        $vstr = implode('', self::$vowels);
        $word = preg_replace('#(['.$vstr.'])u(['.$vstr.'])#', '$1Z$2', $word);
        $word = preg_replace('#(['.$vstr.'])y(['.$vstr.'])#', '$1Y$2', $word);

        return $word;
    }
156555
public static function singularize($word)
    {
        $singular = array (
        '/(quiz)zes$/i' => '\1',
        '/(matr)ices$/i' => '\1ix',
        '/(vert|ind)ices$/i' => '\1ex',
        '/^(ox)en/i' => '\1',
        '/(alias|status)es$/i' => '\1',
        '/([octop|vir])i$/i' => '\1us',
        '/(cris|ax|test)es$/i' => '\1is',
        '/(shoe)s$/i' => '\1',
        '/(o)es$/i' => '\1',
        '/(bus)es$/i' => '\1',
        '/([m|l])ice$/i' => '\1ouse',
        '/(x|ch|ss|sh)es$/i' => '\1',
        '/(m)ovies$/i' => '\1ovie',
        '/(s)eries$/i' => '\1eries',
        '/([^aeiouy]|qu)ies$/i' => '\1y',
        '/([lr])ves$/i' => '\1f',
        '/(tive)s$/i' => '\1',
        '/(hive)s$/i' => '\1',
        '/([^f])ves$/i' => '\1fe',
        '/(^analy)ses$/i' => '\1sis',
        '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
        '/([ti])a$/i' => '\1um',
        '/(n)ews$/i' => '\1ews',
        '/s$/i' => '',
        );

        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');

        $irregular = array(
        'person' => 'people',
        'man' => 'men',
        'child' => 'children',
        'sex' => 'sexes',
        'move' => 'moves');

        $lowercased_word = strtolower($word);
        foreach ($uncountable as $_uncountable){
            if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){
                return $word;
            }
        }

        foreach ($irregular 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 ($singular as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                return preg_replace($rule, $replacement, $word);
            }
        }

        return $word;
    }
583081
def stem(self, word):
        """"""
        if self.stemmer:
            return unicode_to_ascii(self._stemmer.stem(word))
        else:
            return word
1334810
public static function singular($word)
    {
        $definitions = Config::getPluralDefinitions();

        if (($singular = array_search($word, $definitions)) !== false) {
            return $singular;
        }

        return LaravelStr:: singular($word);
    }
1283981
public function suggest($word) 
    {
        if (!pspell_check($this->pSpell, $word)) {
            return pspell_suggest($this->pSpell, $word);
        }
        else {
            return [$word];
        }
    }
328099
def stem(self, word):
        

        if len(word) <= 2:
            return word
        else:
            word = self.remove_initial_apostrophe(word)
            word = self.set_ys(word)
            self.find_regions(word)

            word = self.strip_possessives(word)
            word = self.replace_suffixes_1(word)
            word = self.replace_suffixes_2(word)
            word = self.replace_ys(word)
            word = self.replace_suffixes_3(word)
            word = self.replace_suffixes_4(word)
            word = self.delete_suffixes(word)
            word = self.process_terminals(word)

            return word
692692
public static function pluralize($word) {
        if ($word == "clicktocall") {
            return $word;
        }

        switch(strtolower($word[strlen($word) - 1])) {
        case 'y':
            return substr($word, 0, -1) . 'ies';
        case 's':
        case 'h':
        case 'x':
            return $word. 'es';
        default:
            return $word . 's';
        }
    }