Skip to content

Commit

Permalink
Added the concept of self
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Garside committed Feb 4, 2014
1 parent 987e636 commit 6cefc8e
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 46 deletions.
50 changes: 46 additions & 4 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,11 @@ rocks owned by Pigpen = x

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

## Correct response
11 rocks
3 rocks

***

Expand Down Expand Up @@ -1472,3 +1471,46 @@ books owned by Sidd = 8

## Correct response
13 books

***

# Zoidberg Solution

## The problem
You have 7 balloons and your friend has 5 balloons.
How many more balloons do you have than your friend?

## Digested problem
You have 7 balloons and your friend has 5 balloons .
PRP VBP CD NNS CC PRP$ NN VBZ CD NNS .

How many more balloons do you have than your friend ?
WRB JJ RBR NNS VBP PRP VB IN PRP$ NN .

## Problem inference
I think this problem is about me and my friend grouping balloons and asks a single question.

## Parsed problem
I have 7 balloons and my friend has 5 balloons .
context operator constant unit coordinating_conjunction context operator constant unit punctuation

How many more balloons do I have than my friend ?
asking rel_more unit q_start context q_stop conjunction comparator_context punctuation


## Question 1

### Question text
How many more balloons do you have than your friend?

### Answer interpretation
The answer is the increase in value of balloons owned by me with respect to my friend.

## Data extraction

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

