Skip to content

Commit

Permalink
41 working calibrations; wow
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Garside committed Feb 5, 2014
1 parent 779ba89 commit 094dc7e
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 26 deletions.
65 changes: 61 additions & 4 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ bananas owned by Mrs. Jones + x
bananas owned by Mrs. Jones - 5

### Sentence 3
bananas owned by Mrs. Jones - 4
bananas owned by Mrs. Jones == 0
bananas owned by Mrs. Jones' friends + 4

## Correct response
Expand Down Expand Up @@ -151,6 +153,7 @@ The answer is the unknown value of jars owned by Tony at the end of the problem.
jars owned by Tony = 19

### Sentence 2
jars owned by Tony - 16
jars owned by Tony's sister + 16

## Correct response
Expand Down Expand Up @@ -323,9 +326,11 @@ apples owned by Marc = 10
apples owned by Marc - 2

### Sentence 3
apples owned by Jim + 2
apples owned by Marc - 2

### Sentence 4
apples owned by Julia + 3
apples owned by Marc - 3

## Correct response
Expand Down Expand Up @@ -479,6 +484,7 @@ The answer is the unknown value of rocks owned by Pigpen at the beginning of the
rocks owned by Pigpen = x

### Sentence 2
rocks owned by Pigpen - 3
rocks owned by Pigpen's friends - 8
rocks owned by Pigpen's friends == 0

Expand Down Expand Up @@ -634,6 +640,7 @@ The answer is the unknown value of apples owned by Mickey at the end of the prob
apples owned by Mickey = 12

### Sentence 2
apples owned by Mickey - Eric apples
apples owned by Eric = Mickey apples * 0.5

## Correct response
Expand Down Expand Up @@ -733,6 +740,7 @@ The answer is the unknown value of pieces of chocolate owned by Sara at the end
pieces of chocolate owned by Sara = 8

### Sentence 2
pieces of chocolate owned by Sara's mother - 4
pieces of chocolate owned by Sara + 4

## Correct response
Expand Down Expand Up @@ -793,6 +801,8 @@ doughnuts owned by Bennett + 4

***

'bool' object has no attribute 'is_Relational'
'bool' object has no attribute 'is_Relational'
# Zoidberg Solution

## The problem
Expand Down Expand Up @@ -830,19 +840,18 @@ I think this problem is about Charlie and Mac bottles and asks a single question
How many bottles did Charlie have in the beginning?

### Answer interpretation
The answer is the unknown value of bottles owned by Charlie at the beginning of the problem.
The answer is the unknown value of bottles owned by Charlie at the beginning of the problem at the end of the problem.

## Data extraction

### Sentence 1
bottles owned by Charlie - 4
bottles owned by Mac + 4

### Sentence 2
bottles owned by Charlie = 8
bottles owned by Charlie == 8

## Correct response
12 bottles

***

# Zoidberg Solution
Expand Down Expand Up @@ -1028,9 +1037,11 @@ The answer is the increase in value of feathers owned by Richard with respect to
## Data extraction

### Sentence 1
feathers owned by Dad - 7
feathers owned by Richard + 7

### Sentence 2
feathers owned by William + 4
feathers owned by Dad - 4

## Correct response
Expand Down Expand Up @@ -1193,6 +1204,7 @@ The answer is the unknown value of books owned by Paul at the end of the problem
books owned by Paul = 10

### Sentence 2
books owned by Paul - 7
books owned by Paul's sister + 7

## Correct response
Expand Down Expand Up @@ -1402,6 +1414,7 @@ The answer is the unknown value of bags owned by Tom at the end of the problem.
bags owned by Tom = 5

### Sentence 2
bags owned by Tom's sister + 4
bags owned by Tom - 4

## Correct response
Expand Down Expand Up @@ -1496,6 +1509,7 @@ The answer is the increase in value of balloons owned by me with respect to my f
## Data extraction

### Sentence 1
balloons owned by me = 7
balloons owned by my friend = 5

## Correct response
Expand Down Expand Up @@ -2082,3 +2096,46 @@ sitting toucans on a tree limb + 1

## Correct response
3 toucans

***

# Zoidberg Solution

## The problem
There are 4 squirrels in a tree with 2 nuts.
How many more squirrels are there than nuts?

## Digested problem
There are 4 squirrels in a tree with 2 nuts .
EX VBP CD NNS IN DT NN IN CD NNS .

How many more squirrels are there than nuts ?
WRB JJ RBR NNS VBP RB IN NNS .

## Problem inference
I think this problem is about squirrels and nuts in a tree and than nuts and asks a single question.

## Parsed problem
There are 4 squirrels in 1 tree with 2 nuts .
exestential pre_ind_plu constant unit conjunction constant subordinate conjunction constant unit punctuation

How many more squirrels are there than nuts ? tree
asking rel_more unit pre_ind_plu exestential conjunction subordinate punctuation subordinate_inferred


## Question 1

### Question text
How many more squirrels are there than nuts?

### Answer interpretation
The answer is the increase in value of squirrels in a tree.

## Data extraction

### Sentence 1
nuts in a tree = 2
squirrels in a tree = 4

## Correct response
2 squirrels
2 changes: 2 additions & 0 deletions calibrations/41.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
There are 4 squirrels in a tree with 2 nuts.
How many more squirrels are there than nuts?
2 changes: 1 addition & 1 deletion example.brain.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion run_example.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
clear
echo "" > EXAMPLE.md
MIN_ID=1
MAX_IDX=40
MAX_IDX=41

for i in $(seq $MIN_ID $MAX_IDX); do
cat calibrations/$i.txt | zoidberg | tee -a EXAMPLE.md
Expand Down
2 changes: 2 additions & 0 deletions zoidberg/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ def execute(self):
if stype in ["place_noun", "time_ending", "time_starting"]:
specifying = True

