Skip to content
Zach Leigh edited this page Apr 26, 2016 · 6 revisions

Contents

General

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)」 と呼びます。');

Method Index

Methods

convert()

Convert word properties to hiragana or katakana.

$word = $results->pull(0);

$katakanaOutput = $word->word();

// 'イギリス人'

$coverted = $word->convert('hiragana');

$hiraganaOutput = $word->convert('hiragana')->word();

// 'いぎりす人'

furigana()

Get furigana.

$word = $results->pluck(12);

$output = $word->furigana();

// '<ruby>呼<rt>よ</rt></ruby>びます'

get()

Get the word.

$word = $results->pull(0);

$output = $word->get();

// 'イギリス人'

grammar()

Get any grammar notes for the word. Most words do not yet have grammar notes.

$word = $results->pull(0);

$output = $word->grammar();

// Grammar, if any

lemma()

Get the word's lemma (dictionary form).

$word = $results->pull(12);

$output = $word->lemma();

// '呼ぶ'

parsed()

Returns true if word was successfully parsed, false if it was not. Occasionally, words are not able to be parsed by MeCab either because they are rare, slang, or written in uncommon way (e.g. kana instead of kanji).

$word = $results->pull(0);

$output = $word->parsed();

// true

parseLemma()

Parse the lemma with Limelight to get lemma readings, furigana, romaji etc. Returns a LimelightWord instance.

$word = $results->pull(12);

$output = $word->parseLemma()->reading();

// 'ヨブ'

partOfSpeech()

Get the word's part of speech.

$word = $results->pull(0);

$output = $word->partOfSpeech();

// 'proper noun'

plugin()

Get plugin data by plugin name.

$word = $results->pull(6);

$output = $word->plugin('romaji');

// 'yarō'

pronunciation()

Get the word's pronunciation. Long vowels are denoted by 'ー'.

$word = $results->pull(6);

$output = $word->pronunciation();

// 'ヤロー'

rawMecab()

Get the word's Mecab tokens. Output will be an array of token arrays.

$word = $results->pull(5);

$output = $word->rawMecab();
 
// [
//   0 => [   
//     'type' => 'parsed', 
//     'literal' => 'ライム',  
//     'partOfSpeech1' => 'meishi',
//     'partOfSpeech2' => '一般',  
//     'partOfSpeech3' => '*',  
//     'partOfSpeech4' => '*',  
//     'inflectionType' => '*',  
//     'inflectionForm' => '*',  
//     'lemma' => 'ライム',  
//     'reading' => 'ライム',  
//     'pronunciation' => 'ライム'  
//   ]  
// ] 

reading()

Get the word's reading.

$word = $results->pull(6);

$output = $word->reading();

// 'ヤロウ'

romaji()

Get romaji.

$word = $results->pull(0);

$output = $word->romaji();

// 'Igirisujin'

toArray()

Get the objects public properties as an array.

$word = $results->pull(6);

$output = $word->toArray();

// [
//   'rawMecab' => [
//     0 => [
//       'type => 'parsed',
//       'literal' => '野郎',
//       'partOfSpeech1' => 'meishi',
//       'partOfSpeech2' => '一般',
//       'partOfSpeech3' => '*',
//       'partOfSpeech4' => '*',
//       'inflectionType' => '*',
//       'inflectionForm' => '*',
//       'lemma' => '野郎',
//       'reading' => 'ヤロウ',
//       'pronunciation' => 'ヤロー'
//     ]
//   ],
//   'word' => '野郎',
//   'lemma' => '野郎',
//   'reading' => 'ヤロウ',
//   'pronunciation' => 'ヤロー',
//   'partOfSpeech' => 'noun',
//   'grammar' => 'NULL',
//   'parsed' => true,
//   'pluginData' => [
//     'Furigana' => '<ruby><rb>野郎</rb><rp>(</rp><rt>やろう</rt><rp>)</rp></ruby>',
//     'Romaji' => 'yarō'
//   ]
// ]

toHiragana()

Convert all kana to hiragana.

$word = $results->pull(0);

$output = $word->toHiragana()->reading();

// 'いぎりすじん'

toJson()

Convert the object to its JSON representation.

$word = $results->pull(1);

$output = $word->toJson();

// '{"rawMecab":[{"type":"parsed","literal":"\u306e","partOfSpeech1":"joshi","partOfSpeech2":"rentaika","partOfSpeech3":"*","partOfSpeech4":"*","inflectionType":"*","inflectionForm":"*","lemma":"\u306e","reading":"\u30ce","pronunciation":"\u30ce"}],"word":"\u306e","lemma":"\u306e","reading":"\u30ce","pronunciation":"\u30ce","partOfSpeech":"postposition","grammar":null,"parsed":true,"pluginData":{"Furigana":"\u306e","Romaji":"no"}}'

toKatakana()

Convert all kana to katakana.

$word = $results->pull(12);

$output = $word->toKatakana()->word();

// '呼ビマス'

word()

Get the word.

$word = $results->pull(0);

$output = $word->word();

// 'イギリス人'