@@ -88,11 +88,16 @@ cnlp_init_corenlp <- function(language, anno_level = 2, lib_location = NULL,
88
88
lib_location <- file.path(system.file(" extdata" , package = " cleanNLP" ),
89
89
" /stanford-corenlp-full-2018-10-05" )
90
90
91
- # set properties that are not "corenlp" properties
91
+ # set properties
92
92
volatiles $ corenlp $ language <- language
93
93
volatiles $ corenlp $ lib_location <- lib_location
94
94
volatiles $ corenlp $ mem <- mem
95
95
volatiles $ corenlp $ verbose <- verbose
96
+ volatiles $ corenlp $ properties <- list ()
97
+
98
+ fin <- file.path(lib_location , " /properties.rds" )
99
+ if (file.exists(fin ))
100
+ volatiles $ corenlp $ properties <- readRDS(fin )
96
101
97
102
# German models
98
103
if (language == " de" & anno_level == 0 ) {
@@ -377,22 +382,13 @@ setup_corenlp_backend_raw <- function(keys, values, clear = FALSE) {
377
382
stop(" values must be a character vector" )
378
383
379
384
# read current parameter file
380
- if (! clear ) {
381
- fin <- file.path(system.file(" extdata" , package = " cleanNLP" ),
382
- " properties.rds" )
383
- if (file.exists(fin ))
384
- prop <- readRDS(fin )
385
- else
386
- prop <- list ()
387
- } else prop <- list ()
385
+ if (clear ) {
386
+ volatiles $ corenlp $ properties <- list ()
387
+ }
388
388
389
389
# insert new keys and values
390
390
for (i in seq_along(keys ))
391
- prop [[keys [i ]]] <- values [i ]
392
-
393
- # save new parameter file
394
- saveRDS(prop , file.path(system.file(" extdata" ,
395
- package = " cleanNLP" ), " properties.rds" ))
391
+ volatiles $ corenlp $ properties [[keys [i ]]] <- values [i ]
396
392
}
397
393
398
394
init_corenlp_backend <- function () {
@@ -413,12 +409,11 @@ init_corenlp_backend <- function() {
413
409
}
414
410
415
411
# Parse default parameters
416
- fp <- file.path(system.file(" extdata" ,package = " cleanNLP" ),
417
- " properties.rds" )
418
- if (! file.exists(fp )) {
412
+ if (length(volatiles $ corenlp $ properties ) == 0 ) {
419
413
setup_corenlp_backend_raw(" en" )
420
414
}
421
- properties <- readRDS(fp )
415
+
416
+ properties <- volatiles $ corenlp $ properties
422
417
keys <- names(properties )
423
418
values <- as.character(properties )
424
419
lang <- volatiles $ corenlp $ language
0 commit comments