Class: JLDrill::Tatoeba::LinkFile

Inherits:
DataFile
  • Object
show all
Defined in:
lib/jldrill/model/Tatoeba.rb

Constant Summary collapse

/^(\d*)[\t](\d*)/

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

#initializeLinkFile

Returns a new instance of LinkFile.



57
58
59
60
61
# File 'lib/jldrill/model/Tatoeba.rb', line 57

def initialize()
    super
    @links = []
    @stepSize = 1000
end

Instance Method Details

#dataSizeObject



63
64
65
# File 'lib/jldrill/model/Tatoeba.rb', line 63

def dataSize
    @links.size
end

#finishParsingObject

Don’t erase @lines because we need them later



76
77
78
# File 'lib/jldrill/model/Tatoeba.rb', line 76

def finishParsing
    setLoaded(true)
end

#getLinksTo(index) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/jldrill/model/Tatoeba.rb', line 80

def getLinksTo(index)
    retVal = @links[index]
    if retVal.nil?
        retVal = []
    end
    return retVal
end

#parseEntryObject



67
68
69
70
71
72
73
# File 'lib/jldrill/model/Tatoeba.rb', line 67

def parseEntry
    if LINK_RE.match(@lines[@parsed])
        index = $1.to_i
        (@links[index] ||= []).push($2.to_i)
    end
    @parsed += 1
end