Class: JLDrill::CEDictionary

Inherits:
Dictionary show all
Defined in:
lib/jldrill/model/items/CEDictionary.rb

Overview

A JEDictionary is a Japanese to English Dictionary. It is composed of an array of entries from an EDict dictionary. These entries are parsed to create DictionaryEntry. The DictionaryEntry can then further parse the entries to create Meanings.

Constant Summary collapse

LINE_RE_TEXT =
'^([^\[\s]*)\s+([^\[\s]*)\s+\[(.*)\]\s+\/(([^\/]*\/)+)'
LINE_RE =
Regexp.new(LINE_RE_TEXT, nil)
GET_DE_RE =
Regexp.new('^([^\[\s]*)\s+([^\[\s]*)\s+\[(.*)\]\s+', nil)
FIRST_CHAR_RE =
Regexp.new("^(.)", nil)

Instance Attribute Summary collapse

Attributes inherited from Dictionary

#dictEntries

Attributes inherited from DataFile

#encoding, #file, #lines, #parsed, #publisher, #stepSize

Instance Method Summary collapse

Methods inherited from Dictionary

#dataSize, #eachVocab, #findBinWithKanji, #findBinWithReading, #findBinWithSimplified, #findKanji, #findKanjiStartingWith, #findKanjiThatStart, #findReading, #findReadingsStartingWith, #findReadingsThatStart, #findWord, #findWordsThatStart, #finishParsing, #hashWord, #include?, #initialize, #length, #parseEntry, #parseLine, #readLines, #reset, #vocab

Methods inherited from DataFile

#createLines, #dataSize, #eof?, #findEncoding, #finishParsing, #fraction, #initialize, #load, #loaded?, #parse, #parseChunk, #parseEntry, #parser, #readLines, #reset, #setLoaded, #shortFilename

Constructor Details

This class inherits a constructor from JLDrill::Dictionary

Instance Attribute Details

#jWordsObject (readonly)

Returns the value of attribute jWords.



16
17
18
# File 'lib/jldrill/model/items/CEDictionary.rb', line 16

def jWords
  @jWords
end

Instance Method Details

#getDictionaryEntry(index) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/jldrill/model/items/CEDictionary.rb', line 53

def getDictionaryEntry(index)
    retVal = nil
    if lines[index] =~ GET_DE_RE
        retVal = DictionaryEntry.new
        retVal.kanji = $1
        retVal.simplified = $2
        retVal.reading = $3
        retVal.dictionary = self
        retVal.position = index
    end
    return retVal
end

#getMeaning(position) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/jldrill/model/items/CEDictionary.rb', line 27

def getMeaning(position)
    retVal = ""
    if lines[position] =~ LINE_RE
        retVal = $4
    end
    return retVal
end

#getVocab(position) ⇒ Object

Parse the line at the given position and return the a Vocabulary containing the information (this is deprecated).



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/jldrill/model/items/CEDictionary.rb', line 37

def getVocab(position)
    retVal = nil
    if lines[position] =~ LINE_RE
        kanji = $1
        reading = $3
        english = JLDrill::Meaning.create($4)
        
        retVal = Vocabulary.new(kanji, reading, english.allDefinitions,
                           english.allTypes, "", position)
    else
        Context::Log::warning("JLDrill::CEDictionary", 
                              "Could not parse #{position}")
    end             
    return retVal                        
end

#hashSizeObject



23
24
25
# File 'lib/jldrill/model/items/CEDictionary.rb', line 23

def hashSize
    return "".size
end