Commit 04b69502 authored by Xiaoying Pu's avatar Xiaoying Pu

discovered mousetracker's built-in rand functionality for stimuli; wrote a...

discovered mousetracker's built-in rand functionality for stimuli; wrote a lovely clojure script for generating strings
parent e6737942
......@@ -7,12 +7,14 @@
<group>
<file>file:/Users/pxy/dm_task/src/tracker/UDPController.java</file>
<file>file:/Users/pxy/dm_task/src/util/EventType.java</file>
<file>file:/Users/pxy/dm_task/src/util/EventListener.java</file>
<file>file:/Users/pxy/dm_task/src/tracker/PrimaryTaskController.java</file>
<file>file:/Users/pxy/dm_task/src/digit/controller/SecondaryTaskController.java</file>
<file>file:/Users/pxy/dm_task/src/util/EventListener.java</file>
<file>file:/Users/pxy/dm_task/src/util/Persistence.java</file>
<file>file:/Users/pxy/dm_task/src/digit/DigitTaskFacade.java</file>
</group>
......
(def male "Man, Boy, Father, Male, Grandpa, Husband, Son, Uncle")
(def female "Girl, Female, Aunt, Daughter, Wife, Woman, Mother, Grandma")
(def art "Philosophy, Humanities, Arts, Literature, English, Music, History")
(def science "Science, Physics, Chemistry, Math, Geology, Astronomy, Engineering")
(defn parse
[string]
(let
[splited (clojure.string/split male #", ")]
(apply str (interpose
"|"
(for [token splited]
(str "2*" token))))))
package tracker;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* type,stim,cond,rand,correct,default-compare,resp_1,resp_2
*
* @author pxy
*/
public class Decision {
private final String male = "Man, Boy, Father, Male, Grandpa, Husband, Son, Uncle";
// from my lovely clojure code!
public final String MALE = "2*Man|2*Boy|2*Father|2*Male|2*Grandpa|2*Husband|2*Son|2*Uncle";
private final String female = "Girl, Female, Aunt, Daughter, Wife, Woman, Mother, Grandma";
public final List<String> FEMALE = Arrays.asList(female.split(", "));
private final String unsplitScience = "Biology, Physics, Chemistry, Math, Geology, Astronomy, Engineering";
public final List<String> SCIENCE = Arrays.asList(unsplitScience.split(", "));
private final String arts = "Philosophy, Humanities, Arts, Literature, English, Music, History";
public final List<String> ARTS = Arrays.asList(arts.split(", "));
private final String typeChar = "2";
private final String typeRandomPick = "5";
private final String typePause = "0";
private final String rand = "1";
private static final Random randomHandler = new Random();
public String getCategory1() {
String[] result = new String[]{};
return String.join(",", result);
}
public String getCategory2() {
String[] result = new String[]{};
return String.join(",", result);
}
public String getMix() {
String[] result = new String[]{};
return String.join(",", result);
}
public String getBreak() {
String[] result = new String[]{};
return String.join(",", result);
}
}
package util;
import java.util.Random;
/**
* Depends on UDPConstants
*
* @author xp002
*/
public class TrialStrGenerator {
private static int seed = 0;
private static final Random randomHandler = new Random();
/**
* type,stim,cond,rand,correct,default-compare,resp_1,resp_2 No this
* method's gonna explode!!!!
*
* @param cat1
* @param cat2
* @return a row of stimulus to MouseTracker
*/
public static String genARow(boolean cat1, boolean cat2) {
/* hardcoded params for MouseTracker */
String type = "2"; // for type "string"
String rand = "1"; // Doesn't matter here, cus stimuili are sent one at a time;
// MouseTracker does not reorder them
/* one of male / female / arts / science */
String stim1, stim2;
if (cat1) {
stim1 = UDPConstants.MALE.get(randomHandler.nextInt(UDPConstants.MALE.size()));
} else {
stim1 = UDPConstants.FEMALE.get(randomHandler.nextInt(UDPConstants.FEMALE.size()));
}
if (cat2) {
stim2 = UDPConstants.SCIENCE.get(randomHandler.nextInt(UDPConstants.SCIENCE.size()));
} else {
stim2 = UDPConstants.ARTS.get(randomHandler.nextInt(UDPConstants.ARTS.size()));
}
/* type,stim,cond,rand,correct,default-compare,resp_1,resp_2 */
String[] result = {type, rand, stim1};
/* Java 8 feature */
return String.join(",", result);
}
}
package util;
import java.util.Arrays;
import java.util.List;
/**
*
* @author Xiaoying Pu <xp002@bucknell.edu>
......@@ -53,18 +50,6 @@ public class UDPConstants {
// "2,Wife,LWL,1,1,2,Female,Male"
// };
private static final String male = "Man, Boy, Father, Male, Grandpa, Husband, Son, Uncle";
public static final List<String> MALE = Arrays.asList(male.split(", "));
private static final String female = "Girl, Female, Aunt, Daughter, Wife, Woman, Mother, Grandma";
public static final List<String> FEMALE = Arrays.asList(female.split(", "));
private static final String unsplitScience = "Biology, Physics, Chemistry, Math, Geology, Astronomy, Engineering";
public static final List<String> SCIENCE = Arrays.asList(unsplitScience.split(", "));
private static final String arts = "Biology, Physics, Chemistry, Math, Geology, Astronomy, Engineering";
public static final List<String> ARTS = Arrays.asList(arts.split(", "));
public static int success = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment