Skip to content

Commit 7cd9089

Browse files
committed
thesis version
1 parent 40eddf6 commit 7cd9089

2 files changed

Lines changed: 29 additions & 12 deletions

File tree

agents/WhereWhenHowNoFoa.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# from pprint import pprint
1+
from pprint import pprint
22
from random import random
33
from random import choice
44

@@ -31,13 +31,15 @@ def __init__(self, action_set):
3131
self.where = MostSpecific
3232
# self.when = 'naive bayes'
3333
# self.when = 'always true'
34-
# self.when = 'trestle'
35-
self.when = 'decision tree'
34+
self.when = 'trestle'
35+
# self.when = 'cobweb'
36+
# self.when = 'decision tree'
3637
self.skills = {}
3738
self.examples = {}
3839
self.action_set = action_set
3940

4041
def request(self, state):
42+
# print(state)
4143
# print("REQUEST RECEIVED")
4244
tup = Tuplizer()
4345
flt = Flattener()
@@ -85,7 +87,7 @@ def request(self, state):
8587
skillset.sort(reverse=True)
8688

8789
# print('####SKILLSET####')
88-
# pprint(skillset)
90+
pprint(skillset)
8991
# print('####SKILLSET####')
9092

9193
# used for grounding out plans, don't need to build up each time.
@@ -285,6 +287,11 @@ def compute_exp_depth(self, exp):
285287
return 0
286288

287289
def train(self, state, label, foas, selection, action, inputs, correct):
290+
print('label', label)
291+
print('selection', selection)
292+
print('action', action)
293+
print('input', inputs)
294+
print('correct', correct)
288295

289296
# label = 'math'
290297

@@ -524,8 +531,8 @@ def train(self, state, label, foas, selection, action, inputs, correct):
524531
# print("SAI")
525532
# print(r_exp[0])
526533

527-
# print("CONSTRAINTS")
528-
# print(constraints)
534+
print("CONSTRAINTS")
535+
print(constraints)
529536

530537
w_args = tuple(['?foa%s' % j for j, _ in enumerate(args)])
531538

@@ -587,7 +594,9 @@ def generate_tutor_constraints(self, sai):
587594
constraints.add(('name', selection, 'done'))
588595
else:
589596
# constraints.add(('not', ('type', selection, 'MAIN::button')))
590-
constraints.add(('type', selection, 'MAIN::cell'))
597+
constraints.add(('not', ('type', selection, 'MAIN::button')))
598+
constraints.add(('not', ('type', selection, 'MAIN::label')))
599+
# constraints.add(('type', selection, 'MAIN::cell'))
591600

592601
# value constraints, don't select empty values
593602
for i, a in enumerate(args[1:]):

planners/fo_planner.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,20 @@ def match(self, index, epsilon=0.0, initial_mapping=None):
871871

872872
if __name__ == "__main__":
873873

874-
facts = [(('value', 'test1'), 'this is a test sentence'),
875-
(('value', 'test2'), 'BOOM')]
874+
import sys
875+
sys.path.insert(0, './')
876+
877+
from planners.rulesets import arith_rules
878+
879+
facts = [(('value', 'ul'), '6'),
880+
(('value', 'ur'), '8'),
881+
(('value', 'll'), '-3')]
876882
# kb = FoPlanner(facts, [unigramize, bigramize])
877-
kb = FoPlanner(facts, [])
878-
kb.fc_infer()
879-
print(kb.facts)
883+
kb = FoPlanner(facts, arith_rules)
884+
# kb.fc_infer()
885+
for m in kb.fc_query([(('value', '?x'), '9')], max_depth=1):
886+
print(m)
887+
# print(kb.facts)
880888

881889
# criminal_rule = Operator(('Criminal', '?x'), [('Criminal', '?x')], [],
882890
# [('American', '?x'),

0 commit comments

Comments
 (0)