-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
144 lines (134 loc) · 4.55 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Activation Model</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.experiment-container {
margin-bottom: 40px;
}
.chart-container {
position: relative;
height: 400px;
width: 100%;
margin: 20px 0;
}
.controls {
margin: 20px 0;
}
button {
padding: 10px 20px;
margin: 5px;
cursor: pointer;
}
select {
padding: 5px;
margin: 5px;
}
</style>
</head>
<body>
<h1>Interactive Activation Model Experiments</h1>
<div class="controls">
<select id="experimentSelect">
<option value="readVsE">Single Letter (E) vs Word (READ)</option>
<option value="maveVsE">Single Letter (E) vs Pseudoword (MAVE)</option>
<option value="richGetRicher">Rich Get Richer Effect</option>
<option value="gangEffect">Gang Effect</option>
</select>
<button onclick="runSelectedExperiment()">Run Experiment</button>
</div>
<div class="experiment-container">
<div class="chart-container">
<canvas id="activationChart"></canvas>
</div>
<div id="experimentDescription"></div>
</div>
<script src="iam.js"></script>
<script>
let chart = null;
function createChart(data, labels, title) {
if (chart) {
chart.destroy();
}
const ctx = document.getElementById('activationChart').getContext('2d');
chart = new Chart(ctx, {
type: 'line',
data: {
labels: Array.from({length: data[0].length}, (_, i) => i),
datasets: labels.map((label, i) => ({
label: label,
data: data[i],
borderColor: getColor(i),
fill: false,
tension: 0.1
}))
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: title
}
},
scales: {
y: {
title: {
display: true,
text: 'Activation'
}
},
x: {
title: {
display: true,
text: 'Time Steps'
}
}
}
}
});
}
function getColor(index) {
const colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728'];
return colors[index % colors.length];
}
function runSelectedExperiment() {
const experimentType = document.getElementById('experimentSelect').value;
const model = new InteractiveActivationModel();
let data, labels, title;
switch(experimentType) {
case 'readVsE':
({data, labels} = model.runReadVsE());
title = 'Letter Recognition: E in READ vs E Alone';
break;
case 'maveVsE':
({data, labels} = model.runMaveVsE());
title = 'Letter Recognition: E in MAVE vs E Alone';
break;
case 'richGetRicher':
({data, labels} = model.runRichGetRicher());
title = 'Rich Get Richer Effect with MAVE';
break;
case 'gangEffect':
({data, labels} = model.runGangEffect());
title = 'Gang Effect with MAVE';
break;
}
createChart(data, labels, title);
}
// Run initial experiment on page load
document.addEventListener('DOMContentLoaded', () => {
runSelectedExperiment();
});
</script>
</body>
</html>