PolMine / polmineR

R-package for text mining with the Corpus Workbench (CWB) as backend
48 stars 9 forks source link

hits() throws error when there are not matches for query #279

Closed ablaette closed 6 months ago

ablaette commented 10 months ago
library(polmineR)
use("RcppCWB")
corpus("REUTERS") %>% 
  hits(query = '"adf"', s_attribute = "id", cqp = TRUE)
corpus("REUTERS") %>% 
  hits(query = 'adf', s_attribute = "id", cqp = TRUE)
ablaette commented 6 months ago

The core of the issue is that the ranges() method was not failsafe when no query matches were obtained. So you saw the original error here.

dt <- corpus("REUTERS") %>% 
  ranges(query = '"adf"', cqp = TRUE) %>% 
  as.data.table()

Fixed this. No warnings thrown by the hits()-method.