## Correct response
2 balloons
2 changes: 2 additions & 0 deletions calibrations/28.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
You have 7 balloons and your friend has 5 balloons.
How many more balloons do you have than your friend?
2 changes: 1 addition & 1 deletion example.brain.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"connotation_tags": {"how old": "age"}, "comparison_adj": {"more": "gt"}, "operator_verbs": {"give": "ex", "is": "eq", "have": "eq", "gave": "ex", "need": "re", "collects": "ad", "bake": "co", "needs": "re", "takes": "su", "had": "eq", "buys": "ad", "has": "eq", "gives": "ex", "buy": "ad", "join": "ad", "ate": "su", "kept": "su", "tree": null, "were": "False", "bought": "ad", "throws": "su", "left": null}, "inclusive": {"her family": "inclusive", "family": "inclusive", "his friends": "exclusive", "Mrs. Jones' family": "inclusive", "Pigpen's friends": "exclusive", "friends": "exclusive", "her friends": "exclusive", "Mrs. Jones' friends": "exclusive"}, "numbers": {"4": "4", "dozen": "12"}, "gender": {"skeleton": "neutral", "Jim": "masculine", "years": "neutral", "Lupis": "ambiguous", "bananas": "neutral", "Dad": "masculine", "jars": "neutral", "balloons": "neutral", "dolls": "neutral", "them": "mixed", "Pigpen": "masculine", "Michael": "masculine", "Mrs.": "feminine", "they": "mixed", "him": "masculine", "Sam": "ambiguous", "Spooky": "ambiguous", "rocks": "neutral", "Troy": "masculine", "she": "feminine", "Paul": "masculine", "Mitch": "masculine", "Marc": "masculine", "fish": "mixed", "feathers": "neutral", "books": "neutral", "ornaments": "neutral", "Jane": "feminine", "Alex": "masculine", "skulls": "neutral", "Hellen": "feminine", "Lee": "masculine", "cobs": "neutral", "William": "masculine", "Charlie": "masculine", "christmas": "neutral", "cars": "neutral", "corn": "neutral", "Meathead": "masculine", "Mickey": "masculine", "sister": "feminine", "newspapers": "neutral", "Ethelle": "feminine", "Eric": "masculine", "family": "mixed", "doughnuts": "neutral", "Tom": "masculine", "cups": "neutral", "toy": "neutral", "her": "feminine", "friends": "mixed", "friend": "ambiguous", "himself": "masculine", "marbles": "neutral", "boys": "masculine", "Skellington": "ambiguous", "he": "masculine", "Bennett": "masculine", "tree": "neutral", "apples": "neutral", "Tony": "masculine", "Richard": "masculine", "Sara": "feminine", "pieces": "neutral", "Mr.": "masculine", "his": "masculine", "muffins": "neutral", "pond": "neutral", "Chandler": "masculine", "pink": "neutral", "bags": "neutral", "bottles": "neutral", "Ragdoll": "feminine", "Mac": "masculine", "Jack": "masculine", "pizza": "neutral", "Jones": "ambiguous", "blocks": "neutral", "eggs": "neutral", "Lucy": "feminine", "Lisa": "feminine", "Sidd": "masculine", "Joey": "masculine", "Archie": "masculine", "Julia": "feminine", "mother": "feminine"}, "variables": {"all": "dynamic_variable", "some": "dynamic_variable", "half": "0.5"}, "retagged": {"fish": "noun", "are": "pre_ind_plu", "collects": "operator_verbs", "muffins": "noun_p", "bake": "operator_verbs", "dozen": "numbers", "mitch": "prop_noun", "away": "noise", "there": "exestential", "only": "noise", "4": "numbers", "friend": "noun", "pizza": "noun", "beginning": "subordinates", "ate": "operator_verbs", "join": "operator_verbs", "tree": "noun", "rocks": "noun_p", "apples": "noun_p", "were": "noise", "more": "comparison_adj", "left": "subordinates"}, "unknown": {"('bake', 'VB', None)": null, "('4', 'LS', None)": null, "('fish', 'JJ', None)": null, "('more', 'RBR', None)": null}, "determiners": {"a": "constant", "all": "variable", "away": "noise", "were": "noise", "some": "variable", "only": "noise", "another": "noise", "half": "variable", "the": "noise"}, "relative": {"younger": "rel_less", "fewer": "rel_less", "more": "rel_more"}, "answer_syntax": {"how old": "expression_connotation", "How many": "expression", "how many": "expression"}, "plurality": {"skeleton": "singular", "Jim": "singular", "years": "plural", "Lupis": "singular", "bananas": "plural", "Dad": "singular", "jars": "plural", "balloons": "plural", "dolls": "plural", "them": "plural", "Pigpen": "singular", "Michael": "singular", "Mrs.": "singular", "they": "plural", "him": "singular", "Sam": "singular", "Spooky": "singular", "rocks": "plural", "Troy": "singular", "she": "singular", "Paul": "singular", "Mitch": "singular", "Marc": "singular", "fish": "regular", "feathers": "plural", "books": "plural", "are": null, "ornaments": "plural", "Jane": "singular", "collects": null, "skulls": "plural", "Hellen": "singular", "Lee": "singular", "mitch": null, "cobs": "plural", "William": "singular", "Charlie": "singular", "christmas": "singular", "cars": "plural", "corn": "singular", "Meathead": "singular", "beginning": null, "Mickey": "singular", "sister": "singular", "ate": null, "newspapers": "plural", "Ethelle": "singular", "Eric": "singular", "family": "plural", "doughnuts": "plural", "Tom": "singular", "cups": "plural", "toy": "singular", "her": "singular", "Sidd": "singular", "friend": "singular", "himself": "singular", "marbles": "plural", "boys": "plural", "Skellington": "singular", "he": "singular", "join": null, "Bennett": "singular", "tree": "singular", "apples": "plural", "Tony": "singular", "Alex": "singular", "Richard": "singular", "Sara": "singular", "pieces": "singular", "Mr.": "singular", "his": "singular", "muffins": "plural", "pond": "singular", "Chandler": "singular", "dozen": null, "pink": "singular", "bags": "plural", "bottles": "plural", "Ragdoll": "singular", "Mac": "singular", "Jack": "singular", "pizza": "singular", "Jones": "singular", "blocks": "plural", "eggs": "plural", "Lucy": "singular", "Lisa": "singular", "friends": "plural", "Joey": "singular", "Archie": "singular", "Julia": "singular", "mother": "singular"}, "tag_units": {"age": ["years"]}, "subordinates": {"pond": "place_noun", "left": "time_ending", "away": "False", "there": null, "only": "False", "rocks": null, "boys": "context_grouping", "christmas tree": "place_noun", "apples": null, "altogether": "context_grouping", "muffins": null, "now": "time_ending", "beginning": "time_starting", "friend": null, "pizza": null}, "gerunds": {"remaining": "solution_zero", "swimming": "acting"}, "tag_list": ["age"], "exestential": {"there": "noise"}}
{"connotation_tags": {"how old": "age"}, "comparison_adj": {"more": "gt"}, "operator_verbs": {"give": "ex", "is": "eq", "have": "eq", "gave": "ex", "need": "re", "collects": "ad", "bake": "co", "needs": "re", "takes": "su", "had": "eq", "buys": "ad", "has": "eq", "gives": "ex", "buy": "ad", "join": "ad", "ate": "su", "kept": "su", "tree": null, "were": "False", "bought": "ad", "throws": "su", "left": null}, "inclusive": {"her family": "inclusive", "family": "inclusive", "his friends": "exclusive", "Mrs. Jones' family": "inclusive", "Pigpen's friends": "exclusive", "friends": "exclusive", "her friends": "exclusive", "Mrs. Jones' friends": "exclusive"}, "numbers": {"4": "4", "dozen": "12"}, "gender": {"skeleton": "neutral", "Jim": "masculine", "years": "neutral", "Lupis": "ambiguous", "bananas": "neutral", "Dad": "masculine", "jars": "neutral", "balloons": "neutral", "dolls": "neutral", "them": "mixed", "Pigpen": "masculine", "Michael": "masculine", "Mrs.": "feminine", "they": "mixed", "him": "masculine", "Sam": "ambiguous", "Spooky": "ambiguous", "rocks": "neutral", "Troy": "masculine", "she": "feminine", "Paul": "masculine", "Mitch": "masculine", "Marc": "masculine", "fish": "mixed", "feathers": "neutral", "books": "neutral", "ornaments": "neutral", "Jane": "feminine", "Alex": "masculine", "skulls": "neutral", "Hellen": "feminine", "Lee": "masculine", "cobs": "neutral", "William": "masculine", "Charlie": "masculine", "christmas": "neutral", "cars": "neutral", "corn": "neutral", "Meathead": "masculine", "Mickey": "masculine", "sister": "feminine", "newspapers": "neutral", "Ethelle": "feminine", "Eric": "masculine", "family": "mixed", "doughnuts": "neutral", "Tom": "masculine", "cups": "neutral", "your": "self", "toy": "neutral", "her": "feminine", "friends": "mixed", "friend": "ambiguous", "himself": "masculine", "marbles": "neutral", "boys": "masculine", "Skellington": "ambiguous", "he": "masculine", "Bennett": "masculine", "tree": "neutral", "apples": "neutral", "Tony": "masculine", "Richard": "masculine", "Sara": "feminine", "pieces": "neutral", "Mr.": "masculine", "his": "masculine", "muffins": "neutral", "pond": "neutral", "Chandler": "masculine", "pink": "neutral", "bags": "neutral", "bottles": "neutral", "Ragdoll": "feminine", "Mac": "masculine", "Jack": "masculine", "you": "self", "pizza": "neutral", "Jones": "ambiguous", "blocks": "neutral", "eggs": "neutral", "Lucy": "feminine", "Lisa": "feminine", "Sidd": "masculine", "Joey": "masculine", "Archie": "masculine", "Julia": "feminine", "mother": "feminine"}, "variables": {"all": "dynamic_variable", "some": "dynamic_variable", "half": "0.5"}, "retagged": {"fish": "noun", "are": "pre_ind_plu", "collects": "operator_verbs", "muffins": "noun_p", "bake": "operator_verbs", "dozen": "numbers", "mitch": "prop_noun", "away": "noise", "there": "exestential", "only": "noise", "4": "numbers", "friend": "noun", "pizza": "noun", "beginning": "subordinates", "ate": "operator_verbs", "join": "operator_verbs", "tree": "noun", "rocks": "noun_p", "apples": "noun_p", "were": "noise", "more": "comparison_adj", "left": "subordinates"}, "unknown": {"('bake', 'VB', None)": null, "('4', 'LS', None)": null, "('fish', 'JJ', None)": null, "('more', 'RBR', None)": null}, "determiners": {"a": "constant", "all": "variable", "away": "noise", "were": "noise", "some": "variable", "only": "noise", "another": "noise", "half": "variable", "the": "noise"}, "relative": {"younger": "rel_less", "fewer": "rel_less", "more": "rel_more"}, "answer_syntax": {"how old": "expression_connotation", "How many": "expression", "how many": "expression"}, "plurality": {"skeleton": "singular", "Jim": "singular", "years": "plural", "Lupis": "singular", "bananas": "plural", "Dad": "singular", "jars": "plural", "balloons": "plural", "dolls": "plural", "them": "plural", "Pigpen": "singular", "Michael": "singular", "Mrs.": "singular", "they": "plural", "him": "singular", "Sam": "singular", "Spooky": "singular", "rocks": "plural", "Troy": "singular", "she": "singular", "Paul": "singular", "Mitch": "singular", "Marc": "singular", "fish": "regular", "feathers": "plural", "books": "plural", "are": null, "ornaments": "plural", "Jane": "singular", "collects": null, "skulls": "plural", "Hellen": "singular", "Lee": "singular", "mitch": null, "cobs": "plural", "William": "singular", "Charlie": "singular", "christmas": "singular", "cars": "plural", "corn": "singular", "Meathead": "singular", "beginning": null, "Mickey": "singular", "sister": "singular", "ate": null, "newspapers": "plural", "Ethelle": "singular", "Eric": "singular", "family": "plural", "doughnuts": "plural", "Tom": "singular", "cups": "plural", "your": "self", "toy": "singular", "her": "singular", "Sidd": "singular", "friend": "singular", "himself": "singular", "marbles": "plural", "boys": "plural", "Skellington": "singular", "he": "singular", "join": null, "Bennett": "singular", "tree": "singular", "apples": "plural", "Tony": "singular", "Richard": "singular", "Sara": "singular", "pieces": "singular", "Mr.": "singular", "his": "singular", "muffins": "plural", "pond": "singular", "Chandler": "singular", "dozen": null, "pink": "singular", "bags": "plural", "bottles": "plural", "Ragdoll": "singular", "Mac": "singular", "Jack": "singular", "you": "self", "pizza": "singular", "Jones": "singular", "Alex": "singular", "eggs": "plural", "blocks": "plural", "Lucy": "singular", "Lisa": "singular", "friends": "plural", "Joey": "singular", "Archie": "singular", "Julia": "singular", "mother": "singular"}, "tag_units": {"age": ["years"]}, "subordinates": {"pond": "place_noun", "left": "time_ending", "away": "False", "there": null, "only": "False", "rocks": null, "boys": "context_grouping", "christmas tree": "place_noun", "apples": null, "altogether": "context_grouping", "muffins": null, "now": "time_ending", "beginning": "time_starting", "friend": null, "pizza": null}, "gerunds": {"remaining": "solution_zero", "swimming": "acting"}, "tag_list": ["age"], "exestential": {"there": "noise"}}
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=27
MAX_IDX=28

