Beispiel #1
0
 def __init__(self):
     self.vocab = Index()
     for word in [
             'a', 'find', 'add', 'remove', 'clone', 'grass', 'red', 'wood',
             'blue', 'clear', 'tree', 'house', 'wall', 'door', 'window',
             'course', 'block', 'in', 'with', 'here', 'tall', 'short',
             ling.START, ling.STOP, ling.UNK
     ]:
         self.vocab.index(word)
Beispiel #2
0
 def __init__(self):
     dir_path = os.path.dirname(os.path.realpath(__file__))
     with open(os.path.join(dir_path, "recipes.yaml")) as recipes_f:
         recipes = yaml.load(recipes_f)
     # self.environment = set(recipes["environment"])
     self.index = Index()
     self.environment = set(self.index.index(e) for e in recipes["environment"])
     self.primitives = set(self.index.index(p) for p in recipes["primitives"])
     self.recipes = {}
     for output, inputs in recipes["recipes"].items():
         d = {}
         for inp, count in inputs.items():
             # special keys
             if "_" in inp:
                 d[inp] = count
             else:
                 d[self.index.index(inp)] = count
         self.recipes[self.index.index(output)] = d
     kinds = self.environment | self.primitives | set(self.recipes.keys())
     self.n_kinds = len(self.index)
Beispiel #3
0
 def __init__(self, recipes_path):
     with open(recipes_path) as recipes_f:
         recipes = yaml.load(recipes_f)
     self.index = Index()
     self.environment = set(
         self.index.index(e) for e in recipes["environment"])
     self.primitives = set(
         self.index.index(p) for p in recipes["primitives"])
     self.recipes = {}
     for output, inputs in recipes["recipes"].items():
         d = {}
         for inp, count in inputs.items():
             # special keys
             if "_" in inp:
                 d[inp] = count
             else:
                 d[self.index.index(inp)] = count
         self.recipes[self.index.index(output)] = d
     self.kinds = self.environment | self.primitives | set(
         self.recipes.keys())
     self.n_kinds = len(self.index)