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

Bug in collocationAnalysis.R #14

Open
perkuhn opened this issue Mar 26, 2024 · 0 comments
Open

Bug in collocationAnalysis.R #14

perkuhn opened this issue Mar 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@perkuhn
Copy link

perkuhn commented Mar 26, 2024

bug in:

https://github.com/KorAP/RKorAPClient/blob/master/R/collocationAnalysis.R

presumably in line:

335 '<span class="context-left">(<span class="more"></span>)?(.*[^ ]) *</span><span class="match"><mark>.*</mark></span><span class="context-right"> *([^<]*)'

error not deterministic, not reproducable

presumably because one snippet is selected by chance as "example" that does not follow the structure of the line above, found at least one prove (only trailing part shown):

S78/AUG/00081:
.. </mark><span class="cutted"></span></span><span class="context-right">

suggested change (minimal, should be cross-checked with dtd of the structure):

'<span class="context-left">(<span class="more"></span>)?(.*[^ ]) *</span><span class="match"><mark>.*</mark>(<span class="cutted"></span>)?</span><span class="context-right"> *([^<]*)'

occurred when running following script:

...
QUERY = c("nachhaltig")
LNQ <- TRUE

VC <- c("textType = /[^:][Zz]eit./ & availability!=QAO-NC-LOC:ids & pubPlaceKey=DE & pubDate since 1975 & pubDate until 1981")

df <- collocationAnalysis(
kco,
node = QUERY,
vc = VC,
lemmatizeNodeQuery = LNQ,
lemmatizeCollocateQuery = FALSE,
leftContextSize = 5,
rightContextSize = 5,
withinSpan = "base/s=s",
searchHitsSampleLimit = 40000,
topCollocatesLimit = -1
)

...

-->

Searching "(contains(<base/s=s>, (beeinflussen []{0,4} [tt/l=nachhaltig] | [tt/l=nachhaltig] []{0,4} beeinflussen)))" in "textType = /[^:][Zz]eit./ & availability!=QAO-NC-LOC:ids & pubPlaceKey=DE & pubDate since 1975 & pubDate until 1981": 18 hits, took 5.587511354 s

500 KorAP API request failed
Error in purrr::pmap():
ℹ In index: 3.
Caused by error in out[i] <- if (matchOnly) { gsub(".*<mark>(.+)</mark>.*", "\\1", example) } else { stringr::str_replace(example, "<[^>]*>", "") }:
! Ersetzung hat Länge 0
Run rlang::last_trace() to see where the error occurred.

Backtrace:

  1. ├─base::source("~/R-dev/collocateRankSeriesDynamicSpans.R", echo = TRUE)

  2. │ ├─base::withVisible(eval(ei, envir))

  3. │ └─base::eval(ei, envir)

  4. │ └─base::eval(ei, envir)

  5. ├─RKorAPClient::collocationAnalysis(...) at ~/R-dev/collocateRankSeriesDynamicSpans.R:97:3

  6. ├─RKorAPClient::collocationAnalysis(...)

  7. │ └─RKorAPClient (local) .local(kco, ...)

  8. │ ├─... %>% bind_rows()

  9. │ └─purrr::pmap(...)

  10. │ └─purrr:::pmap_("list", .l, .f, ..., .progress = .progress)

  11. │ ├─purrr:::with_indexed_errors(...)

  12. │ │ └─base::withCallingHandlers(...)

  13. │ ├─purrr:::call_with_cleanup(...)

  14. │ └─RKorAPClient (local) .f(node = .l[[1L]][[i]], vc = .l[[2L]][[i]], ...)

  15. │ ├─RKorAPClient::collocationAnalysis(...)

  16. │ └─RKorAPClient::collocationAnalysis(...)

  17. │ └─RKorAPClient (local) .local(kco, ...)

  18. │ └─RKorAPClient:::findExample(kco, query = result$query, vc = result$vc)

  19. └─dplyr::bind_rows(.)

  20. └─rlang::list2(...)
    Run rlang::last_trace(drop = FALSE) to see 4 hidden frames.

  21. └─base::.handleSimpleError(...)

  22. └─purrr (local) h(simpleError(msg, call))

  23. └─cli::cli_abort(...)
    
  24.   └─rlang::abort(...)
    

after clearing cache worked fine and continued to

Searching "(contains(<base/s=s>, (beeinflußt []{0,4} [tt/l=nachhaltig] | [tt/l=nachhaltig] []{0,4} beeinflußt)))" in "textType = /[^:][Zz]eit./ & availability!=QAO-NC-LOC:ids & pubPlaceKey=DE & pubDate since 1975 & pubDate until 1981": 16 hits, took 5.278042045 s
Retrieved page 1/1 in 5.328346217 s

@kupietz kupietz added the bug Something isn't working label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants