Untitled


SUBMITTED BY: Guest

DATE: Dec. 17, 2013, 4:48 a.m.

FORMAT: Text only

SIZE: 846 Bytes

HITS: 3016

  1. type EachToken
  2. stream::IOStream
  3. EachToken(filename::String) = new(open(filename, "r"))
  4. end
  5. start(itr::EachToken) = nada
  6. function next(itr::EachToken, nada)
  7. token = readutil(itr.stream, " ")
  8. return token[1: end - 1]
  9. end
  10. done(itr::EachToken, nada) = eof(itr.stream)
  11. function counted_tokens(token_iterator)
  12. counts = Dict{String, Int32}()
  13. for token=token_iterator
  14. counts[token] = get(counts, token, 0) + 1
  15. end
  16. return counts
  17. end
  18. token_it = EachToken("small_text.txt")
  19. counts = counted_tokens(token_it)
  20. println(counts)
  21. # compiler output
  22. # ERROR: no method start(EachToken,)
  23. # in counted_tokens at /home/rrenaud/word2vec_jl/word_to_vec.jl:16
  24. # in include at boot.jl:238
  25. # at /home/rrenaud/word2vec_jl/word_to_vec.jl:24

comments powered by Disqus