Skip to content

Commit

Permalink
chaning parameter name dataset_to_merge_assessments
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Kjell authored and Oscar Kjell committed Dec 4, 2024
1 parent 6e5a063 commit 3ce8fef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions R/2_4_0_textPredict_Assess_Classify.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' @param story_id (vector; only for "texttrained"-model_type) Vector of story-ids. Specify this to get story level scores (i.e., summed sentence
#' probabilities corrected for word count). When there is both story_id and participant_id indicated, the function
#' returns a list including both story level and person level prediction corrected for word count. (default = NULL)
#' @param dataset_to_merge_predictions (R-object, tibble; only for "texttrained"-model_type) Insert your data here to integrate predictions to your dataset,
#' @param dataset_to_merge_assessments (R-object, tibble; only for "texttrained"-model_type) Insert your data here to integrate predictions to your dataset,
#' (default = NULL).
#' @param save_embeddings (boolean; only for "texttrained"-model_type) If set to TRUE, embeddings will be saved with a unique identifier, and
#' will be automatically opened next time textPredict is run with the same text. (default = TRUE)
Expand Down Expand Up @@ -110,7 +110,7 @@
#' texts = implicit_motive_data$satisfactiontexts,
#' model_info = "implicit_power_roberta_large_L23_v1",
#' participant_id = implicit_motive_data$participant_id,
#' dataset_to_merge_predictions = implicit_motive_data
#' dataset_to_merge_assessments = implicit_motive_data
#' )
#'
#' # Examine results
Expand Down Expand Up @@ -159,7 +159,7 @@ textPredict <- function(
save_dir = "wd",
save_name = "textPredict",
story_id = NULL,
dataset_to_merge_predictions = NULL,
dataset_to_merge_assessments = NULL,
previous_sentence = FALSE,
## fine-tuned model specific parameters ##
tokenizer_parallelism = FALSE,
Expand Down Expand Up @@ -270,7 +270,7 @@ textPredict <- function(
save_dir = save_dir,
save_name = save_name,
story_id = story_id,
dataset_to_merge_predictions = dataset_to_merge_predictions,
dataset_to_merge_assessments = dataset_to_merge_assessments,
previous_sentence = previous_sentence,
...)

Expand Down Expand Up @@ -317,7 +317,7 @@ textPredict <- function(
show_texts = show_texts,
participant_id = participant_id,
story_id = story_id,
dataset_to_merge_predictions = dataset_to_merge_predictions,
dataset_to_merge_assessments = dataset_to_merge_assessments,
previous_sentence = previous_sentence,
device = device,
)
Expand Down
6 changes: 3 additions & 3 deletions R/2_4_1_textPredictTextTrained.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ textReturnEmbedding <- function(
#' @param story_id (vector; only works for implicit motives models) Vector of story-ids. Specify this to get story level scores (i.e., summed sentence
#' probabilities corrected for word count). When there is both story_id and participant_id indicated, the function
#' returns a list including both story level and person level prediction corrected for word count. (default = NULL)
#' @param dataset_to_merge_predictions (tibble; only works for implicit motives models) Insert your data here to integrate predictions to your dataset,
#' @param dataset_to_merge_assessments (tibble; only works for implicit motives models) Insert your data here to integrate predictions to your dataset,
#' (default = NULL).
#' @param previous_sentence (Boolean; only works for implicit motives models) If set to TRUE, word-embeddings will be averaged over the current and previous
#' sentence per story-id. For this, both participant-id and story-id must be specified.
Expand Down Expand Up @@ -394,7 +394,7 @@ textReturnEmbedding <- function(
#' texts = implicit_motive_data$satisfactiontexts,
#' model_info = "implicit_power_roberta_large_L23_v1",
#' participant_id = implicit_motive_data$participant_id,
#' dataset_to_merge_predictions = implicit_motive_data
#' dataset_to_merge_assessments = implicit_motive_data
#' )
#'
#' # Examine results
Expand Down Expand Up @@ -436,7 +436,7 @@ textPredictTextTrained <- function(
show_texts = FALSE,
participant_id = NULL,
story_id = NULL,
dataset_to_merge_predictions = NULL,
dataset_to_merge_assessments = NULL,
previous_sentence = FALSE,
device = "cpu",
...) {
Expand Down
18 changes: 9 additions & 9 deletions R/2_4_2_textPredictImplicitMotives.R
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ implicit_motives_results <- function(
# If no merge was successful, show the message
if (!merge_success) {
message(colourise(
"Note: dataset_to_merge_predictions does not have the same number of rows as the predictions and cannot be merged.\n",
"Note: dataset_to_merge_assessments does not have the same number of rows as the predictions and cannot be merged.\n",
"brown"
))
}
Expand Down Expand Up @@ -509,7 +509,7 @@ get_implicit_model_info <- function(
#' @param story_id (vector; only works for implicit motives models) Vector of story-ids. Specify this to get story level scores (i.e., summed sentence
#' probabilities corrected for word count). When there is both story_id and participant_id indicated, the function
#' returns a list including both story level and person level prediction corrected for word count. (default = NULL)
#' @param dataset_to_merge_predictions (tibble; only works for implicit motives models) Insert your data here to integrate predictions to your dataset,
#' @param dataset_to_merge_assessments (tibble; only works for implicit motives models) Insert your data here to integrate predictions to your dataset,
#' (default = NULL).
#' @param previous_sentence (Boolean; only works for implicit motives models) If set to TRUE, word-embeddings will be averaged over the current and previous
#' sentence per story-id. For this, both participant-id and story-id must be specified.
Expand Down Expand Up @@ -561,7 +561,7 @@ get_implicit_model_info <- function(
#' texts = implicit_motive_data$satisfactiontexts,
#' model_info = "implicit_power_roberta_large_L23_v1",
#' participant_id = implicit_motive_data$participant_id,
#' dataset_to_merge_predictions = implicit_motive_data
#' dataset_to_merge_assessments = implicit_motive_data
#' )
#'
#' # Examine results
Expand Down Expand Up @@ -604,7 +604,7 @@ textPredictImplicitMotives <- function(
show_texts = FALSE,
participant_id = NULL,
story_id = NULL,
dataset_to_merge_predictions = NULL,
dataset_to_merge_assessments = NULL,
previous_sentence = FALSE,
device = "cpu",
...) {
Expand All @@ -628,10 +628,10 @@ textPredictImplicitMotives <- function(
model_name <- model_info
lower_case_model <- as.character(tolower(model_name))

if (is.null(participant_id) & is.null(story_id) & !is.null(dataset_to_merge_predictions)){
message(colourise(paste("Note: The 'texts' were not at the sentence level, and while dataset_to_merge_predictions",
if (is.null(participant_id) & is.null(story_id) & !is.null(dataset_to_merge_assessments)){
message(colourise(paste("Note: The 'texts' were not at the sentence level, and while dataset_to_merge_assessments",
" was provided, participant_id and story_id were missing. ",
"The function treated each row_id as a participant_id when merging assessments into dataset_to_merge_predictions. \n", sep=""),
"The function treated each row_id as a participant_id when merging assessments into dataset_to_merge_assessments. \n", sep=""),
"purple"))

use_row_id_name <- TRUE
Expand Down Expand Up @@ -681,7 +681,7 @@ textPredictImplicitMotives <- function(
show_texts = show_texts,
participant_id = participant_id,
story_id = story_id,
dataset_to_merge_predictions = dataset_to_merge_predictions,
dataset_to_merge_assessments = dataset_to_merge_assessments,
previous_sentence = previous_sentence,
device = device
)
Expand Down Expand Up @@ -731,7 +731,7 @@ textPredictImplicitMotives <- function(
story_id = story_id,
predicted_scores2 = predicted_scores2,
texts = texts,
dataset = dataset_to_merge_predictions,
dataset = dataset_to_merge_assessments,
lower_case_model = lower_case_model
)

Expand Down
10 changes: 5 additions & 5 deletions man/textPredict.Rd

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

12 changes: 6 additions & 6 deletions tests/testthat/test_2_6_textPredict_implicitmotives.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test_that("textPredict Implicit motives", {
texts = PSE_stories_participant_level$stories,
model_info = "implicitpower_roberta23_nilsson2024",
participant_id = PSE_stories_participant_level$Participant_ID,
dataset_to_merge_predictions = PSE_stories_participant_level
dataset_to_merge_assessments = PSE_stories_participant_level
)
testthat::expect_that(predictions_participant_1, testthat::is_a("list"))
testthat::expect_equal(length(predictions_participant_1), 3)
Expand All @@ -144,7 +144,7 @@ test_that("textPredict Implicit motives", {
model_info = "implicitpower_roberta23_nilsson2024",
show_texts = T
# participant_id = PSE_stories_participant_level$Participant_ID,
# dataset_to_merge_predictions = PSE_stories_participant_level
# dataset_to_merge_assessments = PSE_stories_participant_level
)
testthat::expect_that(predictions_participant_2, testthat::is_a("tbl_df"))
testthat::expect_equal(length(predictions_participant_2), 4)
Expand All @@ -156,7 +156,7 @@ test_that("textPredict Implicit motives", {
model_info = "implicitachievement_roberta23_nilsson2024",
participant_id = PSE_stories_story_level$Participant_ID,
story_id = PSE_stories_story_level$story_id,
dataset_to_merge_predictions = PSE_stories_story_level
dataset_to_merge_assessments = PSE_stories_story_level
)
testthat::expect_that(predictions_story_1, testthat::is_a("list"))
testthat::expect_equal(length(predictions_story_1), 4)
Expand All @@ -170,7 +170,7 @@ test_that("textPredict Implicit motives", {
model_info = "implicitachievement_roberta23_nilsson2024",
#participant_id = PSE_stories_story_level$Participant_ID,
#story_id = PSE_stories_story_level$story_id,
dataset_to_merge_predictions = PSE_stories_story_level
dataset_to_merge_assessments = PSE_stories_story_level
)
testthat::expect_that(predictions_story_2, testthat::is_a("list"))
testthat::expect_equal(length(predictions_story_2), 3)
Expand All @@ -182,7 +182,7 @@ test_that("textPredict Implicit motives", {
model_info = "implicitaffiliation_roberta23_nilsson2024",
participant_id = PSE_stories_sentence_level$Participant_ID,
story_id = PSE_stories_sentence_level$story_id,
dataset_to_merge_predictions = PSE_stories_sentence_level
dataset_to_merge_assessments = PSE_stories_sentence_level
)
testthat::expect_that(predictions_sentence_1, testthat::is_a("list"))
testthat::expect_equal(length(predictions_sentence_1), 4)
Expand All @@ -195,7 +195,7 @@ test_that("textPredict Implicit motives", {
model_info = "implicitaffiliation_roberta23_nilsson2024",
#participant_id = PSE_stories_sentence_level$Participant_ID,
#story_id = PSE_stories_sentence_level$story_id,
dataset_to_merge_predictions = PSE_stories_sentence_level
dataset_to_merge_assessments = PSE_stories_sentence_level
)
testthat::expect_that(predictions_sentence_2, testthat::is_a("list"))
testthat::expect_equal(length(predictions_sentence_2), 3)
Expand Down

0 comments on commit 3ce8fef

Please sign in to comment.