PHP Class JpnForPhp\Analyzer\Analyzer

Author: Matthieu Bilbille
Datei anzeigen Open project: mbilbille/jpnforphp Class Usage Examples

Public Methods

Method Description
countHiragana ( string $str ) : integer Count number of hiragana within the specified string.
countKanji ( string $str, boolean $extended = false ) : integer Count number of kanji within the specified string.
countKatakana ( string $str ) : integer Count number of katakana within the specified string. Chōonpu (http://en.wikipedia.org/wiki/Chōonpu) is considered as Katakana here.
hasHiragana ( string $str ) : boolean Determines whether the given string contains hiragana characters.
hasJapaneseLetters ( string $str ) : boolean Determines whether the given string contains Japanese letters (kanji, hiragana or katakana).
hasJapaneseNumerals ( string $str ) : boolean Determines whether the given string contains Japanese numerals.
hasJapanesePunctuationMarks ( string $str ) : boolean Determines whether the given string contains Japanese punctuation marks.
hasJapaneseWritings ( string $str ) : boolean Determines whether the given string contains Japanese writings (kanji, hiragana, katakana or punctuation marks).
hasKana ( string $str ) : boolean Determines whether the given string contains kana (hiragana or katakana).
hasKanji ( string $str, boolean $extended = false ) : boolean Determines whether the given string contains kanji characters.
hasKatakana ( string $str ) : boolean Determines whether the given string contains katakana characters.
hasLatinLetters ( string $str ) : boolean Determines whether the given string contains latin letters
hasWesternNumerals ( string $str ) : boolean Determines whether the given string contains Western numerals.
inspect ( string $str ) : array Inspects a given string and returns useful details about it.
length ( string $str ) : integer Get string length.
segment ( string $str ) : array Segments the given string to its various part of speech components

Method Details

countHiragana() public static method

Count number of hiragana within the specified string.
public static countHiragana ( string $str ) : integer
$str string The input string.
return integer Returns the number of hiragana.

countKanji() public static method

Count number of kanji within the specified string.
public static countKanji ( string $str, boolean $extended = false ) : integer
$str string The input string.
$extended boolean Determines whether to use the extended kanji set
return integer Returns the number of kanji.

countKatakana() public static method

Count number of katakana within the specified string. Chōonpu (http://en.wikipedia.org/wiki/Chōonpu) is considered as Katakana here.
public static countKatakana ( string $str ) : integer
$str string The input string.
return integer Returns the number of katakana

hasHiragana() public static method

Determines whether the given string contains hiragana characters.
public static hasHiragana ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains at least one hiragana, otherwise FALSE.

hasJapaneseLetters() public static method

Determines whether the given string contains Japanese letters (kanji, hiragana or katakana).
See also: hasKanji()
See also: hasHiragana()
See also: hasKatakana()
public static hasJapaneseLetters ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains either kanji, hiragana or katakana, otherwise FALSE.

hasJapaneseNumerals() public static method

Determines whether the given string contains Japanese numerals.
public static hasJapaneseNumerals ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains Japanese numerals, otherwise FALSE.

hasJapanesePunctuationMarks() public static method

Determines whether the given string contains Japanese punctuation marks.
public static hasJapanesePunctuationMarks ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains Japanese punctuation marks, otherwise FALSE.

hasJapaneseWritings() public static method

Determines whether the given string contains Japanese writings (kanji, hiragana, katakana or punctuation marks).
See also: hasKanji()
See also: hasHiragana()
See also: hasKatakana()
public static hasJapaneseWritings ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains either kanji, hiragana, katakana or punctuation marks, otherwise FALSE.

hasKana() public static method

Determines whether the given string contains kana (hiragana or katakana).
See also: hasHiragana()
See also: hasKatakana()
public static hasKana ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains either hiragana or katakana, otherwise FALSE.

hasKanji() public static method

Determines whether the given string contains kanji characters.
public static hasKanji ( string $str, boolean $extended = false ) : boolean
$str string The string to inspect.
$extended boolean Determines whether to use the extended kanji set
return boolean TRUE if it contains at least one kanji, otherwise FALSE.

hasKatakana() public static method

Determines whether the given string contains katakana characters.
public static hasKatakana ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains at least one katakana, otherwise FALSE.

hasLatinLetters() public static method

Determines whether the given string contains latin letters
public static hasLatinLetters ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains latin letters, otherwise FALSE.

hasWesternNumerals() public static method

Determines whether the given string contains Western numerals.
public static hasWesternNumerals ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains Western numerals, otherwise FALSE.

inspect() public static method

Inspects a given string and returns useful details about it.
See also: length()
See also: countKanji()
See also: countHiragana()
See also: countKatakana()
public static inspect ( string $str ) : array
$str string The string to be inspected.
return array An associative array containing the following items: - "length" : string length. - "kanji" : number of kanji within this string. - "hiragana" : number of hiragana within this string. - "katakana" : number of katakana within this string.

length() public static method

Get string length.
See also: mb_strlen()
public static length ( string $str ) : integer
$str string The string being measured for length.
return integer Returns the number of characters in the input string. A multi-byte character is counted as 1.

segment() public static method

Segments the given string to its various part of speech components
public static segment ( string $str ) : array
$str string The string to segment
return array Segments parts of the given string