fix sentiment model
This commit is contained in:
parent
b93d4763cc
commit
d797999fc5
|
@ -4,7 +4,7 @@ using ZipFile
|
|||
using ..Data: deps
|
||||
|
||||
function load()
|
||||
isfile(deps("sentiment.zip")) || return
|
||||
isfile(deps("sentiment.zip")) && return
|
||||
@info "Downloading sentiment treebank dataset"
|
||||
download("https://cache.julialang.org/https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip",
|
||||
deps("sentiment.zip"))
|
||||
|
@ -26,9 +26,10 @@ totree_(n, a, b) = Tree{Any}((parse(Int, n), nothing), totree(a), totree(b))
|
|||
totree(t::Expr) = totree_(t.args...)
|
||||
|
||||
function parsetree(s)
|
||||
s = replace(s, r"\$", s -> "\\\$")
|
||||
s = replace(s, r"[^\s\(\)]+", s -> "\"$s\"")
|
||||
s = replace(s, " ", ", ")
|
||||
s = replace(s, "\\" => "")
|
||||
s = replace(s, "\$" => "\\\$")
|
||||
s = replace(s, r"[^ \n\(\)]+" => s -> "\"$s\"")
|
||||
s = replace(s, " " => ", ")
|
||||
return totree(Meta.parse(s))
|
||||
end
|
||||
|
||||
|
|
|
@ -9,3 +9,5 @@ using Test
|
|||
|
||||
@test MNIST.images()[1] isa Matrix
|
||||
@test MNIST.labels() isa Vector{Int64}
|
||||
|
||||
@test Data.Sentiment.train() isa Vector{Data.Tree{Any}}
|
||||
|
|
Loading…
Reference in New Issue