Class: JLDrill::Tatoeba::SentenceFile
Constant Summary
collapse
- INDEX_RE =
/^(\d*)[\t]/
- SENTENCE_RE =
/^(\d*)[\t](.*)[\t](.*)/
Instance Attribute Summary
Attributes inherited from DataFile
#encoding, #file, #lines, #parsed, #publisher, #stepSize
Instance Method Summary
collapse
Methods inherited from DataFile
#createLines, #eof?, #findEncoding, #fraction, #load, #loaded?, #parse, #parseChunk, #parser, #readLines, #reset, #setLoaded, #shortFilename
Constructor Details
11
12
13
14
15
|
# File 'lib/jldrill/model/Tatoeba.rb', line 11
def initialize()
super
@sentences = []
@stepSize = 1000
end
|
Instance Method Details
#dataAt(index) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/jldrill/model/Tatoeba.rb', line 45
def dataAt(index)
retVal = ""
entry = @sentences[index]
if !entry.nil?
retVal = @lines[entry]
end
return retVal
end
|
#dataSize ⇒ Object
17
18
19
|
# File 'lib/jldrill/model/Tatoeba.rb', line 17
def dataSize
@sentences.size
end
|
#finishParsing ⇒ Object
Don’t erase @lines because we need them later
30
31
32
|
# File 'lib/jldrill/model/Tatoeba.rb', line 30
def finishParsing
setLoaded(true)
end
|
#parseEntry ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/jldrill/model/Tatoeba.rb', line 21
def parseEntry
if INDEX_RE.match(@lines[@parsed])
index = $1.to_i
@sentences[index] = @parsed
end
@parsed += 1
end
|
#sentenceAt(index) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/jldrill/model/Tatoeba.rb', line 34
def sentenceAt(index)
retVal = ""
entry = @sentences[index]
if !entry.nil?
if SENTENCE_RE.match(@lines[entry])
retVal = $3
end
end
return retVal
end
|