From 66a5ab42c2d7603f48162552f2ddf069989ff5c3 Mon Sep 17 00:00:00 2001 From: vzhang03 Date: Mon, 21 Oct 2024 11:21:28 -0400 Subject: [PATCH] Initial delimiter model --- packages/plugin-spr/examples/delimiter.html | 32 +++++++++++++++++++++ packages/plugin-spr/src/index.ts | 21 ++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 packages/plugin-spr/examples/delimiter.html diff --git a/packages/plugin-spr/examples/delimiter.html b/packages/plugin-spr/examples/delimiter.html new file mode 100644 index 00000000..02c84a0e --- /dev/null +++ b/packages/plugin-spr/examples/delimiter.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/plugin-spr/src/index.ts b/packages/plugin-spr/src/index.ts index 9b42d52a..4fe279e5 100644 --- a/packages/plugin-spr/src/index.ts +++ b/packages/plugin-spr/src/index.ts @@ -32,6 +32,10 @@ const info = { type: ParameterType.INT, default: 1, }, + delimiting: { + type: ParameterType.BOOL, + default: false, + }, }, data: { /* The representation of the structured_reading_string that was used. Combined with the mode this @@ -103,7 +107,15 @@ class SprPlugin implements JsPsychPlugin { // creates inital reading string -> TODO: should instead use mode to determine if (trial.structured_reading_string.length > 0) this.structured_reading_string = trial.structured_reading_string; - else + else if (trial.delimiting) { + this.structured_reading_string = this.createReadingString( + trial.unstructured_reading_string, + trial.chunk_size, + trial.line_size, + "%" + ); + console.log("delimiting is true", this.structured_reading_string); + } else this.structured_reading_string = this.createReadingString( trial.unstructured_reading_string, trial.chunk_size, @@ -125,9 +137,12 @@ class SprPlugin implements JsPsychPlugin { private createReadingString( unstructured_reading_string: string, chunk_size: number, - line_size: number + line_size: number, + delimiter?: string ): string[] { - const split_text = unstructured_reading_string.split(" "); + const split_text = delimiter + ? unstructured_reading_string.split(delimiter) + : unstructured_reading_string.split(" "); const res = []; var current_chunk = [];