struct TextReader
    file::String
    vocab::Vocab
end

Base.IteratorSize(::Type{TextReader}) = Base.SizeUnknown()
Base.IteratorEltype(::Type{TextReader}) = Base.HasEltype()
Base.eltype(::Type{TextReader}) = Vector{Int}

function Base.iterate(r::TextReader, s=nothing)
    s === nothing && (s = open(r.file))
    if eof(s); close(s); return nothing; end
    v = r.vocab
    [ get(v.w2i, w, v.unk) for w in v.tokenizer(readline(s)) ], s
end
