Skip to content

Commit

Permalink
13th calibration working
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Garside committed Jan 29, 2014
1 parent f0745d2 commit ae1e093
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 51 deletions.
87 changes: 74 additions & 13 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ The answer is the difference in value of toy cars owned by Chandler with respect

### Sentence 1
toy cars owned by Joey = 13
toy cars owned by Joey + 13

### Sentence 2
toy cars owned by Chandler = 6
toy cars owned by Chandler + 6

## Correct response
7 fewer toy cars
14 toy cars fewer

***

Expand Down Expand Up @@ -332,6 +334,7 @@ apples owned by Marc - 3

***

False 8 None @fish swimming pond
# Zoidberg Solution

## The problem
Expand All @@ -349,17 +352,17 @@ How many fish are swimming in the pond now?
WRB JJ JJ VBP VBG IN DT NN RB .

## Problem inference
I think this problem is about an increasing number of swimming fish and asks a single question.
I think this problem is about an increasing number of swimming fish in a pond and asks a single question.

## Parsed problem
8 fish are swimming in a .
constant context pre_ind_plu acting conjunction constant punctuation
8 fish are swimming in a pond .
constant context pre_ind_plu acting conjunction constant subordinate punctuation

4 more fish join fish .
constant rel_more context operator context punctuation

How many fish are swimming in the now ?
asking context pre_ind_plu acting conjunction noise subordinate punctuation
How many fish are swimming in the pond now ?
asking context pre_ind_plu acting conjunction noise subordinate subordinate punctuation


## Question 1
Expand All @@ -368,18 +371,18 @@ I think this problem is about an increasing number of swimming fish and asks a s
How many fish are swimming in the pond now?

### Answer interpretation
The answer is the unknown value of fish swimming at the end of the problem.
The answer is the unknown value of fish swimming in a pond at the end of the problem.

## Data extraction

### Sentence 1
swimming fish = 8
swimming fish in a pond = 8

### Sentence 2
swimming fish + 4

## Correct response
12 fish
8 fish

***

Expand All @@ -399,7 +402,7 @@ Michael had 8 pieces of pizza. He ate 2 pieces of pizza. How many pieces of pizz
WRB JJ NNS IN NN VBD NNP VB VBN .

## Problem inference
I think this problem is about Michael losing pieces of pizza and asks a single question.
I think this problem is about Michael losing pieces of pizza, pieces pizza, and of pizza and asks a single question.

## Parsed problem
Michael had 8 pieces of pizza .
Expand All @@ -424,9 +427,13 @@ The answer is the unknown value of pieces of pizza owned by Michael at the end o

### Sentence 1
pieces of pizza owned by Michael = 8
of pizza owned by Michael = 8
pieces pizza owned by Michael = 8

### Sentence 2
pieces of pizza owned by Michael - 2
of pizza owned by Michael - 2
pieces pizza owned by Michael - 2

## Correct response
6 pieces of pizza
Expand Down Expand Up @@ -479,13 +486,15 @@ rocks owned by Pigpen = x

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

## Correct response
3 rocks
11 rocks

***

False 4 None Mr. Lupis eggs muffins
# Zoidberg Solution

## The problem
Expand Down Expand Up @@ -532,7 +541,7 @@ eggs needed by Mr. Lupis to bake muffins == 4
eggs owned by Mr. Lupis = 2

## Correct response
2 more eggs
2 eggs more

***

Expand All @@ -554,7 +563,7 @@ How many cobs of corn do they have altogether?
WRB JJ NNS IN NN VBP PRP VBP RB .

## Problem inference
I think this problem is about Mitch and Lisa grouping cobs of corn and asks a single question.
I think this problem is about Mitch and Lisa grouping cobs of corn, cobs corn, and of corn and asks a single question.

## Parsed problem
Mitch has 3 cobs of corn .
Expand All @@ -579,9 +588,13 @@ The answer is the unknown value of cobs of corn owned by Mitch and Lisa added to

### Sentence 1
cobs of corn owned by Mitch = 3
cobs corn owned by Mitch = 3
of corn owned by Mitch = 3

### Sentence 2
cobs of corn owned by Lisa = 2
cobs corn owned by Lisa = 2
of corn owned by Lisa = 2

## Correct response
5 cobs of corn
Expand Down Expand Up @@ -638,3 +651,51 @@ apples owned by Eric = Mickey apples * 0.5

## Correct response
6 apples

***

False 14 None _unknown_ christmas ornaments christmas tree
# Zoidberg Solution

## The problem
There are 6 pink christmas ornaments and 8 blue christmas ornaments on the christmas tree.
How many christmas ornaments are on the christmas tree altogether?

## Digested problem
There are 6 pink christmas ornaments and 8 blue christmas ornaments on the christmas tree .
EX VBP CD NN NNS NNS CC CD JJ NNS NNS IN DT NNS VBP .

