quanteda / quanteda.sentiment
Showing 2 of 4 files from the diff.

@@ -197,10 +197,15 @@
Loading
197 197
198 198
#' @export
199 199
"valence<-.dictionary2" <- function(x, value) {
200 -
  value <- as.list(value)
201 -
  check_valences(x, value)
202 -
  x@meta$object$valence <- set_valences(x, value)
203 -
  class(x) <- "dictionary3"
200 +
  if (!is.null(value)) {
201 +
    value <- as.list(value)
202 +
    check_valences(x, value)
203 +
    x@meta$object$valence <- set_valences(x, value)
204 +
    class(x) <- "dictionary3"
205 +
  } else {
206 +
    x@meta$object$valence <- NULL
207 +
    if (!is.null(polarity(x))) class(x) <- "dictionary2"
208 +
  }
204 209
  x
205 210
}
206 211

@@ -152,16 +152,20 @@
Loading
152 152
153 153
#' @export
154 154
"polarity<-.dictionary2" <- function(x, value) {
155 -
    if (!setequal(union(c("pos", "neg", "neut"), names(value)),
156 -
                  c("pos", "neg", "neut")) ||
157 -
        !is.list(value)) {
158 -
        stop("value must be a list of 'pos', 'neg', and (optionally) 'neut'",
159 -
            call. = FALSE)
155 +
    if (!is.null(value)) {
156 +
        if (!setequal(union(c("pos", "neg", "neut"), names(value)),
157 +
                      c("pos", "neg", "neut")) ||
158 +
            !is.list(value)) {
159 +
            stop("value must be a list of 'pos', 'neg', and (optionally) 'neut'",
160 +
                 call. = FALSE)
161 +
        }
162 +
        check_that_poles_exist(x, value)
163 +
        class(x) <- "dictionary3"
164 +
    } else {
165 +
        if (is.null(valence(x))) class(x) <- "dictionary2"
160 166
    }
161 -
    check_that_poles_exist(x, value)
162 -
167 +
        
163 168
    x@meta$object$polarity <- value
164 -
    class(x) <- "dictionary3"
165 169
    x
166 170
}
167 171
Files Coverage
R 95.83%
Project Totals (3 files) 95.83%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading