What would be reasonable limits on what we allow a user to ask for the pattern matching functions? It appears to be an issue mainly in the number of patterns. Below, the number of patterns in stopwords("en") is 175, so 160/8.5 = 18.8 is not bad, but it's till 2.5 minutes of frozen console.
Maybe we could issue a warning and ask to proceed if the user tries to fit more than a vector of 10 patterns? We could set this limit and the prompt with warning as global options.
library(quanteda)
## Package version: 1.9.9007
data_corpus_guardian <- as.corpus(quanteda.corpora::download("data_corpus_guardian"))
# ndoc = 6000
system.time(
kw1 <- kwic(data_corpus_guardian, "the")
)
## user system elapsed
## 8.473 0.445 8.615
# compare with longer documents
data_corpus_guardiansents <- corpus_reshape(data_corpus_guardian, to = "sentences")
system.time(
kw3 <- kwic(data_corpus_guardiansents, "the")
)
## user system elapsed
## 12.248 0.388 11.803
# with shorter documents
data_corpus_guardianonebig <-
corpus(texts(data_corpus_guardian, groups = rep(1, ndoc(data_corpus_guardian))))
system.time(
kw4 <- kwic(data_corpus_guardianonebig, "the")
)
## user system elapsed
## 6.233 0.377 6.653
# not really ok
system.time(
kw2 <- kwic(data_corpus_guardian, stopwords("en"))
)
## user system elapsed
## 160.170 5.907 125.154
What would be reasonable limits on what we allow a user to ask for the pattern matching functions? It appears to be an issue mainly in the number of patterns. Below, the number of patterns in
stopwords("en")is 175, so 160/8.5 = 18.8 is not bad, but it's till 2.5 minutes of frozen console.Maybe we could issue a warning and ask to proceed if the user tries to fit more than a vector of 10 patterns? We could set this limit and the prompt with warning as global options.