From cd05733648eef19b441823b6725d8ce92ef3460e Mon Sep 17 00:00:00 2001 From: Erik de Vries Date: Tue, 5 Feb 2019 14:26:28 +0100 Subject: [PATCH] actorizer: Additional fix for missing punctuation (see previous commit) --- R/actorizer.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/actorizer.R b/R/actorizer.R index 741bee9..8baa021 100644 --- a/R/actorizer.R +++ b/R/actorizer.R @@ -30,10 +30,12 @@ actorizer <- function(out, localhost = F, ids, type, prefix, postfix, identifier select(-one_of('exists')) %>% # Removing ud.exists variable unnest() ud <- as.data.frame(udpipe_annotate(udmodel, x = doc$merged, parser = "none", doc_id = doc$`_id`)) - - ### The exception below is only valid for the UK, where the original UDPipe output misses a dot at the end of the article, but the actor output does not + + ### The exception below is only valid for the UK, where the original UDPipe output misses a dot at the end of the article, but the actor output does not ### (UK output is older than actor output, should be updated) - ud <- ud[-length(ud$sentence_id),] + if (!(ud_org$lemma[length(ud_org$lemma)] %in% c('!','?','.'))) { + ud <- ud[-length(ud$sentence_id),] + } if (length(ud_org$sentence_id) == length(ud$sentence_id)) { ud <- bind_cols(ud_org, sentence = ud$sentence, token = ud$token, doc_id = ud$doc_id) } else {