A: XMLVocabulary


Please note that this is still an iKnow specific standard, we are very open to modifications and to evolving this standard so it can benefit others. On a sidenote: we are also in the midst of specifying an hVocabulary Microformat for this.

The main purpose of this format is being able to structure Vocabulary content. At the heart of these vocabularies are cues and responses - the basis of memorization. Secondly there is structure to supply additional Vocabulary content like images, sounds and sample sentences.

With this first draft of the format you can specify:

  • Item Cue with part of speech
  • Item Response
  • Item sample sentences
  • All rich assets

Example XML

An example of Vocabulary in XML, CDATA is omitted for ease of reading.

  1. <vocabulary xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iknow.co.jp/api/specifications/vocabulary/1.0" version="1.0">  
  2.   <items>  
  3.     <item id="437406">  
  4.       <cue language="ja" part_of_speech="Noun">  
  5.         <text>ほんとう</text>  
  6.         <sound>http://media4.cerego.co.jp/contents/JLL/audio/JW08605A.mp3</sound>  
  7.         <transliterations>  
  8.           <transliteration type="Latn"><![CDATA[hontou]]></transliteration>  
  9.         </transliterations>  
  10.       </cue>  
  11.       <responses>  
  12.         <response type="meaning" language="en">  
  13.           <text><![CDATA[truth, reality]]></text>  
  14.         </response>  
  15.         <response type="character" language="ja">  
  16.           <text><![CDATA[本当]]></text>  
  17.         </response>  
  18.       </responses>  
  19.       <dc:creator>Cerego</dc:creator>  
  20.     </item>  
  21.   </items>  
  22. </vocabulary>  
<vocabulary xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iknow.co.jp/api/specifications/vocabulary/1.0" version="1.0">
  <items>
    <item id="437406">
      <cue language="ja" part_of_speech="Noun">
        <text>ほんとう</text>
        <sound>http://media4.cerego.co.jp/contents/JLL/audio/JW08605A.mp3</sound>
        <transliterations>
          <transliteration type="romaji"><![CDATA[hontou]]></transliteration>
        </transliterations>
      </cue>
      <responses>
        <response type="meaning" language="en">
          <text><![CDATA[truth, reality]]></text>
        </response>
        <response type="character" language="ja">
          <text><![CDATA[本当]]></text>
        </response>
      </responses>
      <dc:creator>Cerego</dc:creator>
    </item>
  </items>
</vocabulary>


Example Parsing Code

How to parse XMLVocabulary in Ruby:

  1. require 'rexml/document'  
  2. file = File.new("vocabulary.xml")  
  3. doc = REXML::Document.new(file)  
  4. doc.elements.each("vocabulary/items/item"do |item|  
  5.   @data = {:sample_sentences => []}  
  6.   item.elements.each("cue"do |cue|  
  7.     @data[:part_of_speech] = cue.attributes['part_of_speech']  
  8.     @data[:cue_text] = cue.elements["text"].text  
  9.     @data[:cue_sound] = cue.elements["sdound"].text  
  10.   end  
  11.   item.elements.each("responses/response"do |response|  
  12.     @data[:repsonse_value] = response.elements["text"].text  
  13.   end  
  14.   item.elements.each("sentences/sentence"do |sentence|  
  15.     sample_sentence_data = {}  
  16.     sample_sentence_data[:cue_sample_sentence] = sentence.elements["sentence"].text  
  17.     sample_sentence_data[:cue_sample_sentence_sound] = sentence.elements["sound"].text  
  18.     sample_sentence_data[:cue_sample_sentence_image] = sentence.elements["image"].text  
  19.     sample_sentence_data[:cue_sample_sentence_translation] = sentence.elements["translations/sentence/text"].text  
  20.     @data[:sample_sentences] << sample_sentence_data  
  21.   end  
  22.   p @data  
  23. end