for i in $(seq 1 $MAX_IDX); do
cat calibrations/$i.txt | zoidberg | tee -a EXAMPLE.md
Expand Down
4 changes: 4 additions & 0 deletions zoidberg/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def execute(self):
self.subordinates += self.subordinate

def __str__(self):

if self.context_subtype and self.context_subtype[0] == "self":
self.context = self.query.problem.brain.self_reflexive(self.context, True)

o = []

o.append("\n### Question text")
Expand Down
34 changes: 31 additions & 3 deletions zoidberg/brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@
"variables": {},
"connotation_tags": {},
"tag_list": [],
"tag_units": {}
"tag_units": {},
}

# hardcoded taught the concept of self
SELF_REFLEXIVE = {
"you": "I",
"me": "I",
"I": "I",
"i": "I",
"your": "my"
}
INDIRECT_SELF_REFLEXIVE = {
"you": "me",
"I": "me",
"i": "me",
"your": "my",
"me": "me"
}

# Various mathematical operators we know of
Expand Down Expand Up @@ -87,15 +103,17 @@
PLURALITY = [
("singular", "Refers to a single (balloon, she)"),
("plural", "Refers to a plural (balloons, they)"),
("regular", "Refers to a regular plural (fish, sheep)")
("regular", "Refers to a regular plural (fish, sheep)"),
("self", "Refers to you, Zoidberg!")
]

