Skip to content

Commit

Permalink
Fixed merging issues
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'refs/remotes/origin/develop' into develop
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
henriquesposito committed Aug 21, 2024
2 parents 01e6a1e + e18d9eb commit d8cd833
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(gather_topics)
export(get_urgency)
export(read_pdf)
export(select_priorities)
export(sim_urgency)
export(split_text)
import(dplyr)
import(quanteda)
Expand Down
28 changes: 28 additions & 0 deletions R/urgency.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,31 @@ get_urgency <- function(.data, normalize = "tokens") {
stringr::str_count(as.character(v), paste0("\\b", commitment_words$terms[i], "\\b"))*
commitment_words$score_commitment_scaled[i])))
}

#' Simulating urgency
#'
#' @examples
#' sim_urgency()
#' @export
sim_urgency <- function(urgency,
commitment, intensity, timing, frequency,
pronoun = "We"){
if(!missing(urgency)){
combins <- expand.grid(c("",int$word), comm$word, stringsAsFactors = FALSE)
combins <- merge(combins, int, by.x = "Var1", by.y = "word")
combins <- combins[,c("Var1","Var2","Rescaled")]
combins <- merge(combins, comm, by.x = "Var2", by.y = "word")
combins <- combins[,c("Var1","Var2","Rescaled.x","Rescaled.y")]
combins$combo <- combins$Rescaled.x * combins$Rescaled.y
intcom <- combins[which.min(abs(urgency - combins$combo)),c("Var1","Var2")]
out <- paste(pronoun, paste(intcom, collapse = " "), "do this.")
} else if(!missing(commitment)){
commit <- comm$word[which.min(abs(abs(commitment) - comm$Rescaled))]
if(commitment<0) commit <- paste(commit, sample(c("not","never"),1))
if(!missing(intensity)){
intensifier <- int$word[which.min(abs(abs(intensity) - int$Rescaled))]
out <- paste(pronoun, intensifier, commit, "do this.")
} else out <- paste(pronoun, commit, "do this.")
} else out <- paste(pronoun, "do this.")
out
}
14 changes: 14 additions & 0 deletions man/sim_urgency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions poldis.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

0 comments on commit d8cd833

Please sign in to comment.