<commit_before>package edu.virginia.psyc.pi.domain.json;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: dan
 * Date: 3/10/14
 * Time: 10:28 PM
 * An Java Object representation of data returned from PIPlayer.  This representation
 * is designed for storing in a relational database.
 */
public class TrialJson {

    private long id;
    private int log_serial;
    private String trial_id;
    private String name;
    private String responseHandle;
    private int latency;
    private List<String> stimuli;
    private List<String> media;
    private Map<String,String> data;
    private String script;
    private String session;
    private int participant;


    @Override
    public String toString() {
        return "TrialJson{" +
                "id=" + id +
                ", log_serial=" + log_serial +
                ", trial_id='" + trial_id + '\'' +
                ", name='" + name + '\'' +
                ", responseHandle='" + responseHandle + '\'' +
                ", latency=" + latency +
                ", stimuli=" + stimuli +
                ", media=" + media +
                ", data=" + data +
                ", script='" + script + '\'' +
                ", session='" + session + '\'' +
                ", participant=" + participant +
                '}';
    }

    /**
     * Retruns the headers of an interpretation report in the order they
     * should occur.
     * @return
     */
    public static List<String> interpretationReportHeaders() {
        List<String> headers = new ArrayList<String>();
        headers.add("participant");
        headers.add("sessionName");
        headers.add("scriptName");
        headers.add("session");
        headers.add("trial");
        headers.add("positive");
//        headers.add("paragraph");
//        headers.add("question");
        headers.add("letter latency");
        headers.add("letter correct");
        headers.add("question latency");
        headers.add("question correct");

        return headers;
    }

    public Map<String,String> toInterpretationReport() {

        Map<String,String> report = new HashMap<String, String>();

        // Return an empty row for invalid results.
        if(!this.name.equals("posneg")) return report;

        report.put("participant", participant+"");
        report.put("sessionName", session);
        report.put("scriptName", script);
        report.put("session",    log_serial+"");
        report.put("trial",      trial_id);
        report.put("positive",   data.get("positive"));
//        report.put("paragraph",  data.get("paragraph"));
//        report.put("question",   data.get("question"));
        report.put("letter latency",   data.get("letter_latency"));
        report.put("letter correct",   data.get("correctOnLetter"));
        report.put("question latency",   data.get("question_latency"));
        report.put("question correct",   data.get("correctOnQuestion"));

        return report;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getLog_serial() {
        return log_serial;
    }

    public void setLog_serial(int log_serial) {
        this.log_serial = log_serial;
    }
<commit_msg>re-adding question and answer to output for reference.<commit_after>package edu.virginia.psyc.pi.domain.json;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: dan
 * Date: 3/10/14
 * Time: 10:28 PM
 * An Java Object representation of data returned from PIPlayer.  This representation
 * is designed for storing in a relational database.
 */
public class TrialJson {

    private long id;
    private int log_serial;
    private String trial_id;
    private String name;
    private String responseHandle;
    private int latency;
    private List<String> stimuli;
    private List<String> media;
    private Map<String,String> data;
    private String script;
    private String session;
    private int participant;


    @Override
    public String toString() {
        return "TrialJson{" +
                "id=" + id +
                ", log_serial=" + log_serial +
                ", trial_id='" + trial_id + '\'' +
                ", name='" + name + '\'' +
                ", responseHandle='" + responseHandle + '\'' +
                ", latency=" + latency +
                ", stimuli=" + stimuli +
                ", media=" + media +
                ", data=" + data +
                ", script='" + script + '\'' +
                ", session='" + session + '\'' +
                ", participant=" + participant +
                '}';
    }

    /**
     * Retruns the headers of an interpretation report in the order they
     * should occur.
     * @return
     */
    public static List<String> interpretationReportHeaders() {
        List<String> headers = new ArrayList<String>();
        headers.add("participant");
        headers.add("sessionName");
        headers.add("scriptName");
        headers.add("session");
        headers.add("trial");
        headers.add("positive");
        headers.add("letter latency");
        headers.add("letter correct");
        headers.add("question latency");
        headers.add("question correct");
        headers.add("paragraph");
        headers.add("question");
        return headers;
    }

    public Map<String,String> toInterpretationReport() {

        Map<String,String> report = new HashMap<String, String>();

        // Return an empty row for invalid results.
        if(!this.name.equals("posneg")) return report;

        report.put("participant", participant+"");
        report.put("sessionName", session);
        report.put("scriptName", script);
        report.put("session",    log_serial+"");
        report.put("trial",      trial_id);
        report.put("positive",   data.get("positive"));
        report.put("letter latency",   data.get("letter_latency"));
        report.put("letter correct",   data.get("correctOnLetter"));
        report.put("question latency",   data.get("question_latency"));
        report.put("question correct",   data.get("correctOnQuestion"));
        report.put("paragraph",  data.get("paragraph"));
        report.put("question",   data.get("question"));

        return report;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getLog_serial() {
        return log_serial;
    }

    public void setLog_serial(int log_serial) {
        this.log_serial = log_serial;
    }

{'fraction_non_alphanumeric': 0.13609291244788566, 'fraction_numerical': 0.0026801667659321023, 'mean_word_length': 2.230880230880231, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1086553', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1777, 'n_words': 445}