Skip to content

Commit

Permalink
no ranges_to_cpos() warning in decode(to = "AnnotatedPlainTextDocument")
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Blätte authored and Andreas Blätte committed Feb 16, 2024
1 parent 9c928ec commit 176298e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: polmineR
Type: Package
Title: Verbs and Nouns for Corpus Analysis
Version: 0.8.9.9001
Date: 2023-11-04
Version: 0.8.9.9002
Date: 2024-02-16
Authors@R: c(
person("Andreas", "Blaette", role = c("aut", "cre"), email = "andreas.blaette@uni-due.de", comment = c(ORCID = "0000-0001-8970-8010")),
person("Christoph", "Leonhardt", role = "ctb"),
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# polmineR v0.8.9.9001
# polmineR v0.8.9.9001-9002

* S4 class has new slot 'match' for decoded matches for query.
* Method `ranges()` adds decoded token stream of query matches to 'ranges'
Expand All @@ -7,6 +7,8 @@ object (slot "match") that is returned #277.
'query' or by 'match' #278.
* `subset()` for subcorpus objects issued ERROR if s-attribute did not have
values. Warning issued now.
* No warning for `decode(to = "AnnotatedPlainTextDocument")` of no regions
available for s_attribute defined by `mw`.

# polmineR v0.8.9

Expand Down
5 changes: 5 additions & 0 deletions R/decode.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ as.AnnotatedPlainTextDocument <- function(x, p_attributes = NULL, s_attributes =
region_matrix = x@cpos,
s_attribute = s_attr
)
# missing regions for s_attr within regions result in NAs
drop <- which(apply(struc_matrix, 1, function(row) any(is.na(row))))
if (length(drop) > 0L) struc_matrix <- struc_matrix[-drop,]
if (nrow(struc_matrix) == 0L) return(NULL)

strucs <- ranges_to_cpos(struc_matrix)
strucs_min <- unique(strucs[strucs >= 0L])
if (length(strucs_min) == 0L) return(NULL)
Expand Down

0 comments on commit 176298e

Please sign in to comment.