-
Notifications
You must be signed in to change notification settings - Fork 28
LimelightWord
LimelightWord objects contain all information gained from the Limelight parse() method. Each LimelightWord object holds information for exactly one word. Unlike LimelightResults methods which are plural, LimelightWord methods are all singular.
All examples in this section will use the following text.
$results = $limelight->parse('イギリス人のことを 「ライム野郎 (limey)」 と呼びます。');
All basic methods follow the same general syntax.
/**
* Get property.
*
* @return string/array
*/
method();
Get the word.
$word = $results->findIndex(0);
echo $word->get();
Output: イギリス人
Get the word.
$word = $results->findIndex(0);
echo $word->word();
Output: イギリス人
Get the word's reading.
$word = $results->findIndex(6);
echo $word->reading();
Output: ヤロウ
Get the word's pronunciation. Long vowels are denoted by 'ー'.
$word = $results->findIndex(6);
echo $word->pronunciation();
Output: ヤロー
Get the word's lemma (dictionary form).
$word = $results->findIndex(12);
echo $word->lemma();
Output: 呼ぶ
Get the word's part of speech.
$word = $results->findIndex(0);
echo $word->partOfSpeech();
Output: proper noun
Get any grammar notes for the word. Most words do not yet have grammar notes.
$word = $results->findIndex(0);
$word->grammar();
Get the word's Mecab tokens. Output will be an array of token arrays.
$word = $results->findIndex(5);
print_r($word->rawMecab());
Output
Array
(
[0] => Array
(
[type] => parsed
[literal] => ライム
[partOfSpeech1] => meishi
[partOfSpeech2] => 一般
[partOfSpeech3] => *
[partOfSpeech4] => *
[inflectionType] => *
[inflectionForm] => *
[lemma] => ライム
[reading] => ライム
[pronunciation] => ライム
)
)
Conversion methods can be used before the above properties to convert items to hiragana, katakana, furigana, or romaji. Furigana and romaji conversion is performed by plugins. These plugins are activated by default, but if they have been deleted or un-registered in config.php, the conversion will fail.
All methods take no arguments.
Convert text to hiragana.
$word = $results->findIndex(0);
echo $word->toHiragana()->word();
Output: いぎりすじん
Convert text to katakana.
$word = $results->findIndex(12);
echo $word->toKatakana()->word();
Output: ヨビマス
Convert text to furigana.
$word = $results->findIndex(12);
echo $word->toFurigana()->word();
Output: 呼びます
Convert text to romaji.
$word = $results->findIndex(0);
echo $word->toRomaji()->word();
Output: Igirisujin
Get basic info about word.
$word = $results->findIndex(6);
echo $word;
Output:
Word: 野郎
Part of Speech: noun
Lemma: 野郎
Reading: ヤロウ
Pronunciation: ヤロー