Skip to content

Commit

Permalink
Merge pull request #13 from ai-ku/load
Browse files Browse the repository at this point in the history
Load
  • Loading branch information
ekinakyurek authored Nov 5, 2019
2 parents 36c4753 + 1bb3b09 commit 2dfe277
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,27 @@ Detailed information about experiments can be found in [scripts/](scripts/README

## Tagging

Note: Limited Support
Available Pre-Trained Models

```JULIA
trained(MorseModel, TRDataSet);
trained(MorseModel, UDDataSet, lang="ru"); # Russian
trained(MorseModel, UDDataSet, lang="da"); # Danish
trained(MorseModel, UDDataSet, lang="fi"); # Finnish
trained(MorseModel, UDDataSet, lang="pt"); # Portuguese
trained(MorseModel, UDDataSet, lang="es"); # Español
trained(MorseModel, UDDataSet, lang="hu"); # Hungarian
trained(MorseModel, UDDataSet, lang="bg"); # Bulgarian
trained(MorseModel, UDDataSet, lang="sv"); # Swedish
```

### How To Use

Note: Please use lowercased and tokenized inputs.

```Julia
julia> using Knet, KnetLayers, Morse
julia> model, vocabulary, parser = trained(MorseModel, TRDataSet, vers="2018");
julia> model, vocabulary, parser = trained(MorseModel, TRDataSet);
julia> predictions = model("annem sana yardım edemez .", v=vocabulary, p=parser)
annem anne+Noun+A3sg+P1sg+Nom
sana sen+Pron+Pers+A2sg+Pnon+Dat
Expand Down
14 changes: 10 additions & 4 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ function download(dataset::Type{TRDataSet}; path=dir("data","TrMor2018"))
end
end

const server_url ="ai.ku.edu.tr/models/morse/"
const server_url ="people.csail.mit.edu/deniz/models/morse/"

function download(model::Type{T}, format::Type{TRDataSet}; vers="2018", lemma=true, lang="tr") where T
function download(model::Type{T}, format; vers="2018", lemma=true, lang="tr") where T
flang = format===TRDataSet ? string("TR-tr",vers) : string("UD-",lang)
mname = string(T,"_lemma_",lemma,"_lang_",flang,"_size_full",".jld2")
mname = string("bestModel.",T,"_lemma_",lemma,"_lang_",flang,"_size_full","_params.jld2")
lpath = dir("checkpoints",mname)
if !isfile(lpath)
mpath = string(server_url, mname)
Expand All @@ -76,7 +76,13 @@ end
"""
function loadModel(fname::AbstractString)
f = KnetLayers.load(fname)
return f["model"], f["opts"], f["vocab"], f["parser"]
prms,opts,vocab,parser = f["model"], f["opts"], f["vocab"], f["parser"]
ModelType = eval(Meta.parse(opts[:modelType]))
model = ModelType(opts,vocab)
for (wm,wl) in zip(params(model),prms)
copyto!(wm.value,wl)
end
return model,opts,vocab,parser
end

"""
Expand Down

0 comments on commit 2dfe277

Please sign in to comment.