-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsa2.wppl
49 lines (35 loc) · 923 Bytes
/
rsa2.wppl
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
const statePrior = function () {
uniformDraw([0, 1, 2, 3])
}
const utterancePrior = function () {
uniformDraw(["all", "some", "none"])
}
const literalMeaning = {
all: function(state) { return state >= 3 },
some: function(state) { return state <= 3 && state >= 1 },
none: function(state) { return state == 0 }
}
const literalListener = function(utt) {
Infer({model: function() {
const state = statePrior()
const meaning = literalMeaning[utt]
condition(meaning(state))
return state
}})
}
const alpha = 1.0
const pragmaticSpeaker = function(state) {
Infer({model: function(){
const utt = utterancePrior()
factor(alpha * literalListener(utt).score(state))
return utt
}})
}
const pragmaticListener = function(utt) {
Infer({model: function() {
const state = statePrior()
observe(pragmaticSpeaker(state), utt)
return state
}})
}
pragmaticListener("some")