Skip to content

Commit

Permalink
tricks to keep size smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
qinwf committed Nov 23, 2014
1 parent 466cf99 commit e178f60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 10 additions & 0 deletions R/jiebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ worker <- function(type = "mix", dict = DICTPATH, hmm = HMMPATH,
if(!any(type == c("mix","mp","hmm","query","simhash","keywords","tag"))){
stop("Unkown worker type")
}
jiebapath <- find.package("jiebaR")
if(!file.exists(file.path(jiebapath,"dict","jieba.dict.utf8"))){
unzip(file.path(jiebapath,"dict","jieba.dict.zip"),exdir =file.path( jiebapath,"dict") )
}
if(!file.exists(file.path(jiebapath,"dict","hmm_model.utf8"))){
unzip(file.path(jiebapath,"dict","hmm_model.zip"),exdir =file.path( jiebapath,"dict") )
}
if(!file.exists(file.path(jiebapath,"dict","idf.utf8"))){
unzip(file.path(jiebapath,"dict","idf.zip"),exdir =file.path( jiebapath,"dict") )
}
result = new.env(parent = emptyenv())

switch(type,
Expand Down
11 changes: 1 addition & 10 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ STOPPATH<-NULL
# if (.Platform$OS.type == "windows") {
# Sys.setlocale( locale = "English")
# }
if(!file.exists(file.path(find.package("jiebaR"),"dict","jieba.dict.utf8"))){
unzip(file.path(find.package("jiebaR"),"dict","jieba.dict.zip"),exdir =file.path(find.package("jiebaR"),"dict") )
}
if(!file.exists(file.path(find.package("jiebaR"),"dict","hmm_model.utf8"))){
unzip(file.path(find.package("jiebaR"),"dict","hmm_model.zip"),exdir =file.path(find.package("jiebaR"),"dict") )
}
if(!file.exists(file.path(find.package("jiebaR"),"dict","idf.utf8"))){
unzip(file.path(find.package("jiebaR"),"dict","idf.zip"),exdir =file.path(find.package("jiebaR"),"dict") )
}


assign(x = "DICTPATH", file.path(find.package("jiebaR"),"dict","jieba.dict.utf8"),asNamespace('jiebaR'))
assign(x = "HMMPATH", file.path(find.package("jiebaR"),"dict","hmm_model.utf8"),asNamespace('jiebaR'))
assign(x = "USERPATH", file.path(find.package("jiebaR"),"dict","user.dict.utf8"),asNamespace('jiebaR'))
Expand Down

0 comments on commit e178f60

Please sign in to comment.