Dictionary

The Dictionary object allows you to query definitions for a given word. It has a single function:

Dictionary:definitions( word )

Returns an array containing definitions for the word passed as a parameter. Each element of the array will be a table with the following elements:

  • simplified - the simplified character version of the word
  • traditional - the traditional character version of the word
  • pinyin - the pinyin of the word, using tones
  • pinyinNumbers - the pinyin of the word, using numbers
  • english - the English definition of the word

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
local cta = require 'cta'
local dictionary = cta.dictionary()

local definitions = dictionary:definitions( '云' )

for i, definition in ipairs( definitions ) do
    print( '-- Definition ' .. i )
    print( '\tSimplified: ', definition.simplified )
    print( '\tTraditional: ', definition.traditional )
    print( '\tPinyin (tones): ', definition.pinyin )
    print( '\tPinyin (numbers): ', definition.pinyinNumbers )
    print( '\tEnglish: ', definition.english )
end

Output

-- Definition 1
    Simplified:     
    Traditional:    
    Pinyin (tones):         yún
    Pinyin (numbers):       yun2
    English:        1. (classical) to say

-- Definition 2
    Simplified:     
    Traditional:    
    Pinyin (tones):         Yún
    Pinyin (numbers):       Yun2
    English:        1. surname Yun; 2. abbr. for Yunnan Province 雲南省|云南省[Yún nán shěng]

-- Definition 3
    Simplified:     
    Traditional:    
    Pinyin (tones):         yún
    Pinyin (numbers):       yun2
    English:        1. cloud; 2. CL:[duǒ]