Skip to content

Commit a5428f9

Browse files
committed
loosen unit test on punctuation symbols - test only on lowercased letters/numbers
1 parent 6b4e3c1 commit a5428f9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

inst/tinytest/test_predict.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ expect_true(is.data.frame(trans$tokens))
1111
expect_equal(nrow(trans$tokens), 0)
1212

1313
if(Sys.getenv("TINYTEST_CI", unset = "yes") == "yes"){
14+
onlyalpha <- function(x){
15+
x <- gsub("[^[:alnum:] ]", "", x)
16+
x <- x[nchar(x) > 0]
17+
x <- tolower(x)
18+
x
19+
}
20+
1421
## JFK example full fragment using tiny model
1522
model <- whisper("tiny")
1623
trans <- predict(model, newdata = system.file(package = "audio.whisper", "samples", "jfk.wav"), language = "en")
@@ -19,13 +26,7 @@ if(Sys.getenv("TINYTEST_CI", unset = "yes") == "yes"){
1926
expect_true(is.data.frame(trans$data))
2027
expect_equal(nrow(trans$data), 1)
2128
expect_true(is.data.frame(trans$tokens))
22-
expect_equal(nrow(trans$tokens), 23)
23-
onlyalpha <- function(x){
24-
x <- gsub("[^[:alnum:] ]", "", x)
25-
x <- x[nchar(x) > 0]
26-
x <- tolower(x)
27-
x
28-
}
29+
expect_equal(length(onlyalpha(trimws(trans$tokens$token))), 23)
2930
expect_equal(onlyalpha(trimws(trans$data$text)), onlyalpha("And so my fellow Americans ask not what your country can do for you ask what you can do for your country."))
3031
expect_equal(onlyalpha(trimws(trans$tokens$token)), onlyalpha(c("And", "so", "my", "fellow", "Americans", "ask", "not", "what",
3132
"your", "country", "can", "do", "for", "you", "ask", "what",

0 commit comments

Comments
 (0)