Skip to content

Commit

Permalink
Use haskey
Browse files Browse the repository at this point in the history
  • Loading branch information
zgornel committed Oct 1, 2018
1 parent 8f74013 commit 3cb094c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function _load_gz_embeddings(filepath::S1,
if word in keep_words || no_custom_words
if lang in keys(LANGUAGES) && LANGUAGES[lang] in languages # use only languages mapped in LANGUAGES
_llang = LANGUAGES[lang]
if !(_llang in keys(lang_embs))
if !haskey(lang_embs, _llang)
push!(lang_embs, _llang=>Dict{type_word, type_vector}())
push!(fuzzy_words, _llang=>type_word[])
end
Expand Down Expand Up @@ -147,9 +147,9 @@ function _load_hdf5_embeddings(filepath::S1,
cnt = 0
for (idx, (lang, word)) in enumerate(words)
if word in keep_words || no_custom_words
if lang in keys(LANGUAGES) && LANGUAGES[lang] in languages # use only languages mapped in LANGUAGES
if haskey(LANGUAGES, lang) && LANGUAGES[lang] in languages # use only languages mapped in LANGUAGES
_llang = LANGUAGES[lang]
if !(_llang in keys(lang_embs))
if !haskey(lang_embs, _llang)
push!(lang_embs, _llang=>Dict{type_word, type_vector}())
push!(fuzzy_words, _llang=>type_word[])
end
Expand Down
4 changes: 2 additions & 2 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ size(conceptnet::ConceptNet, inds...) = (conceptnet.width, length(conceptnet))[i
function in(key::S, conceptnet::ConceptNet) where S<:AbstractString
found = false
for lang in keys(conceptnet.embeddings)
if key in keys(conceptnet.embeddings[lang])
if haskey(conceptnet.embeddings[lang], key)
found = true
break
end
Expand All @@ -151,7 +151,7 @@ function in(key::S, conceptnet::ConceptNet) where S<:AbstractString
end

function in(lang::L, conceptnet::ConceptNet) where L<:Languages.Language
return lang in keys(conceptnet.embeddings)
return haskey(conceptnet.embeddings, lang)
end


Expand Down

0 comments on commit 3cb094c

Please sign in to comment.