#rint specifying
if specifying:
subs = self.query.subordinates
self.subordinate = [s for s in subs if s[0] == val[0]]
#rint subs, stype, val[0]
if len(self.subordinate) > 0:
self.subordinates += self.subordinate

Expand Down
31 changes: 17 additions & 14 deletions zoidberg/sentence_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,19 +412,21 @@ def do_track(subtype, tag):
self.units.pop()
self.used_unit_adjectives.append(self.last_word)
self.parsed.pop()
#elif self.problem.involves_acting:
# unit, uidx = self.fix_unit(unit)
# self.last_unit = unit
# self.last_unit_tag = tag
# self.last_unit_index = len(self.parsed)
# self.units.append(unit)
# self.unit_idx[unit] = self.last_unit_index
# if self.new_units_as_context:
# p.units_acting_as_context[unit] = True
# self.track(unit, "unit", self.subtype, uidx)
# do_unset_conj = False
# do_reg_unit = False
# do_std = False
ptest = self.parsed.pop()
self.parsed.append(ptest)
if ptest[1] == "constant" and self.last_tag != "DT" and self.problem.exestential:
unit, uidx = self.fix_unit(unit)
self.last_unit = unit
self.last_unit_tag = tag
self.last_unit_index = len(self.parsed)
self.units.append(unit)
self.unit_idx[unit] = self.last_unit_index
if self.new_units_as_context:
p.units_acting_as_context[unit] = True
self.track(unit, "unit", self.subtype, uidx)
do_unset_conj = False
do_reg_unit = False
do_std = False

if do_std:
if word in self.used_unit_adjectives:
Expand Down Expand Up @@ -987,7 +989,8 @@ def do_track(subtype, tag):
continue
self.subordinate_subtypes[subord] = sub_subs[subord]
self.subordinate_lookup[subord] = sub_look[subord]
#self.subordinates.append(sub)
if subt != "refiner":
self.subordinates.append(sub)
self.track(sub, "subordinate_inferred", self.subordinate_subtypes[subord])

if self.main_context in self.problem.context_actions and len(self.actions) == 0:
Expand Down
39 changes: 33 additions & 6 deletions zoidberg/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ def generate_expression(self, zeroes_out=False, answer_out=False):
if operator == "ex":
operator = "su"

if not answer_out:
data.append((operator, constant, context_var))
#if not answer_out:
data.append((operator, constant, context_var))

if zeroes_out:
data.append(("ans", "0", None))
Expand All @@ -509,6 +509,9 @@ def generate_expression(self, zeroes_out=False, answer_out=False):
self.containers[container][k1][context_constant] = {}

self.containers[container][k1][context_constant][k2] = data
#rint "==="
#rint "WAT", container, k1, context_constant, k2, data
#rint self.containers
self.digest_unit_groups(container, k1, context_constant, k2)

if self.coordinated:
Expand Down Expand Up @@ -595,8 +598,10 @@ def execute(self):
did_set_context = False
last_context = None
last_context_subtype = None
open_conjunction = False
last_target = None
last_target_subtype = None
pending_constant = None
last_container = None
zeroes_out = False
answer_out = False
Expand Down Expand Up @@ -637,13 +642,27 @@ def execute(self):
if self.operator == "ex":
self.can_target = True

if part == "constant" and not self.constant:
self.constant = val
if part == "constant":
if not self.constant:
self.constant = val
elif open_conjunction:
pending_constant = val

if part == "variable_relationship":
self.variable_relationship = val

if part == "unit":
if open_conjunction and pending_constant:
if self.has_any():
self.coordinated_container = self.generate_expression(zeroes_out, answer_out)
self.constant = pending_constant
pending_constant = None

self.coordinated = True
self.context = last_context
self.context_subtype = last_context_subtype
self.container = last_container
did_set_context = False
self.unit = val

if part == "context_unit":
Expand Down Expand Up @@ -684,6 +703,8 @@ def execute(self):
self.action = val

if part in ["subordinate", "subordinate_inferred"]:
open_conjunction = False
pending_constant = None
if val[1] is not None:
if val[0] not in parser.subordinate_lookup:
continue
Expand All @@ -696,6 +717,9 @@ def execute(self):
self.container = val[0]
last_container = self.container

if part == "conjunction":
open_conjunction = True

if part == "coordinating_conjunction":
if self.has_any():
self.coordinated_container = self.generate_expression(zeroes_out, answer_out)
Expand Down Expand Up @@ -753,10 +777,10 @@ def compute(self):
# rint sd
# rint self.symbols
# rint "--"
new_constant_wrapper = {}
#rint data
new_data = {}
for context in data:
new_data = {}
new_constant_wrapper = {}
for context_constant in data[context]:
units = data[context][context_constant]

Expand Down Expand Up @@ -806,11 +830,13 @@ def compute(self):
else:
con = constant
# rint "HERE THEN?", con, constant
#rint "DIS", new_values, unit, context_constant, context, container
new_values.append((operator, con, dc))
new_units[unit] = new_values
new_constant_wrapper[context_constant] = new_units
last_context = context
new_data[context] = new_constant_wrapper
#rint context, new_constant_wrapper, container
new_container[container] = new_data
index += 1
new_sentence_data.append(new_container)
Expand Down Expand Up @@ -950,6 +976,7 @@ def simple_solve(sym, context_constant, rel_var=None):
pass
# This should get handled in the formal logic elsewhere
elif sub == "place_noun" or sub is None:
#rint "here?"
compContext = word
dispUnit = answer.unit
if answer.actor:
Expand Down

0 comments on commit 094dc7e

Please sign in to comment.