How many christmas ornaments are on the christmas tree altogether ?
WRB JJ NNS NNS VBP IN DT NNS VBP RB .

## Problem inference
I think this problem is about christmas ornaments pink christmas ornaments, blue christmas ornaments, pink ornaments, christmas ornaments, and blue ornaments on the christmas tree and asks a single question.

## Parsed problem
There are 6 pink christmas ornaments and 8 blue christmas ornaments on the christmas tree .
exestential pre_ind_plu constant unit coordinating_conjunction constant unit conjunction noise subordinate punctuation

How many christmas ornaments are on the christmas tree altogether ?
asking context pre_ind_plu conjunction noise subordinate subordinate punctuation


## Question 1

### Question text
How many christmas ornaments are on the christmas tree altogether?

### Answer interpretation
The answer is the unknown value of christmas ornaments on the christmas tree added together.

## Data extraction

### Sentence 1
christmas ornaments on the christmas tree = 8
christmas ornaments on the christmas tree + 6
blue ornaments on the christmas tree = 8
blue christmas ornaments on the christmas tree = 8
pink ornaments on the christmas tree = 6
pink christmas ornaments on the christmas tree = 6

## Correct response
14 christmas ornaments
2 changes: 1 addition & 1 deletion calibrations/13.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
There are 6 pink christmas ornaments and 8 blue christmas ornaments on the christmas tree.
How many christmas ornaments are there altogether?
How many christmas ornaments are on the christmas tree altogether?
2 changes: 1 addition & 1 deletion run_example.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
clear
echo "" > EXAMPLE.md
MAX_IDX=12
MAX_IDX=13

for i in $(seq 1 $MAX_IDX); do
cat calibrations/$i.txt | zoidberg | tee -a EXAMPLE.md
Expand Down
21 changes: 15 additions & 6 deletions zoidberg/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,17 @@ def execute(self):
self.last_unrefined_context_subtype = subtype

# Assume subordinate during specifying is answer condition
if part == "subordinate" and specifying:
subs = self.query.subordinates
self.subordinate = [s for s in subs if s[0] == val[0]]
if len(self.subordinate) > 0:
self.subordinates += self.subordinate
if part == "subordinate":
# If we have an actor but are not specifying in an exestential
# problem, then we can simply assume that specification is occurring
if not specifying and self.actor is not None and self.query.problem.exestential:
specifying = True

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

def __str__(self):
o = []
Expand Down Expand Up @@ -171,7 +177,10 @@ def __str__(self):
i.append("the {0} {1} of".format(mode, syntax))

if self.actor:
i.append("{0} {1}".format(self.actor, self.action))
if self.action is not None:
i.append("{0} {1}".format(self.actor, self.action))
else:
i.append(self.actor)

if self.value:
if self.relative_value:
Expand Down
13 changes: 12 additions & 1 deletion zoidberg/brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DEFAULT_BRAIN = {
"operator_verbs": {},
"subordinates": {},
"exestential": {},
"comparison_adj": {},
"answer_syntax": {},
"plurality": {},
Expand Down Expand Up @@ -94,6 +95,7 @@

RETAGS = [
("noise", "This is not relevant to the question and can be ignored"),
("exestential", "This is an exestential statement (there are, are there)"),
("operator_verbs", "This indicates a mathematical operation"),
("subordinates", "This indicates a point in time"),
("comparison_adj", "This indicates a comparison between things"),
Expand Down Expand Up @@ -163,6 +165,8 @@ def retag():
brain.number(x, ref)
elif item == "variable":
brain.variable(x, ref)
elif item == "exestential":
brain.add("exestential", x, "noise")
elif item == "noise":
brain.add("determiners", x, "noise")
# A false in the indicator means it's noise and can be ignored
Expand Down Expand Up @@ -339,6 +343,8 @@ def retag(self, val, tag):
tag = "WP$"
elif item == "noise":
tag = "DT"
elif item == "exestential":
tag = "EX"
elif item == "numbers":
tag = "CD"
val = str(self.raw["numbers"][val])
Expand All @@ -361,7 +367,12 @@ def subordinate(self, p, ref):
sub, tag = p
subtype = self.proc("subordinates", sub, input_subordinate_type, ref)
if subtype == "place_noun":
self.noun_like(sub, tag, ref)
# Sometimes composite nouns get passed in as subordinates. If we're
# working with a composite noun (something with a space "red car")
# we simply don't want to ask what it's about, because each of the
# constituent pieces should be already known
if " " not in sub:
self.noun_like(sub, tag, ref)
return subtype

def operator(self, verb, ref):
Expand Down
1 change: 1 addition & 0 deletions zoidberg/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, text, brain_path=None):
self.longest_word = None
self.units_acting_as_context = {}

self.exestential = False
self.adaptive_context = {}
self.last_contexts = {
"plurality": {
Expand Down
Loading

0 comments on commit ae1e093

Please sign in to comment.