-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.jl
More file actions
46 lines (36 loc) · 1.31 KB
/
Copy pathData.jl
File metadata and controls
46 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Data
using Types
function read(numDocs::Int64)
print("Reading data...")
open("data.txt") do data
M::Matrix{M_Matrix_Int_Type} = zeros(0, 0)
line::Int64 = 1
for ln in eachline(data)
if line == 1
# skip
elseif line == 2
d::Int64 = parse(Int64, ln)
M = zeros(d, numDocs)
M_dist = zeros(numDocs, numDocs)
elseif line == 3
# skip
elseif line >= 4
splitted::Array{ASCIIString} = convert(Array{ASCIIString}, split(ln))
docId::Int64 = parse(Int64, splitted[1])
wordId::Int64 = parse(Int64, splitted[2])
count::M_Matrix_Int_Type = parse(M_Matrix_Int_Type, splitted[3])
if docId > numDocs
break
end
# println("M[$(docId), $(wordId)] = $(count)")
M[wordId, docId] = count
else
# println("Finished reading")
break
end
line += 1
end
return M
end
end
end