Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p_attribute_encode() should also have argument reload #68

Closed
ablaette opened this issue Feb 14, 2024 · 1 comment
Closed

p_attribute_encode() should also have argument reload #68

ablaette opened this issue Feb 14, 2024 · 1 comment

Comments

@ablaette
Copy link
Collaborator

We have introduced it with CorpusData$encode() - but p_attribute_encode() should have argument reload to, because running RcppCWB::cl_delete_corpus() and RcppCWB::cqp_reset_registry() is not intuitive at all.

@ablaette
Copy link
Collaborator Author

This is a minimal example I use in another context - but it demonstrates that using the newly created corpus fails unless you call RcppCWB::cqp_reset_registry().

library(cwbtools)
library(magrittr)
library(tokenizers)
library(dplyr)
library(polmineR)

regdir <- fs::path(tempdir(), "regdir")
datadir <- fs::path(tempdir(), "corpusdata", "tmpcorpus")

dir.create(regdir)
dir.create(datadir, recursive = TRUE)

tokenstream <- c("Das müssen Sie einfach hören!") %>% 
  iconv(from = "UTF-8", to = "latin1") %>%
  tokenize_words(lowercase = FALSE, strip_punct = FALSE)

p_attribute_encode(
  token_stream = tokenstream[[1]],
  p_attribute = "word",
  registry_dir = regdir,
  data_dir = datadir,
  corpus = "LATIN1",
  encoding = "latin1",
  method = "CWB",
  compress = FALSE,
  quietly = TRUE
)

RcppCWB::cqp_reset_registry(registry = regdir)

corpus("LATIN1", registry_dir = regdir) %>%
  get_token_stream(p_attribute = "word")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant