Skip to content

Commit f8a4479

Browse files
committed
change to Int64
1 parent 8fa77f8 commit f8a4479

File tree

9 files changed

+109
-109
lines changed

9 files changed

+109
-109
lines changed

docs/src/man/find_path.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ CurrentModule = JudiLing
1111
build_paths
1212
learn_paths(::DataFrame,::DataFrame,::SparseMatrixCSC,::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Matrix,::SparseMatrixCSC,::Dict)
1313
build_paths(::DataFrame,::SparseMatrixCSC,::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Matrix,::SparseMatrixCSC,::Dict,::Array)
14-
eval_can(::Vector{Vector{Tuple{Vector{Integer}, Integer}}},::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Dict,::Integer,::Bool)
14+
eval_can(::Vector{Vector{Tuple{Vector{Int64}, Int64}}},::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Dict,::Int64,::Bool)
1515
find_top_feature_indices(::Matrix, ::Array)
1616
```

docs/src/man/make_yt_matrix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ CurrentModule = JudiLing
66

77
```@docs
88
make_Yt_matrix
9-
make_Yt_matrix(::Integer, ::DataFrame)
9+
make_Yt_matrix(::Int64, ::DataFrame)
1010
```

src/find_path.jl

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ store paths information found by learn_paths or build_paths function
33
"""
44
struct Result_Path_Info_Struct
55
ngrams_ind::Array
6-
num_tolerance::Integer
6+
num_tolerance::Int64
77
support::AbstractFloat
88
end
99

@@ -38,13 +38,13 @@ learn_paths function takes each timestep individually and calculate Yt_hat respe
3838
- `gold_ind::Union{Nothing, Vector}=nothing`: for in gold_path_info mode
3939
- `Shat_val::Union{Nothing, Matrix}=nothing`: for gold_path_info mode
4040
- `check_gold_path::Bool=false`: if turn on gold_path_info mode
41-
- `max_t::Integer=15`: maximum timestep
42-
- `max_can::Integer=10`: maximum candidates when output
41+
- `max_t::Int64=15`: maximum timestep
42+
- `max_can::Int64=10`: maximum candidates when output
4343
- `threshold::AbstractFloat=0.1`: for each timestep, only grams greater than threshold will be selected
4444
- `is_tolerant::Bool=false`: if in tolerant mode, path allows limited nodes under threshold but greater than tolerance
4545
- `tolerance::AbstractFloat=(-1000.0)`: in tolerant mode, only nodes greater than tolerance and lesser than threshold will be selected
46-
- `max_tolerance::Integer=4`: maximum numbers of nodes allowed in a path
47-
- `grams::Integer=3`: n-grams
46+
- `max_tolerance::Int64=4`: maximum numbers of nodes allowed in a path
47+
- `grams::Int64=3`: n-grams
4848
- `tokenized::Bool=false`: whether tokenized
4949
- `sep_token::Union{Nothing, String, Char}=nothing`: seperate token
5050
- `keep_sep::Bool=false`: whether keep seperaters in grams
@@ -159,13 +159,13 @@ function learn_paths(
159159
gold_ind=nothing::Union{Nothing, Vector},
160160
Shat_val=nothing::Union{Nothing, Matrix},
161161
check_gold_path=false::Bool,
162-
max_t=15::Integer,
163-
max_can=10::Integer,
162+
max_t=15::Int64,
163+
max_can=10::Int64,
164164
threshold=0.1::AbstractFloat,
165165
is_tolerant=false::Bool,
166166
tolerance=(-1000.0)::AbstractFloat,
167-
max_tolerance=4::Integer,
168-
grams=3::Integer,
167+
max_tolerance=4::Int64,
168+
grams=3::Int64,
169169
tokenized=false::Bool,
170170
sep_token=nothing::Union{Nothing, String, Char},
171171
keep_sep=false::Bool,
@@ -176,12 +176,12 @@ function learn_paths(
176176

177177
# initialize queues for storing paths
178178
n_val = size(data_val, 1)
179-
# working_q = Array{Queue{Array{Integer,1}},1}(undef, n_val)
180-
working_q = Vector{Queue{Tuple{Vector{Integer}, Integer}}}(undef, n_val)
181-
# res = Array{Array{Array{Integer}},1}(undef, n_val)
182-
res = Vector{Vector{Tuple{Vector{Integer}, Integer}}}(undef, n_val)
179+
# working_q = Array{Queue{Array{Int64,1}},1}(undef, n_val)
180+
working_q = Vector{Queue{Tuple{Vector{Int64}, Int64}}}(undef, n_val)
181+
# res = Array{Array{Array{Int64}},1}(undef, n_val)
182+
res = Vector{Vector{Tuple{Vector{Int64}, Int64}}}(undef, n_val)
183183
for j in 1:n_val
184-
res[j] = Tuple{Vector{Integer}, Integer}[]
184+
res[j] = Tuple{Vector{Int64}, Int64}[]
185185
end
186186

187187
# # initialize gold_path_info supports
@@ -245,7 +245,7 @@ function learn_paths(
245245

246246
# for timestep 2 and after 2
247247
if isassigned(working_q, j)
248-
tmp_working_q = Queue{Tuple{Vector{Integer},Integer}}()
248+
tmp_working_q = Queue{Tuple{Vector{Int64},Int64}}()
249249
while !isempty(working_q[j])
250250
a = dequeue!(working_q[j]) ## a = [11] Al[11,5] == 1 # candidates = [1, 5, 7]
251251

@@ -287,11 +287,11 @@ function learn_paths(
287287
working_q[j] = tmp_working_q
288288
# for timestep 1
289289
else
290-
working_q[j] = Queue{Tuple{Vector{Integer},Integer}}()
290+
working_q[j] = Queue{Tuple{Vector{Int64},Int64}}()
291291
for c in candidates_t
292292
# check whether a n-gram is a start n-gram
293293
if isstart(c, i2f, tokenized=tokenized, sep_token=sep_token)
294-
a = Integer[]
294+
a = Int64[]
295295
push!(a, c)
296296
# check whether this n-gram is both start and complete
297297
if iscomplete(a, i2f, tokenized=tokenized, sep_token=sep_token)
@@ -306,7 +306,7 @@ function learn_paths(
306306
for c in candidates_t_tlr
307307
# check whether a n-gram is a start n-gram
308308
if isstart(c, i2f, tokenized=tokenized, sep_token=sep_token)
309-
a = Integer[]
309+
a = Int64[]
310310
push!(a, c)
311311
# check whether this n-gram is both start and complete
312312
if iscomplete(a, i2f, tokenized=tokenized, sep_token=sep_token)
@@ -350,10 +350,10 @@ validation data
350350
...
351351
# Arguments
352352
- `rC::Union{Nothing, Matrix}=nothing`: correlation Matrix of C and Chat, passing it to save computing time
353-
- `max_t::Integer=15`: maximum timestep
354-
- `max_can::Integer=10`: maximum candidates when output
355-
- `n_neighbors::Integer=10`: find indices only in top n neighbors
356-
- `grams::Integer=3`: n-grams
353+
- `max_t::Int64=15`: maximum timestep
354+
- `max_can::Int64=10`: maximum candidates when output
355+
- `n_neighbors::Int64=10`: find indices only in top n neighbors
356+
- `grams::Int64=3`: n-grams
357357
- `tokenized::Bool=false`: whether tokenized
358358
- `sep_token::Union{Nothing, String, Char}=nothing`: seperate token
359359
- `target_col::Union{String, :Symbol}=:Words`: word column names
@@ -443,23 +443,23 @@ function build_paths(
443443
i2f::Dict,
444444
C_train_ind::Array;
445445
rC=nothing::Union{Nothing, Matrix},
446-
max_t=15::Integer,
447-
max_can=10::Integer,
448-
n_neighbors=10::Integer,
449-
grams=3::Integer,
446+
max_t=15::Int64,
447+
max_can=10::Int64,
448+
n_neighbors=10::Int64,
449+
grams=3::Int64,
450450
tokenized=false::Bool,
451451
sep_token=nothing::Union{Nothing, String, Char},
452452
target_col=:Words::Union{String, Symbol},
453453
verbose=false::Bool
454454
)::Vector{Vector{Result_Path_Info_Struct}}
455455
# initialize queues for storing paths
456456
n_val = size(data_val, 1)
457-
# working_q = Array{Queue{Array{Integer,1}},1}(undef, n_val)
458-
# res = Array{Array{Array{Integer}},1}(undef, n_val)
459-
res = Vector{Vector{Tuple{Vector{Integer}, Integer}}}(undef, n_val)
457+
# working_q = Array{Queue{Array{Int64,1}},1}(undef, n_val)
458+
# res = Array{Array{Array{Int64}},1}(undef, n_val)
459+
res = Vector{Vector{Tuple{Vector{Int64}, Int64}}}(undef, n_val)
460460

461461
for j in 1:n_val
462-
res[j] = Tuple{Vector{Integer}, Integer}[]
462+
res[j] = Tuple{Vector{Int64}, Int64}[]
463463
end
464464

465465
verbose && println("Finding all top features..")
@@ -483,11 +483,11 @@ function build_paths(
483483
candidates_t = top_indices[j]
484484

485485
# timestep 1
486-
working_q = Queue{Array{Integer, 1}}()
486+
working_q = Queue{Array{Int64, 1}}()
487487
for c in candidates_t
488488
# check whether a n-gram is a start n-gram
489489
if isstart(c, i2f, tokenized=tokenized, sep_token=sep_token)
490-
a = Integer[]
490+
a = Int64[]
491491
push!(a, c)
492492
# check whether this n-gram is both start and complete
493493
if iscomplete(a, i2f, tokenized=tokenized, sep_token=sep_token)
@@ -499,7 +499,7 @@ function build_paths(
499499
end
500500

501501
for i in 2:max_t
502-
tmp_working_q = Queue{Array{Integer, 1}}()
502+
tmp_working_q = Queue{Array{Int64, 1}}()
503503
while !isempty(working_q)
504504
a = dequeue!(working_q) ## a = [11] Al[11,5] == 1 # candidates = [1, 5, 7]
505505
for c in candidates_t ## c = 5 # a = [11, 1, 5, 7] # a = [11, 1] [11, 5] [11, 7]
@@ -528,17 +528,17 @@ function build_paths(
528528
end
529529

530530
"""
531-
eval_can(::Vector{Vector{Tuple{Vector{Integer}, Integer}}},::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Dict,::Integer,::Bool)
531+
eval_can(::Vector{Vector{Tuple{Vector{Int64}, Int64}}},::Union{SparseMatrixCSC, Matrix},::Union{SparseMatrixCSC, Matrix},::Dict,::Int64,::Bool)
532532
533533
at the end of finding path algorithms, each candidates need to be evaluated
534534
regarding their predicted semantic vectors
535535
"""
536536
function eval_can(
537-
candidates::Vector{Vector{Tuple{Vector{Integer}, Integer}}},
537+
candidates::Vector{Vector{Tuple{Vector{Int64}, Int64}}},
538538
S::Union{SparseMatrixCSC, Matrix},
539539
F::Union{SparseMatrixCSC, Matrix},
540540
i2f::Dict,
541-
max_can::Integer,
541+
max_can::Int64,
542542
verbose=false::Bool
543543
)::Array{Array{Result_Path_Info_Struct,1},1}
544544

@@ -551,7 +551,7 @@ function eval_can(
551551
res = Result_Path_Info_Struct[]
552552
if size(candidates[i], 1) > 0
553553
for (ci,n) in candidates[i] # ci = [1,3,4]
554-
Chat = zeros(Integer, length(i2f))
554+
Chat = zeros(Int64, length(i2f))
555555
Chat[ci] .= 1
556556
Shat = Chat'*F
557557
Scor = cor(Shat[1, :], S[i, :])
@@ -575,9 +575,9 @@ function find_top_feature_indices(
575575
# Chat_val::Union{SparseMatrixCSC, Matrix},
576576
rC::Matrix,
577577
C_train_ind::Array;
578-
n_neighbors=10::Integer,
578+
n_neighbors=10::Int64,
579579
verbose=false::Bool
580-
)::Vector{Vector{Integer}}
580+
)::Vector{Vector{Int64}}
581581

582582
# collect num of val data
583583
n_val = size(rC, 1)
@@ -587,7 +587,7 @@ function find_top_feature_indices(
587587
# display(rC)
588588

589589
# initialize features list for all candidates
590-
features_all = Vector{Vector{Integer}}(undef, n_val)
590+
features_all = Vector{Vector{Int64}}(undef, n_val)
591591

592592
# create iter for tqdm
593593
verbose && println("finding all n_neighbors features...")

src/make_cue_matrix.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct Cue_Matrix_Struct
1010
C::Union{Matrix, SparseMatrixCSC}
1111
f2i::Dict
1212
i2f::Dict
13-
gold_ind::Vector{Vector{Integer}}
13+
gold_ind::Vector{Vector{Int64}}
1414
A::SparseMatrixCSC
1515
end
1616

@@ -31,7 +31,7 @@ This function makes cue matrix and corresponding indices given dataset as csv fi
3131
3232
...
3333
# Arguments
34-
- `grams::Integer=3`: the number of grams for cues
34+
- `grams::Int64=3`: the number of grams for cues
3535
- `target_col::Union{String, Symbol}=:Words`: the column name for target
3636
- `tokenized::Bool=false`: whether the target is tokenized
3737
- `sep_token::Union{Nothing, String, Char}=nothing`: what is the seperate token
@@ -54,7 +54,7 @@ latin_cue_obj_train = JudiLing.make_cue_matrix(
5454
"""
5555
function make_cue_matrix(
5656
data::DataFrame;
57-
grams=3::Integer,
57+
grams=3::Int64,
5858
target_col=:Words::Union{String, Symbol},
5959
tokenized=false::Bool,
6060
sep_token=nothing::Union{Nothing, String, Char},
@@ -143,7 +143,7 @@ the same indices.
143143
144144
...
145145
# Arguments
146-
- `grams::Integer=3`: the number of grams for cues
146+
- `grams::Int64=3`: the number of grams for cues
147147
- `target_col::Union{String, Symbol}=:Words`: the column name for target
148148
- `tokenized::Bool=false`: whether the word is tokenized
149149
- `sep_token::Union{Nothing, String, Char}=nothing`: what is the seperate token
@@ -178,7 +178,7 @@ latin_cue_obj_val = JudiLing.make_cue_matrix(
178178
function make_cue_matrix(
179179
data::DataFrame,
180180
cue_obj::Cue_Matrix_Struct;
181-
grams=3::Integer,
181+
grams=3::Int64,
182182
target_col="Words"::String,
183183
tokenized=false::Bool,
184184
sep_token=nothing::Union{Nothing, String, Char},
@@ -226,14 +226,14 @@ function make_cue_matrix(
226226
end
227227

228228
"""
229-
make_ngrams(::Array,::Integer,::Bool,
229+
make_ngrams(::Array,::Int64,::Bool,
230230
::Union{Nothing, String, Char},::Union{String, Char}
231231
232232
given a list of tokens, return all ngrams in a list
233233
"""
234234
function make_ngrams(
235235
tokens::Array,
236-
grams=3::Integer,
236+
grams=3::Int64,
237237
keep_sep=false::Bool,
238238
sep_token=nothing::Union{Nothing, String, Char},
239239
start_end_token="#"::Union{String, Char}

0 commit comments

Comments
 (0)