GENDERS = [
("masculine", "Refers to a male gender"),
("feminine", "Refers to a female gender"),
("neutral", "Refers to a non-gendered entity"),
("mixed", "Refers to a mixture of/ambiguous genders (a group of )"),
("ambiguous", "Refers to a man or woman but is not clear enough to know")
("ambiguous", "Refers to a man or woman but is not clear enough to know"),
("self", "Refers to you, Zoidberg!")
]

RETAGS = [
Expand Down Expand Up @@ -488,3 +506,13 @@ def variable(self, n, ref):
def dump(self):
set_json(self.path, self.raw)

def self_reflexive(self, val, indirect=False):
if indirect:
x = INDIRECT_SELF_REFLEXIVE
else:
x = SELF_REFLEXIVE
if not val in x:
raise Exception("Need to handle this reflexive self: " + val)
else:
return x[val]

2 changes: 1 addition & 1 deletion zoidberg/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,6 @@ def __str__(self):
o.append("I have literally no idea what's going on here.")

o.append("\n## Parsed problem")
output_tuples(self.sentences, o, self.longest_phrase)
output_tuples(self.sentences, o, self.longest_phrase, self.problem.brain)

return "\n".join(o)
10 changes: 9 additions & 1 deletion zoidberg/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ def __init__(self, text, brain_path=None, file_name=None):
"plurality": {
"singular": None,
"plural": None,
"self": None,
"regular": None
},
"gender": {
"masculine": None,
"feminine": None,
"neutral": None,
"mixed": None,
"self": None,
"ambiguous": None
},
"last": None
Expand All @@ -50,13 +52,15 @@ def __init__(self, text, brain_path=None, file_name=None):
"plurality": {
"singular": None,
"plural": None,
"self": None,
"regular": None
},
"gender": {
"masculine": None,
"feminine": None,
"neutral": None,
"mixed": None,
"self": None,
"ambiguous": None
},
"last": None
Expand All @@ -65,13 +69,15 @@ def __init__(self, text, brain_path=None, file_name=None):
"plurality": {
"singular": {},
"plural": {},
"self": {},
"regular": {}
},
"gender": {
"masculine": {},
"feminine": {},
"neutral": {},
"mixed": {},
"self": {},
"ambiguous": {}
},
"last": None
Expand All @@ -80,9 +86,11 @@ def __init__(self, text, brain_path=None, file_name=None):
"plurality": {
"singular": {},
"plural": {},
"self": {},
"regular": {}
},
"gender": {
"self": {},
"masculine": {},
"feminine": {},
"neutral": {},
Expand Down Expand Up @@ -160,7 +168,7 @@ def __str__(self):
o.append(self.text)

o.append("## Digested problem")
output_tuples(self.sentence_tags, o, self.longest_word)
output_tuples(self.sentence_tags, o, self.longest_word, self.brain)

if self.inference is not None:
o.append(str(self.inference))
Expand Down
Loading

0 comments on commit 6cefc8e

Please sign in to comment.