Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New experiment columns #64

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/src/components/View/TableView/ArrangeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ArrageTable = ({ result }: ArrageTableProps) => {
const handleExport = () => {
const tableData = flattenData(result, expandedExperiment, expandedCondition, expandedBehavior)

const escapeCsvValue = (value: string | number) => {
const escapeCsvValue = (value: string | number | null) => {
if (typeof value === 'string') {
// Escape double quotes by doubling them
value = value.replace(/"/g, '""')
Expand All @@ -72,6 +72,9 @@ const ArrageTable = ({ result }: ArrageTableProps) => {
value = `"${value}"`
}
}
if (value === null) {
value = '--'
}
return value
}

Expand Down
145 changes: 138 additions & 7 deletions client/src/components/View/TableView/hooks/data-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ export interface Behavior {
export interface Experiment {
experiment_name: string
experiment_description: string
participant_source: string
participant_source_category: string
units_randomized: string
units_analyzed: string
sample_size_randomized: number
sample_size_analyzed: number
sample_size_notes: string
adults: string
age_mean: number | string | null
age_sd: number | string | null
female_perc: number | string | null
male_perc: number | string | null
gender_other: number | string | null
language: string
language_secondary: string
compensation: string
demographics_conditions: string
population_other: string
conditions: Condition[]
}

Expand All @@ -19,7 +37,7 @@ export interface Result {
}

export type KeyValuePairs = {
[key: string]: number | string
[key: string]: number | string | null
}

export type TableData = {
Expand Down Expand Up @@ -53,7 +71,29 @@ export const flattenExperiment = (
expandedBehavior: boolean,
): TableData => {
const defaultHeaders = ['id', 'file_name']
const experimentHeaders = ['experiment_name', 'experiment_description']
const experimentHeaders = [
'experiment_name',
'experiment_description',
'participant_source',
'participant_source_category',
'units_randomized',
'units_analyzed',
'sample_size_randomized',
'sample_size_analyzed',
'sample_size_notes',
'adults',
'age_mean',
'age_sd',
'female_perc',
'male_perc',
'gender_other',
'language',
'language_secondary',
'compensation',
'demographics_conditions',
'population_other',
]

const conditionHeaders = [
'condition_name',
'condition_description',
Expand Down Expand Up @@ -86,6 +126,29 @@ export const flattenExperiment = (
file_name: data.file_name || '',
experiment_name: experiment.experiment_name,
experiment_description: experiment.experiment_description,
participant_source: experiment.participant_source,
participant_source_category: experiment.participant_source_category,
units_randomized: experiment.units_randomized,
units_analyzed: experiment.units_analyzed,
sample_size_randomized: experiment.sample_size_randomized,
sample_size_analyzed: experiment.sample_size_analyzed,
sample_size_notes: experiment.sample_size_notes,
adults: experiment.adults,
age_mean: experiment.age_mean,
age_sd: experiment.age_sd,
female_perc: experiment.female_perc,
male_perc: experiment.male_perc,
gender_other: experiment.gender_other,
// white_perc: experiment.white_perc,
// black_perc: experiment.black_perc,
// hispanic_perc: experiment.hispanic_perc,
// asian_perc: experiment.asian_perc,
// other_ethnicity_perc: experiment.other_ethnicity_perc,
language: experiment.language,
language_secondary: experiment.language_secondary,
compensation: experiment.compensation,
demographics_conditions: experiment.demographics_conditions,
population_other: experiment.population_other,
condition_name: condition.condition_name,
condition_description: condition.condition_description,
condition_type: condition.condition_type,
Expand All @@ -103,6 +166,29 @@ export const flattenExperiment = (
file_name: data.file_name || '',
experiment_name: experiment.experiment_name,
experiment_description: experiment.experiment_description,
participant_source: experiment.participant_source,
participant_source_category: experiment.participant_source_category,
units_randomized: experiment.units_randomized,
units_analyzed: experiment.units_analyzed,
sample_size_randomized: experiment.sample_size_randomized,
sample_size_analyzed: experiment.sample_size_analyzed,
sample_size_notes: experiment.sample_size_notes,
adults: experiment.adults,
age_mean: experiment.age_mean,
age_sd: experiment.age_sd,
female_perc: experiment.female_perc,
male_perc: experiment.male_perc,
gender_other: experiment.gender_other,
// white_perc: experiment.white_perc,
// black_perc: experiment.black_perc,
// hispanic_perc: experiment.hispanic_perc,
// asian_perc: experiment.asian_perc,
// other_ethnicity_perc: experiment.other_ethnicity_perc,
language: experiment.language,
language_secondary: experiment.language_secondary,
compensation: experiment.compensation,
demographics_conditions: experiment.demographics_conditions,
population_other: experiment.population_other,
condition_name: condition.condition_name,
condition_description: condition.condition_description,
condition_type: condition.condition_type,
Expand All @@ -114,13 +200,13 @@ export const flattenExperiment = (
const headersGroup = expandedBehavior
? [
{ name: 'Paper', span: 2 },
{ name: 'Experiments', span: 2 },
{ name: 'Experiments', span: experimentHeaders.length },
{ name: 'Conditions', span: 4 },
{ name: 'Behaviors', span: 4 },
]
: [
{ name: 'Paper', span: 2 },
{ name: 'Experiments', span: 2 },
{ name: 'Experiments', span: experimentHeaders.length },
{ name: 'Conditions', span: 4 },
{ name: 'Behaviors', span: 1 },
]
Expand All @@ -138,9 +224,31 @@ export const flattenExperiment = (
condition.condition_behaviors.map((behavior, beh_index) => ({
id: `${experiment_id}-${exp_index}-${con_index}-${beh_index}`,
file_name: data.file_name || '',

experiment_name: experiment.experiment_name,
experiment_description: experiment.experiment_description,
participant_source: experiment.participant_source,
participant_source_category: experiment.participant_source_category,
units_randomized: experiment.units_randomized,
units_analyzed: experiment.units_analyzed,
sample_size_randomized: experiment.sample_size_randomized,
sample_size_analyzed: experiment.sample_size_analyzed,
sample_size_notes: experiment.sample_size_notes,
adults: experiment.adults,
age_mean: experiment.age_mean,
age_sd: experiment.age_sd,
female_perc: experiment.female_perc,
male_perc: experiment.male_perc,
gender_other: experiment.gender_other,
// white_perc: experiment.white_perc,
// black_perc: experiment.black_perc,
// hispanic_perc: experiment.hispanic_perc,
// asian_perc: experiment.asian_perc,
// other_ethnicity_perc: experiment.other_ethnicity_perc,
language: experiment.language,
language_secondary: experiment.language_secondary,
compensation: experiment.compensation,
demographics_conditions: experiment.demographics_conditions,
population_other: experiment.population_other,
conditions: condition.condition_name,
behavior_name: behavior.behavior_name,
behavior_description: behavior.behavior_description,
Expand All @@ -154,6 +262,29 @@ export const flattenExperiment = (
file_name: data.file_name || '',
experiment_name: experiment.experiment_name,
experiment_description: experiment.experiment_description,
participant_source: experiment.participant_source,
participant_source_category: experiment.participant_source_category,
units_randomized: experiment.units_randomized,
units_analyzed: experiment.units_analyzed,
sample_size_randomized: experiment.sample_size_randomized,
sample_size_analyzed: experiment.sample_size_analyzed,
sample_size_notes: experiment.sample_size_notes,
adults: experiment.adults,
age_mean: experiment.age_mean,
age_sd: experiment.age_sd,
female_perc: experiment.female_perc,
male_perc: experiment.male_perc,
gender_other: experiment.gender_other,
// white_perc: experiment.white_perc,
// black_perc: experiment.black_perc,
// hispanic_perc: experiment.hispanic_perc,
// asian_perc: experiment.asian_perc,
// other_ethnicity_perc: experiment.other_ethnicity_perc,
language: experiment.language,
language_secondary: experiment.language_secondary,
compensation: experiment.compensation,
demographics_conditions: experiment.demographics_conditions,
population_other: experiment.population_other,
conditions: `${experiment.conditions.length} condition`,
behaviors: `${experiment.conditions.reduce(
(acc, condition) => acc + condition.condition_behaviors.length,
Expand All @@ -163,13 +294,13 @@ export const flattenExperiment = (
const headersGroup = expandedBehavior
? [
{ name: 'Paper', span: 2 },
{ name: 'Experiments', span: 2 },
{ name: 'Experiments', span: experimentHeaders.length },
{ name: 'Conditions', span: 1 },
{ name: 'Behaviors', span: 4 },
]
: [
{ name: 'Paper', span: 2 },
{ name: 'Experiments', span: 2 },
{ name: 'Experiments', span: experimentHeaders.length },
{ name: 'Conditions', span: 1 },
{ name: 'Behaviors', span: 1 },
]
Expand Down
24 changes: 22 additions & 2 deletions client/src/components/View/TableView/hooks/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,29 @@ export const check_data: Result = {
condition_type: 'control',
},
],
experiment_description:
'This study investigates the properties and distribution of common sense knowledge among individuals and groups. It defines commonsensicality for individual claims and people, and quantifies common sense as a clique detection problem on a bipartite belief graph of people and claims.',
experiment_name: 'Quantifying Commonsensicality',
experiment_description:
"This study aimed to define and quantify common sense both at the individual and collective levels. It employed a bipartite graph model to evaluate how 'commonsensical' certain claims were perceived by a sample of human participants.",
participant_source: 'Amazon Mechanical Turk (mTurk)',
participant_source_category: 'online panel',
units_randomized: 'individuals',
units_analyzed: 'individuals',
sample_size_randomized: 2046,
sample_size_analyzed: 2046,
sample_size_notes:
'Each participant rated 50 randomly chosen claims from a corpus of 4,407 claims.',
adults: 'adults',
age_mean: '--',
age_sd: '--',
female_perc: '--',
male_perc: '--',
gender_other: '--',
language: 'English',
language_secondary: 'NA',
compensation: 'monetary payment based on standard mTurk rates',
demographics_conditions: 'N',
population_other:
'Participants were chosen to ensure diversity across several demographic attributes such as age, race, gender, education, income, marital status, and political leaning.',
},
],
}
87 changes: 86 additions & 1 deletion server/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,90 @@ def build_feature_functions(
"type": "string",
"description": "Description of the experiment.",
},
"participant_source": {
"type": "string",
"description": "Where do participants come from? mTurk, Prolific, students, retail workers, etc. Try to use just a few words to describe this. If it is an online panel, please write the name of the source: mTurk, Prolific, etc.",
},
"participant_source_category": {
"type": "string",
"description": "Where do participants come from? Pick one from this list.",
"enum": [
"online panel",
"university students",
"high school or younger students",
"executive students",
"customers",
"employees",
"public or community",
"other",
],
},
"units_randomized": {
"type": "string",
"description": "What was randomized in the experiment? This might be individuals, teams, groups, schools, etc.",
},
"units_analyzed": {
"type": "string",
"description": "What was analyzed in the experiment? This may be the same as what was randomized (often, individual participants) but it may be a lower-level unit. For instance, restaurants may be the unit of randomization but orders placed might be the unit of analysis. Or schools may be the unit of randomization but students might be the unit of analysis.",
},
"sample_size_randomized": {
"type": "number",
"description": "What is the total sample size, at the unit of what was randomized?",
},
"sample_size_analyzed": {
"type": "number",
"description": "What is the total sample size, at the unit of what was analyzed? This should be after any exclusions, if any are mentioned. If the unit of randomization = the unit of analysis, this will often be the same number as above. If exclusions were made before analysis, this may be smaller.",
},
"sample_size_notes": {
"type": "string",
"description": "If anything was confusing or complicated about the sample size, please explain here. Otherwise, write 'NA'.",
},
"adults": {
"type": "string",
"description": "Is the target population adults (18 years old or older), children (<18 years old), or both?",
"enum": ["adults", "children", "both"],
},
"age_mean": {
"type": "number",
"description": "What is the average age of participants? If not mentioned, leave '--'.",
},
"age_sd": {
"type": "number",
"description": "What is the standard deviation of the age of participants? If not mentioned, leave '--'.",
},
"female_perc": {
"type": "number",
"description": "What is the percentage of participants identified as female? give a number between 0 and 1, If not mentioned, leave '--'.",
},
"male_perc": {
"type": "number",
"description": "What is the percentage of participants identified as male? give a number between 0 and 1, If not mentioned, leave '--'.",
},
"gender_other": {
"type": "number",
"description": "What is the percentage of participants identified as neither female nor male? give a number between 0 and 1, If not mentioned, leave '--'.",
},
"language": {
"type": "string",
"description": "What is the primary language used to communicate with the participants in the study, in particular in the stimuli or interventions? If unclear, please explain. (Note if there is any communication as part of the intervention, there should be a primary language listed.)",
},
"language_secondary": {
"type": "string",
"description": "What is the secondary language used to communicate with the participants in the study? If none, write NA.",
},
"compensation": {
"type": "string",
"description": "Were the participants compensated at all? Often, online participants are paid for their time. Sometimes bonuses or lotteries are used as well. If they were compensated, please describe the compensation.",
},
"demographics_conditions": {
"type": "string",
"description": "Does the study provide enough information to capture the age, gender, and/or ethnicity of participants by condition? (This is in contrast to overall, which is captured above.) For example, it might have a table of these demographic features by condition. Note this is not just about the paper providing inferential statistics to show balance across conditions; it is about showing proportions or means and standard deviations by condition.",
"enum": ["Y", "N"],
},
"population_other": {
"type": "string",
"description": "Anything else to mention about the participant population? Include any key attributes that are measured but not listed above, especially any that the researchers seem to indicate are important to describe the population.",
},
"conditions": {},
},
},
Expand Down Expand Up @@ -323,4 +407,5 @@ def call_asssistant_api(file_path: str, sid: str, sio):


if __name__ == "__main__":
build_feature_functions(get_all_features())
s = build_feature_functions(get_all_features())
print(json.dumps(s))