- Previous: Appendix
- Up: Appendix
- Next: B: Parts of speech
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.
- <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="Latn"><![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:
- require 'rexml/document'
- file = File.new("vocabulary.xml")
- doc = REXML::Document.new(file)
- doc.elements.each("vocabulary/items/item") do |item|
- @data = {:sample_sentences => []}
- item.elements.each("cue") do |cue|
- @data[:part_of_speech] = cue.attributes['part_of_speech']
- @data[:cue_text] = cue.elements["text"].text
- @data[:cue_sound] = cue.elements["sdound"].text
- end
- item.elements.each("responses/response") do |response|
- @data[:repsonse_value] = response.elements["text"].text
- end
- item.elements.each("sentences/sentence") do |sentence|
- sample_sentence_data = {}
- sample_sentence_data[:cue_sample_sentence] = sentence.elements["sentence"].text
- sample_sentence_data[:cue_sample_sentence_sound] = sentence.elements["sound"].text
- sample_sentence_data[:cue_sample_sentence_image] = sentence.elements["image"].text
- sample_sentence_data[:cue_sample_sentence_translation] = sentence.elements["translations/sentence/text"].text
- @data[:sample_sentences] << sample_sentence_data
- end
- p @data
- end
- Previous: Appendix
- Up: Appendix
- Next: B: Parts of speech



Comments
Please sign in to post a comment.