@@ -44,10 +44,10 @@ new_tokenlist <- function(tokens = list(), lemma = NULL, pos = NULL,
44
44
unique_tokens = character ()) {
45
45
vec_assert(tokens , list ())
46
46
if (! (is.null(lemma ) | is.list(lemma ))) {
47
- rlang :: abort( " ` lemma` must be NULL or a list." )
47
+ cli :: cli_abort( " {.arg lemma} must be NULL or a list." )
48
48
}
49
49
if (! (is.null(pos ) | is.list(pos ))) {
50
- rlang :: abort( " ` pos` must be NULL or a list." )
50
+ cli :: cli_abort( " {.arg pos} must be NULL or a list." )
51
51
}
52
52
vec_assert(unique_tokens , character ())
53
53
@@ -141,7 +141,7 @@ obj_print_footer.textrecipes_tokenlist <- function(x, ...) {
141
141
# or removes (for keep = FALSE) the words
142
142
tokenlist_filter <- function (x , dict , keep = FALSE ) {
143
143
if (! is_tokenlist(x )) {
144
- rlang :: abort (" Input must be a tokenlist." )
144
+ cli :: cli_abort (" Input must be a tokenlist." )
145
145
}
146
146
147
147
if (! keep ) {
@@ -180,7 +180,7 @@ tokenlist_filter <- function(x, dict, keep = FALSE) {
180
180
181
181
tokenlist_filter_function <- function (x , fn ) {
182
182
if (! is_tokenlist(x )) {
183
- rlang :: abort (" Input must be a tokenlist." )
183
+ cli :: cli_abort (" Input must be a {.cls tokenlist} ." )
184
184
}
185
185
186
186
tokens <- get_tokens(x )
@@ -210,7 +210,7 @@ tokenlist_filter_function <- function(x, fn) {
210
210
211
211
tokenlist_apply <- function (x , fun , arguments = NULL ) {
212
212
if (! is_tokenlist(x )) {
213
- rlang :: abort (" Input must be a tokenlist." )
213
+ cli :: cli_abort (" Input must be {.cls tokenlist} object ." )
214
214
}
215
215
216
216
tokens <- get_tokens(x )
@@ -226,7 +226,7 @@ tokenlist_apply <- function(x, fun, arguments = NULL) {
226
226
# Takes a [tokenlist] and calculate the token count matrix
227
227
tokenlist_to_dtm <- function (x , dict ) {
228
228
if (! is_tokenlist(x )) {
229
- rlang :: abort (" Input must be a tokenlist." )
229
+ cli :: cli_abort (" Input must be a tokenlist." )
230
230
}
231
231
232
232
tokens <- get_tokens(x )
@@ -246,23 +246,23 @@ tokenlist_to_dtm <- function(x, dict) {
246
246
247
247
tokenlist_lemma <- function (x ) {
248
248
if (! is_tokenlist(x )) {
249
- rlang :: abort (" Input must be a tokenlist." )
249
+ cli :: cli_abort (" Input must be a tokenlist." )
250
250
}
251
251
252
252
if (is.null(maybe_get_lemma(x ))) {
253
- rlang :: abort( " ` lemma` attribute not avaliable ." )
253
+ cli :: cli_abort( " The {.code lemma} attribute is not available ." )
254
254
}
255
255
256
256
tokenlist(maybe_get_lemma(x ), pos = maybe_get_pos(x ))
257
257
}
258
258
259
259
tokenlist_pos_filter <- function (x , pos_tags ) {
260
260
if (! is_tokenlist(x )) {
261
- rlang :: abort (" Input must be a tokenlist." )
261
+ cli :: cli_abort (" Input must be a tokenlist." )
262
262
}
263
263
264
264
if (is.null(maybe_get_pos(x ))) {
265
- rlang :: abort( " pos attribute not avaliable ." )
265
+ cli :: cli_abort( " {.arg pos} attribute not available ." )
266
266
}
267
267
268
268
tokens <- get_tokens(x )
@@ -292,7 +292,7 @@ tokenlist_pos_filter <- function(x, pos_tags) {
292
292
293
293
tokenlist_ngram <- function (x , n , n_min , delim ) {
294
294
if (! is_tokenlist(x )) {
295
- rlang :: abort (" Input must be a tokenlist." )
295
+ cli :: cli_abort (" Input must be a tokenlist." )
296
296
}
297
297
298
298
tokenlist(cpp11_ngram(get_tokens(x ), n , n_min , delim ))
0 commit comments