python_code
stringlengths 0
4.04M
| repo_name
stringlengths 7
58
| file_path
stringlengths 5
147
|
---|---|---|
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
class StopCondition:
def __init__(self, agent):
self.agent = agent
def check(self) -> bool:
raise NotImplementedError("Implemented by subclass")
class NeverStopCondition(StopCondition):
def __init__(self, agent):
super().__init__(agent)
self.name = "never"
def check(self):
return False
| craftassist-master | python/base_agent/stop_condition.py |
from condition import NeverCondition
DEFAULT_THROTTLING_TICK = 16
THROTTLING_TICK_UPPER_LIMIT = 64
THROTTLING_TICK_LOWER_LIMIT = 4
# put a counter and a max_count so can't get stuck?
class Task(object):
def __init__(self):
self.memid = None
self.interrupted = False
self.finished = False
self.name = None
self.undone = False
self.last_stepped_time = None
self.throttling_tick = DEFAULT_THROTTLING_TICK
self.stop_condition = NeverCondition(None)
def step(self, agent):
# todo? make it so something stopped by condition can be resumed?
if self.stop_condition.check():
self.finished = True
return
return
def add_child_task(self, t, agent, pass_stop_condition=True):
# FIXME, this is ugly and dangerous; some conditions might keep state etc?
if pass_stop_condition:
t.stop_condition = self.stop_condition
agent.memory.task_stack_push(t, parent_memid=self.memid)
def interrupt(self):
self.interrupted = True
def check_finished(self):
if self.finished:
return self.finished
def hurry_up(self):
self.throttling_tick /= 4
if self.throttling_tick < THROTTLING_TICK_LOWER_LIMIT:
self.throttling_tick = THROTTLING_TICK_LOWER_LIMIT
def slow_down(self):
self.throttling_tick *= 4
if self.throttling_tick > THROTTLING_TICK_UPPER_LIMIT:
self.throttling_tick = THROTTLING_TICK_UPPER_LIMIT
def __repr__(self):
return str(type(self))
| craftassist-master | python/base_agent/task.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from collections import defaultdict, namedtuple
import binascii
import hashlib
import logging
import numpy as np
import time
import traceback
from word2number.w2n import word_to_num
from typing import Tuple, List, TypeVar
import uuid
##FFS FIXME!!!! arrange utils properly, put things in one place
XYZ = Tuple[int, int, int]
# two points p0(x0, y0, z0), p1(x1, y1, z1) determine a 3d cube(point_at_target)
POINT_AT_TARGET = Tuple[int, int, int, int, int, int]
IDM = Tuple[int, int]
Block = Tuple[XYZ, IDM]
Hole = Tuple[List[XYZ], IDM]
T = TypeVar("T") # generic type
#####FIXME!!!!!! make all these dicts all through code
Pos = namedtuple("pos", ["x", "y", "z"])
Look = namedtuple("look", "yaw, pitch")
Player = namedtuple("Player", "entityId, name, pos, look")
TICKS_PER_SEC = 100
TICKS_PER_MINUTE = 60 * TICKS_PER_SEC
TICKS_PER_HOUR = 60 * TICKS_PER_MINUTE
TICKS_PER_DAY = 24 * TICKS_PER_HOUR
class Time:
def __init__(self):
self.init_time_raw = time.time()
# converts from seconds to internal tick
def round_time(self, t):
return int(TICKS_PER_SEC * t)
def get_time(self):
return self.round_time(time.time() - self.init_time_raw)
def get_world_hour(self):
# returns a fraction of a day. 0 is sunrise, .5 is sunset, 1.0 is next day
return (time.localtime()[3] - 8 + time.localtime()[4] / 60) / 24
def add_tick(self, ticks=1):
time.sleep(ticks / TICKS_PER_SEC)
class ErrorWithResponse(Exception):
def __init__(self, chat):
self.chat = chat
class NextDialogueStep(Exception):
pass
class TimingWarn(object):
"""Context manager which logs a warning if elapsed time exceeds some threshold"""
def __init__(self, max_time: float):
self.max_time = max_time
def __enter__(self):
self.start_time = time.time()
def __exit__(self, exc_type, exc_value, exc_traceback):
self.elapsed_time = time.time() - self.start_time
if self.elapsed_time >= self.max_time:
logging.warn(
"Timing exceeded threshold: {}".format(self.elapsed_time)
+ "\n"
+ "".join(traceback.format_stack(limit=2))
)
def number_from_span(s):
try:
n = float(s)
except:
try:
n = float(word_to_num(s))
except:
return
return n
def check_username(hashed_username, username):
"""Compare the username with the hash to check if they
are same"""
user, salt = hashed_username.split(":")
return user == hashlib.sha256(salt.encode() + username.encode()).hexdigest()
def get_bounds(locs):
M = np.max(locs, axis=0)
m = np.min(locs, axis=0)
return m[0], M[0], m[1], M[1], m[2], M[2]
def group_by(items, key_fn):
"""Return a dict of {k: list[x]}, where key_fn(x) == k"""
d = defaultdict(list)
for x in items:
d[key_fn(x)].append(x)
return d
def hash_user(username):
"""Encrypt username"""
# uuid is used to generate a random number
salt = uuid.uuid4().hex
return hashlib.sha256(salt.encode() + username.encode()).hexdigest() + ":" + salt
def manhat_dist(a, b):
"""Return mahattan ditance between a and b"""
return abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2])
def pos_to_np(pos):
"""Convert pos to numpy array"""
if pos is None:
return None
return np.array((pos.x, pos.y, pos.z))
def shasum_file(path):
"""Retrn shasum of the file at path"""
sha = hashlib.sha1()
with open(path, "rb") as f:
block = f.read(2 ** 16)
while len(block) != 0:
sha.update(block)
block = f.read(2 ** 16)
return binascii.hexlify(sha.digest())
# TODO make this just a dict, and change in memory and agent
# eg in object_looked_at and PlayerNode
def to_player_struct(pos, yaw, pitch, eid, name):
if len(pos) == 2:
pos = Pos(pos[0], 0.0, pos[1])
else:
pos = Pos(pos[0], pos[1], pos[2])
look = Look(yaw, pitch)
return Player(eid, name, pos, look)
| craftassist-master | python/base_agent/base_util.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
MAP_YES = [
"yes",
"true",
"i agree",
"tru dat",
"yep",
"ya",
"yah",
"yeah",
"definitely",
"def",
"sure",
"ok",
"o k",
]
MAP_NO = ["no", "nope", "false", "definitely not"]
MAP_MAYBE = ["maybe", "unknown", "i don ' t know", "i do not know"]
ACTION_ING_MAPPING = {
"build": "building",
"dance": "dancing",
"destroy": "destroying",
"dig": "digging",
"fill": "filling",
"move": "moving",
}
| craftassist-master | python/base_agent/string_lists.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has functions to preprocess the chat from user before
querying the dialogue manager"""
import string
from spacy.lang.en import English
from typing import List
tokenizer = English().Defaults.create_tokenizer()
def word_tokenize(st) -> str:
chat_with_spaces = insert_spaces(st)
return " ".join([str(x) for x in tokenizer(chat_with_spaces)])
def sentence_split(st):
st = st.replace(" ?", " .")
st = st.replace(" !", " .")
st = st.replace(" ...", " .")
res = [
" ".join([x for x in sen.lower().split() if x not in string.punctuation])
for sen in st.split(" .")
]
return [x for x in res if x != ""]
def insert_spaces(chat):
updated_chat = ""
for i, c in enumerate(chat):
# [num , (num , {num , ,num , :num
if (
(c in ["[", "(", "{", ",", ":", "x"])
and (i != len(chat) - 1)
and (chat[i + 1].isdigit())
):
updated_chat += c + " "
# num, , num] , num) , num}, num:
# 4x -> 4 x
elif (
(c.isdigit())
and (i != len(chat) - 1)
and (chat[i + 1] in [",", "]", ")", "}", ":", "x"])
):
updated_chat += c + " "
else:
updated_chat += c
return updated_chat
def preprocess_chat(chat: str) -> List[str]:
# For debug mode, return as is.
if chat == "_debug_" or chat.startswith("_ttad_"):
return [chat]
# Tokenize
tokenized_line = word_tokenize(chat)
tokenized_sentences = [sen for sen in sentence_split(tokenized_line)]
return tokenized_sentences
if __name__ == "__main__":
import fileinput
for line in fileinput.input():
try:
print(preprocess_chat(line)[0])
except IndexError:
pass
| craftassist-master | python/base_agent/preprocess.py |
from typing import List
SELFID = "0" * 32
def maybe_and(sql, a):
if a:
return sql + " AND "
else:
return sql
def maybe_or(sql, a):
if a:
return sql + " OR "
else:
return sql
# TODO counts
def get_property_value(agent_memory, mem, prop):
# order of precedence:
# 1: main memory table
# 2: table corresponding to the nodes .TABLE
# 3: triple with the nodes memid as subject and prop as predicate
# is it in the main memory table?
cols = [c[1] for c in agent_memory._db_read("PRAGMA table_info(Memories)")]
if prop in cols:
cmd = "SELECT " + prop + " FROM Memories WHERE uuid=?"
r = agent_memory._db_read(cmd, mem.memid)
return r[0][0]
# is it in the mem.TABLE?
T = mem.TABLE
cols = [c[1] for c in agent_memory._db_read("PRAGMA table_info({})".format(T))]
if prop in cols:
cmd = "SELECT " + prop + " FROM " + T + " WHERE uuid=?"
r = agent_memory._db_read(cmd, mem.memid)
return r[0][0]
# is it a triple?
triples = agent_memory.get_triples(subj=mem.memid, pred_text=prop, return_obj_text="always")
if len(triples) > 0:
return triples[0][2]
return None
class MemorySearcher:
def __init__(self, self_memid=SELFID, search_data=None):
self.self_memid = self_memid
self.search_data = search_data
def search(self, memory, search_data=None) -> List["ReferenceObjectNode"]: # noqa T484
raise NotImplementedError
class ReferenceObjectSearcher(MemorySearcher):
def __init__(self, self_memid=SELFID, search_data=None):
super().__init__(self_memid=SELFID, search_data=None)
def is_filter_empty(self, filter_dict):
r = filter_dict.get("special")
if r and len(r) > 0:
return False
r = filter_dict.get("ref_obj_range")
if r and len(r) > 0:
return False
r = filter_dict.get("ref_obj_exact")
if r and len(r) > 0:
return False
r = filter_dict.get("memories_range")
if r and len(r) > 0:
return False
r = filter_dict.get("memories_exact")
if r and len(r) > 0:
return False
t = filter_dict.get("triples")
if t and len(t) > 0:
return False
return True
def range_queries(self, r, table, a=False):
""" this does x, y, z, pitch, yaw, etc.
input format for generates is
{"xmin": float, xmax: float, ... , yawmin: float, yawmax: float}
"""
sql = ""
vals = []
for k, v in r.items():
if "min" in k:
sql = maybe_and(sql, len(vals) > 0)
sql += table + "." + k.replace("min", "") + ">? "
vals.append(v)
if "max" in k:
sql = maybe_and(sql, len(vals) > 0)
sql += table + "." + k.replace("max", "") + "<? "
vals.append(v)
return sql, vals
def exact_matches(self, m, table, a=False):
sql = ""
vals = []
for k, v in m.items():
sql = maybe_and(sql, len(vals) > 0)
sql += table + "." + k + "=? "
vals.append(v)
return sql, vals
def triples(self, triples, a=False):
# currently does an "and": the memory needs to satisfy all triples
vals = []
if not triples:
return "", vals
sql = "ReferenceObjects.uuid IN (SELECT subj FROM Triples WHERE "
for t in triples:
sql = maybe_or(sql, len(vals) > 0)
vals.append(t["pred_text"])
if t.get("obj_text"):
sql += "(pred_text, obj_text)=(?, ?)"
vals.append(t["obj_text"])
else:
sql += "(pred_text, obj)=(?, ?)"
vals.append(t["obj"])
sql += " GROUP BY subj HAVING COUNT(subj)=? )"
vals.append(len(triples))
return sql, vals
def get_query(self, filter_dict, ignore_self=True):
if self.is_filter_empty(filter_dict):
query = "SELECT uuid FROM ReferenceObjects"
if ignore_self:
query += " WHERE uuid !=?"
return query, [self.self_memid]
else:
return query, []
query = (
"SELECT ReferenceObjects.uuid FROM ReferenceObjects"
" INNER JOIN Memories as M on M.uuid=ReferenceObjects.uuid"
" WHERE "
)
args = []
fragment, vals = self.range_queries(
filter_dict.get("ref_obj_range", {}), "ReferenceObjects"
)
query = maybe_and(query, len(args) > 0)
args.extend(vals)
query += fragment
fragment, vals = self.exact_matches(
filter_dict.get("ref_obj_exact", {}), "ReferenceObjects"
)
query = maybe_and(query, len(args) > 0 and len(vals) > 0)
args.extend(vals)
query += fragment
fragment, vals = self.range_queries(filter_dict.get("memories_range", {}), "M")
query = maybe_and(query, len(args) > 0 and len(vals) > 0)
args.extend(vals)
query += fragment
fragment, vals = self.exact_matches(filter_dict.get("memories_exact", {}), "M")
query = maybe_and(query, len(args) > 0 and len(vals) > 0)
args.extend(vals)
query += fragment
fragment, vals = self.triples(filter_dict.get("triples", []))
query = maybe_and(query, len(args) > 0 and len(vals) > 0)
args.extend(vals)
query += fragment
if ignore_self:
query += " AND ReferenceObjects.uuid !=?"
args.append(self.self_memid)
return query, args
# flag (default) so that it makes a copy of speaker_look etc so that if the searcher is called
# later so it doesn't return the new position of the agent/speaker/speakerlook
# how to parse this distinction?
def handle_special(self, memory, search_data):
d = search_data.get("special")
if not d:
return []
if d.get("SPEAKER"):
return [memory.get_player_by_eid(d["SPEAKER"])]
if d.get("SPEAKER_LOOK"):
memids = memory._db_read_one(
'SELECT uuid FROM ReferenceObjects WHERE ref_type="attention" AND type_name=?',
d["SPEAKER_LOOK"],
)
if memids:
memid = memids[0]
mem = memory.get_location_by_id(memid)
return [mem]
if d.get("AGENT"):
return [memory.get_player_by_eid(d["AGENT"])]
if d.get("DUMMY"):
return [d["DUMMY"]]
return []
def search(self, memory, search_data=None) -> List["ReferenceObjectNode"]: # noqa T484
"""Find ref_objs matching the given filters
filter_dict has children:
"ref_obj_range", dict, with keys "min<column_name>" or "max<column_name>",
(that is the string "min" prepended to the column name)
and float values vmin and vmax respectively.
<column_name> is any column in the ReferenceObjects table that
is a numerical value. filters on rows satisfying the inequality
<column_entry> > vmin or <column_entry> < vmax
"ref_obj_exact", dict, with keys "<column_name>"
<column_name> is any column in the ReferenceObjects table
checks exact matches to the value
"memories_range" and "memories_exact" are the same, but columns in the Memories table
"triples" list [t0, t1, ...,, tm]. each t in the list is a dict
with form t = {"pred_text": <pred>, "obj_text": <obj>}
or t = {"pred_text": <pred>, "obj": <obj_memid>}
currently returns memories with all triples matched
"""
if not search_data:
search_data = self.search_data
assert search_data
if search_data.get("special"):
return self.handle_special(memory, search_data)
query, args = self.get_query(search_data)
self.search_data = search_data
memids = [m[0] for m in memory._db_read(query, *args)]
return [memory.get_mem_by_id(memid) for memid in memids]
if __name__ == "__main__":
filter_dict = {
"ref_obj_range": {"minx": 3},
"memories_exact": {"create_time": 1},
"triples": [
{"pred_text": "has_tag", "obj_text": "cow"},
{"pred_text": "has_name", "obj_text": "eddie"},
],
}
| craftassist-master | python/base_agent/memory_filters.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file defines the DialogueStack class and helper functions
to support it."""
import logging
from base_agent.base_util import NextDialogueStep, ErrorWithResponse
class DialogueStack(object):
"""This class represents a dialogue stack that holds DialogueObjects on it."""
def __init__(self, agent, memory):
self.agent = agent
self.memory = memory
self.stack = []
def __getitem__(self, i):
"""Get the ith item on the stack """
return self.stack[i]
def peek(self):
"""Get the item on top of the DialogueStack"""
if self.stack:
return self.stack[-1]
else:
return None
def clear(self):
"""clear current stack"""
self.old_stack = self.stack
self.stack = []
def append(self, dialogue_object):
"""Append a dialogue_object to stack"""
self.stack.append(dialogue_object)
def append_new(self, cls, *args, **kwargs):
"""Construct a new DialogueObject and append to stack"""
self.stack.append(
cls(agent=self.agent, memory=self.memory, dialogue_stack=self, *args, **kwargs)
)
def step(self):
"""Process and step through the top-of-stack dialogue object."""
if len(self.stack) > 0:
# WARNING: check_finished increments the DialogueObject's current_step counter
while len(self.stack) > 0 and self.stack[-1].check_finished():
del self.stack[-1]
if len(self.stack) == 0:
return
try:
output_chat, step_data = self.stack[-1].step()
if output_chat:
self.agent.send_chat(output_chat)
# Update progeny_data of the current DialogueObject
if len(self.stack) > 1 and step_data is not None:
logging.info("Update progeny_data={} stack={}".format(step_data, self.stack))
self.stack[-2].update_progeny_data(step_data)
except NextDialogueStep:
return
except ErrorWithResponse as err:
self.stack[-1].finished = True
self.agent.send_chat(err.chat)
return
def __len__(self):
"""Length of stack"""
return len(self.stack)
| craftassist-master | python/base_agent/dialogue_stack.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
###TODO put dances back
import gzip
import logging
import numpy as np
import os
import pickle
import sqlite3
import uuid
from itertools import zip_longest
from typing import cast, Optional, List, Tuple, Sequence, Union
from base_agent.base_util import XYZ, Time
from base_agent.task import Task
from base_agent.memory_filters import ReferenceObjectSearcher
from base_agent.memory_nodes import ( # noqa
TaskNode,
PlayerNode,
MemoryNode,
ChatNode,
TimeNode,
LocationNode,
ReferenceObjectNode,
NamedAbstractionNode,
NODELIST,
)
SCHEMAS = [os.path.join(os.path.dirname(__file__), "memory_schema.sql")]
# TODO when a memory is removed, its last state should be snapshotted to prevent tag weirdness
class AgentMemory:
def __init__(
self,
db_file=":memory:",
schema_paths=SCHEMAS,
db_log_path=None,
nodelist=NODELIST,
agent_time=None,
):
if db_log_path:
self._db_log_file = gzip.open(db_log_path + ".gz", "w")
self._db_log_idx = 0
self.sql_queries = []
if os.path.isfile(db_file):
os.remove(db_file)
self.db = sqlite3.connect(db_file)
self.task_db = {}
self._safe_pickle_saved_attrs = {}
self.init_time_interface(agent_time)
for schema_path in schema_paths:
with open(schema_path, "r") as f:
self._db_script(f.read())
self.all_tables = [
c[0] for c in self._db_read("SELECT name FROM sqlite_master WHERE type='table';")
]
self.nodes = {}
for node in nodelist:
self.nodes[node.NODE_TYPE] = node
# create a "self" memory to reference in Triples
self.self_memid = "0" * len(uuid.uuid4().hex)
self._db_write(
"INSERT INTO Memories VALUES (?,?,?,?,?,?)", self.self_memid, "Self", 0, 0, -1, False
)
self.tag(self.self_memid, "_agent")
self.tag(self.self_memid, "_self")
self.ref_searcher = ReferenceObjectSearcher(self_memid=self.self_memid)
def __del__(self):
if getattr(self, "_db_log_file", None):
self._db_log_file.close()
def init_time_interface(self, agent_time=None):
self.time = agent_time or Time()
def get_time(self):
return self.time.get_time()
def get_world_time(self):
return self.time.get_world_time()
def add_tick(self, ticks=1):
self.time.add_tick(ticks)
# TODO list of all "updatable" mems, do a mem.update() ?
def update(self, agent):
pass
########################
### Workspace memory ###
########################
def set_memory_updated_time(self, memid):
self._db_write("UPDATE Memories SET updated_time=? WHERE uuid=?", self.get_time(), memid)
def set_memory_attended_time(self, memid):
self._db_write("UPDATE Memories SET attended_time=? WHERE uuid=?", self.get_time(), memid)
def update_recent_entities(self, mems=[]):
logging.info("update_recent_entities {}".format(mems))
for mem in mems:
mem.update_recently_attended()
# for now, no archives in recent entities
def get_recent_entities(self, memtype, time_window=12000) -> List["MemoryNode"]:
r = self._db_read(
"""SELECT uuid
FROM Memories
WHERE node_type=? AND attended_time >= ? and is_snapshot=0
ORDER BY attended_time DESC""",
memtype,
self.get_time() - time_window,
)
return [self.get_mem_by_id(memid, memtype) for memid, in r]
###############
### General ###
###############
def get_node_from_memid(self, memid: str) -> str:
(r,) = self._db_read_one("SELECT node_type FROM Memories WHERE uuid=?", memid)
return r
def get_mem_by_id(self, memid: str, node_type: str = None) -> "MemoryNode":
if node_type is None:
node_type = self.get_node_from_memid(memid)
if node_type is None:
return MemoryNode(self, memid)
return self.nodes.get(node_type, MemoryNode)(self, memid)
# does not search archived mems for now
def get_all_tagged_mems(self, tag: str) -> List["MemoryNode"]:
memids = self.get_memids_by_tag(tag)
return [self.get_mem_by_id(memid) for memid in memids]
def check_memid_exists(self, memid: str, table: str) -> bool:
return bool(self._db_read_one("SELECT * FROM {} WHERE uuid=?".format(table), memid))
# TODO forget should be a method of the memory object
def forget(self, memid: str, hard=True):
if not hard:
self.add_triple(subj=memid, pred_text="has_tag", obj_text="_forgotten")
else:
self._db_write("DELETE FROM Memories WHERE uuid=?", memid)
# TODO this less brutally. might want to remember some
# triples where the subject or object has been removed
# eventually we might have second-order relations etc, this could set
# off a chain reaction
self.remove_memid_triple(memid, role="both")
##########################
### ReferenceObjects ###
##########################
def get_reference_objects(self, filter_dict):
return self.ref_searcher.search(self, search_data=filter_dict)
#################
### Triples ###
#################
# TODO should add a MemoryNode and a .create()
def add_triple(
self,
subj: str = "", # this is a memid if given
obj: str = "", # this is a memid if given
subj_text: str = "",
pred_text: str = "has_tag",
obj_text: str = "",
confidence: float = 1.0,
):
""" adds (subj, pred, obj) triple to the triplestore.
*_text is the name field of a NamedAbstraction; if
such a NamedAbstraction does not exist, this builds it as a side effect.
subj and obj can be memids or text, but pred_text is required """
assert subj or subj_text
assert obj or obj_text
assert not (subj and subj_text)
assert not (obj and obj_text)
memid = uuid.uuid4().hex
pred = NamedAbstractionNode.create(self, pred_text)
if not obj:
obj = NamedAbstractionNode.create(self, obj_text)
if not subj:
subj = NamedAbstractionNode.create(self, subj_text)
if not subj_text:
subj_text = None # noqa T484
if not obj_text:
obj_text = None # noqa T484
self._db_write(
"INSERT INTO Triples VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
memid,
subj,
subj_text,
pred,
pred_text,
obj,
obj_text,
confidence,
)
def tag(self, subj_memid: str, tag_text: str):
self.add_triple(subj=subj_memid, pred_text="has_tag", obj_text=tag_text)
def untag(self, subj_memid: str, tag_text: str):
self._db_write(
'DELETE FROM Triples WHERE subj=? AND pred_text="has_tag" AND obj_text=?',
subj_memid,
tag_text,
)
# does not search archived mems for now
# assumes tag is tag text
def get_memids_by_tag(self, tag: str) -> List[str]:
r = self._db_read(
'SELECT DISTINCT(Memories.uuid) FROM Memories INNER JOIN Triples as T ON T.subj=Memories.uuid WHERE T.pred_text="has_tag" AND T.obj_text=? AND Memories.is_snapshot=0',
tag,
)
return [x for (x,) in r]
def get_tags_by_memid(self, subj_memid: str, return_text: bool = True) -> List[str]:
if return_text:
return_clause = "obj_text"
else:
return_clause = "obj"
q = (
"SELECT DISTINCT("
+ return_clause
+ ') FROM Triples WHERE pred_text="has_tag" AND subj=?'
)
r = self._db_read(q, subj_memid)
return [x for (x,) in r]
# does not search archived mems for now
# TODO clean up input?
def get_triples(
self,
subj: str = None,
obj: str = None,
subj_text: str = None,
pred_text: str = None,
obj_text: str = None,
return_obj_text: str = "if_exists",
) -> List[Tuple[str, str, str]]:
""" gets triples from the triplestore.
if return_obj_text == "if_exists", will return the obj_text
if it exists, and the memid otherwise
if return_obj_text == "always", returns the obj_text even if it is None
if return_obj_text == "never", returns the obj memid
subj is always returned as a memid even when searched as text.
need at least one non-None part of the triple, and
text should not not be input for a part of a triple where a memid is set
"""
assert any([subj or subj_text, pred_text, obj or obj_text])
# search by memid or by text, but not both
assert not (subj and subj_text)
assert not (obj and obj_text)
pairs = [
("subj", subj),
("subj_text", subj_text),
("pred_text", pred_text),
("obj", obj),
("obj_text", obj_text),
]
args = [x[1] for x in pairs if x[1] is not None]
where = [x[0] + "=?" for x in pairs if x[1] is not None]
if len(where) == 1:
where_clause = where[0]
else:
where_clause = " AND ".join(where)
return_clause = "subj, pred_text, obj, obj_text "
sql = (
"SELECT "
+ return_clause
+ "FROM Triples INNER JOIN Memories as M ON Triples.subj=M.uuid WHERE M.is_snapshot=0 AND "
+ where_clause
)
r = self._db_read(sql, *args)
# subj is always returned as memid, even if pred and obj are returned as text
# pred is always returned as text
if return_obj_text == "if_exists":
l = [(s, pt, ot) if ot else (s, pt, o) for (s, pt, o, ot) in r]
elif return_obj_text == "always":
l = [(s, pt, ot) for (s, pt, o, ot) in r]
else:
l = [(s, pt, o) for (s, pt, o, ot) in r]
return cast(List[Tuple[str, str, str]], l)
def remove_memid_triple(self, memid: str, role="subj"):
if role == "subj" or role == "both":
self._db_write("DELETE FROM Triples WHERE subj=?", memid)
if role == "obj" or role == "both":
self._db_write("DELETE FROM Triples WHERE obj=?", memid)
###############
### Chats ###
###############
def add_chat(self, speaker_memid: str, chat: str) -> str:
return ChatNode.create(self, speaker_memid, chat)
def get_chat_by_id(self, memid: str) -> "ChatNode":
return ChatNode(self, memid)
def get_recent_chats(self, n=1) -> List["ChatNode"]:
"""Return a list of at most n chats"""
r = self._db_read("SELECT uuid FROM Chats ORDER BY time DESC LIMIT ?", n)
return [ChatNode(self, m) for m, in reversed(r)]
def get_most_recent_incoming_chat(self, after=-1) -> Optional["ChatNode"]:
r = self._db_read_one(
"""
SELECT uuid
FROM Chats
WHERE speaker != ? AND time >= ?
ORDER BY time DESC
LIMIT 1
""",
self.self_memid,
after,
)
if r:
return ChatNode(self, r[0])
else:
return None
#################
### Players ###
#################
# TODO consolidate anything using eid
def get_player_by_eid(self, eid) -> Optional["PlayerNode"]:
r = self._db_read_one("SELECT uuid FROM ReferenceObjects WHERE eid=?", eid)
if r:
return PlayerNode(self, r[0])
else:
return None
def get_player_by_name(self, name) -> Optional["PlayerNode"]:
r = self._db_read_one(
'SELECT uuid FROM ReferenceObjects WHERE ref_type="player" AND name=?', name
)
# r = self._db_read_one("SELECT uuid FROM Players WHERE name=?", name)
if r:
return PlayerNode(self, r[0])
else:
return None
def get_players_tagged(self, *tags) -> List["PlayerNode"]:
tags += ("_player",)
memids = set.intersection(*[set(self.get_memids_by_tag(t)) for t in tags])
return [self.get_player_by_id(memid) for memid in memids]
def get_player_by_id(self, memid) -> "PlayerNode":
return PlayerNode(self, memid)
###################
### Locations ###
###################
def add_location(self, xyz: XYZ) -> str:
return LocationNode.create(self, xyz)
def get_location_by_id(self, memid: str) -> "LocationNode":
return LocationNode(self, memid)
###############
### Times ###
###############
def add_time(self, t: int) -> str:
return TimeNode.create(self, t)
def get_time_by_id(self, memid: str) -> "TimeNode":
return TimeNode(self, memid)
# ###############
# ### Sets ###
# ###############
#
# def add_set(self, memid_list):
# set_memid = SetNode.create(self)
# self.add_objs_to_set(set_memid, memid_list)
# return SetNode(self, set_memid)
#
# def add_objs_to_set(self, set_memid, memid_list):
# for mid in memid_list:
# self.add_triple(mid, "set_member_", set_memid)
###############
### Tasks ###
###############
def task_stack_push(
self, task: Task, parent_memid: str = None, chat_effect: bool = False
) -> "TaskNode":
memid = TaskNode.create(self, task)
# Relations
if parent_memid:
self.add_triple(subj=memid, pred_text="_has_parent_task", obj=parent_memid)
if chat_effect:
chat = self.get_most_recent_incoming_chat()
assert chat is not None, "chat_effect=True with no incoming chats"
self.add_triple(subj=chat.memid, pred_text="chat_effect_", obj=memid)
# Return newly created object
return TaskNode(self, memid)
def task_stack_update_task(self, memid: str, task: Task):
self._db_write("UPDATE Tasks SET pickled=? WHERE uuid=?", self.safe_pickle(task), memid)
def task_stack_peek(self) -> Optional["TaskNode"]:
r = self._db_read_one(
"""
SELECT uuid
FROM Tasks
WHERE finished_at < 0 AND paused = 0
ORDER BY created_at DESC
LIMIT 1
"""
)
if r:
return TaskNode(self, r[0])
else:
return None
def task_stack_pop(self) -> Optional["TaskNode"]:
"""Return the 'TaskNode' of the stack head and mark finished"""
mem = self.task_stack_peek()
if mem is None:
raise ValueError("Called task_stack_pop with empty stack")
self._db_write("UPDATE Tasks SET finished_at=? WHERE uuid=?", self.get_time(), mem.memid)
return mem
def task_stack_pause(self) -> bool:
"""Pause the stack and return True iff anything was stopped"""
return self._db_write("UPDATE Tasks SET paused=1 WHERE finished_at < 0") > 0
def task_stack_clear(self):
self._db_write("DELETE FROM Tasks WHERE finished_at < 0")
def task_stack_resume(self) -> bool:
"""Resume stopped tasks. Return True if there was something to resume."""
return self._db_write("UPDATE Tasks SET paused=0") > 0
def task_stack_find_lowest_instance(
self, cls_names: Union[str, Sequence[str]]
) -> Optional["TaskNode"]:
"""Find and return the lowest item in the stack of the given class(es)"""
names = [cls_names] if type(cls_names) == str else cls_names
(memid,) = self._db_read_one(
"SELECT uuid FROM Tasks WHERE {} ORDER BY created_at LIMIT 1".format(
" OR ".join(["action_name=?" for _ in names])
),
*names,
)
if memid is not None:
return TaskNode(self, memid)
else:
return None
def task_stack_get_all(self) -> List["TaskNode"]:
r = self._db_read(
"""
SELECT uuid
FROM Tasks
WHERE paused=0 AND finished_at<0
ORDER BY created_at
"""
)
return [TaskNode(self, memid) for memid, in r]
def get_last_finished_root_task(self, action_name: str = None, recency: int = None):
q = """
SELECT uuid
FROM Tasks
WHERE finished_at >= ? {}
ORDER BY created_at DESC
""".format(
" AND action_name=?" if action_name else ""
)
if recency is None:
recency = self.time.round_time(300)
args: List = [self.get_time() - recency]
if action_name:
args.append(action_name)
memids = [r[0] for r in self._db_read(q, *args)]
for memid in memids:
if self._db_read_one(
"SELECT uuid FROM Triples WHERE pred_text='_has_parent_task' AND subj=?", memid
):
# not a root task
continue
return TaskNode(self, memid)
# raise ValueError("Called get_last_finished_root_task with no finished root tasks")
def get_task_by_id(self, memid: str) -> "TaskNode":
return TaskNode(self, memid)
#################
### Time ###
#################
def hurry_up(self):
if self.task_stack_peek() is None:
return # send chat?
task_mem = self.task_stack_peek()
task_mem.task.hurry_up()
self.task_stack_update_task(task_mem.memid, task_mem.task)
def slow_down(self):
if self.task_stack_peek() is None:
return # send chat?
task_mem = self.task_stack_peek()
task_mem.task.slow_down()
self.task_stack_update_task(task_mem.memid, task_mem.task)
#########################
### Database Access ###
#########################
def _db_read(self, query, *args) -> List[Tuple]:
args = tuple(a.item() if isinstance(a, np.number) else a for a in args)
try:
c = self.db.cursor()
c.execute(query, args)
query = query.replace("?", "{}").format(*args)
if query not in self.sql_queries:
self.sql_queries.append(query)
r = c.fetchall()
c.close()
return r
except:
logging.error("Bad read: {} : {}".format(query, args))
raise
def _db_read_one(self, query, *args) -> Tuple:
args = tuple(a.item() if isinstance(a, np.number) else a for a in args)
try:
c = self.db.cursor()
c.execute(query, args)
query = query.replace("?", "{}").format(*args)
if query not in self.sql_queries:
self.sql_queries.append(query)
r = c.fetchone()
c.close()
return r
except:
logging.error("Bad read: {} : {}".format(query, args))
raise
def _db_write(self, query: str, *args) -> int:
"""Return the number of rows affected"""
args = tuple(a.item() if isinstance(a, np.number) else a for a in args)
try:
c = self.db.cursor()
c.execute(query, args)
query = query.replace("?", "{}").format(*args)
if query not in self.sql_queries:
self.sql_queries.append(query)
self.db.commit()
c.close()
self._write_to_db_log(query, *args)
return c.rowcount
except:
logging.error("Bad write: {} : {}".format(query, args))
raise
def _db_script(self, script: str):
c = self.db.cursor()
c.executescript(script)
self.db.commit()
c.close()
self._write_to_db_log(script, no_format=True)
####################
### DB LOGGING ###
####################
def get_db_log_idx(self):
return self._db_log_idx
def _write_to_db_log(self, s: str, *args, no_format=False):
if not getattr(self, "_db_log_file", None):
return
# sub args in for ?
split = s.split("?")
final = b""
for sub, arg in zip_longest(split, args, fillvalue=""):
final += str(sub).encode("utf-8")
if type(arg) == str and arg != "":
# put quotes around string args
final += '"{}"'.format(arg).encode("utf-8")
else:
final += str(arg).encode("utf-8")
# remove newlines, add semicolon
if not no_format:
final = final.strip().replace(b"\n", b" ") + b";\n"
# write to file
self._db_log_file.write(final)
self._db_log_file.flush()
self._db_log_idx += 1
######################
### MISC HELPERS ###
######################
def dump(self, sql_file, dict_memory_file=None):
sql_file.write("\n".join(self.db.iterdump()))
if dict_memory_file is not None:
import io
import pickle
assert type(dict_memory_file) == io.BufferedWriter
dict_memory = {"task_db": self.task_db}
pickle.dump(dict_memory, dict_memory_file)
def safe_pickle(self, obj):
# little bit scary...
if not hasattr(obj, "pickled_attrs_id"):
if hasattr(obj, "memid"):
obj.pickled_attrs_id = obj.memid
else:
try:
obj.pickled_attrs_id = uuid.uuid4().hex
except:
pass
for attr in ["memory", "agent_memory", "new_tasks_fn", "stop_condition", "movement"]:
if hasattr(obj, attr):
if self._safe_pickle_saved_attrs.get(obj.pickled_attrs_id) is None:
self._safe_pickle_saved_attrs[obj.pickled_attrs_id] = {}
val = getattr(obj, attr)
delattr(obj, attr)
setattr(obj, "__had_attr_" + attr, True)
self._safe_pickle_saved_attrs[obj.pickled_attrs_id][attr] = val
return pickle.dumps(obj)
def safe_unpickle(self, bs):
obj = pickle.loads(bs)
if hasattr(obj, "pickled_attrs_id"):
for attr in ["memory", "agent_memory", "new_tasks_fn", "stop_condition", "movement"]:
if hasattr(obj, "__had_attr_" + attr):
delattr(obj, "__had_attr_" + attr)
setattr(obj, attr, self._safe_pickle_saved_attrs[obj.pickled_attrs_id][attr])
return obj
| craftassist-master | python/base_agent/sql_memory.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/base_agent/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
class BaseAgent:
def __init__(self, opts, name=None):
self.opts = opts
self.name = name or "bot"
self.count = 0
self.init_memory()
self.init_controller()
self.init_perception()
def start(self):
while True: # count forever
try:
self.step()
except Exception as e:
self.handle_exception(e)
def step(self):
self.perceive()
self.memory.update(self)
# maybe place tasks on the stack, based on memory/perception
self.controller_step()
# step topmost task on stack
self.task_step()
self.count += 1
def perceive(self):
"""
Get information from the world and store it in memory.
"""
raise NotImplementedError
def controller_step(self):
"""
interpret commands, carry out dialogues, etc. place tasks on the task stack.
"""
raise NotImplementedError
def task_step(self):
"""
run the current task on the stack. interact with the world
"""
raise NotImplementedError
def handle_exception(self, e):
"""
handle/log exceptions
"""
raise NotImplementedError
| craftassist-master | python/base_agent/core.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import numpy as np
from memory_filters import ReferenceObjectSearcher, get_property_value
from base_util import TICKS_PER_SEC, TICKS_PER_MINUTE, TICKS_PER_HOUR
# attribute has function signature list(mems) --> list(float)
class Attribute:
def __init__(self, agent):
self.agent = agent
def __call__(self, mems):
raise NotImplementedError("Implemented by subclass")
class TableColumn(Attribute):
def __init__(self, agent, attribute):
super().__init__(agent)
self.attribute = attribute
def __call__(self, mems):
return [get_property_value(self.agent.memory, mem, self.attribute) for mem in mems]
class LinearExtentAttribute(Attribute):
"""
computes the (perhaps signed) length between two points in space.
if "relative_direction"=="AWAY", unsigned length
if "relative_direction" in ["LEFT", "RIGHT" ...] projected onto a special direction
and signed. the "arrow" goes from "source" to "destination",
e.g. if destination is more LEFT than source, "LEFT" will be positive
if "relative_direction" in ["INSIDE", "OUTSIDE"], signed length is shifted towards zero
so that 0 is at the boundary of the source.
This is not implemented yet FIXME!!
One of the two points in space is given by the positions of a reference object
either given directly as a memory, or given as FILTERs to search
the other is the list element input into the call
"""
def __init__(self, agent, location_data, mem=None, fixed_role="source"):
super().__init__(agent)
self.coordinate_transforms = agent.coordinate_transforms
self.location_data = location_data
self.fixed_role = fixed_role
self.frame = location_data.get("frame") or "AGENT"
# TODO generalize/formalize this
# TODO: currently stores look vecs/orientations at creation,
# build mechanism to update orientations, e.g. if giving directions
# "first you turn left, then go 7 steps forward, turn right, go 7 steps forward"
# need this in grammar too
# TODO store fixed pitch/yaw etc. with arxiv memories, not raw
try:
if self.frame == "AGENT":
# TODO handle this appropriately!
yaw, pitch = agent.memory._db_read(
"SELECT yaw, pitch FROM ReferenceObjects WHERE uuid=?", agent.memory.self_memid
)[0]
elif self.frame == "ABSOLUTE":
yaw, pitch = self.coordinate_transforms.yaw_pitch(
self.coordinate_transforms.DIRECTIONS["FRONT"]
)
# this is another player/agent; it is assumed that the frame has been replaced with
# with the eid of the player/agent
else:
# TODO error if eid not found; but then parent/helper should have caught it?
# TODO error properly if eid is a ref object, but pitch or yaw are null
yaw, pitch = agent.memory._db_read(
"SELECT yaw, pitch FROM ReferenceObjects WHERE eid=?", self.frame
)[0]
except:
# TODO handle this better
raise Exception(
"Unable to find the yaw, pitch in the given frame; maybe can't find the eid?"
)
self.yaw = yaw
self.pitch = pitch
self.mem = mem
self.searcher = "mem"
# put a "NULL" mem in input to not build a searcher
if not self.mem:
d = self.location_data.get(fixed_role)
if d:
self.searchers = ReferenceObjectSearcher(search_data=d)
def extent(self, source, destination):
# source and destination are arrays in this function
# arrow goes from source to destination:
diff = np.subtract(source, destination)
if self.location_data["relative_direction"] in ["INSIDE", "OUTSIDE"]:
raise Exception("inside and outside not yet implemented in linear extent")
if self.location_data["relative_direction"] in [
"LEFT",
"RIGHT",
"UP",
"DOWN",
"FRONT",
"BACK",
]:
reldir_vec = self.coordinate_transforms.DIRECTIONS[
self.location_data["relative_direction"]
]
# this should be an inverse transform so we set inverted=True
dir_vec = self.coordinate_transforms.transform(
reldir_vec, self.yaw, self.pitch, inverted=True
)
return diff @ dir_vec
else: # AWAY
return np.linalg.norm(diff)
def __call__(self, mems):
if not self.mem:
fixed_mem = self.searcher.search(self.agent.memory)
# FIXME!!! handle mem not found
else:
fixed_mem = self.mem
# FIMXE TODO store and use an arxiv if we don't want position to track!
if self.fixed_role == "source":
return [self.extent(fixed_mem.get_pos(), mem.get_pos()) for mem in mems]
else:
return [self.extent(mem.get_pos(), fixed_mem.get_pos()) for mem in mems]
# a value has a get_value() method; and get_value should not have
# any inputs
class ComparisonValue:
def __init__(self, agent):
self.agent = agent
def get_value(self):
raise NotImplementedError("Implemented by subclass")
# TODO more composable less ugly, more ML friendly
class ScaledValue(ComparisonValue):
def __init__(self, value, scale):
self.value = value
self.scale = scale
def get_value(self):
return self.scale * self.value.get_value()
# TODO feet, meters, inches, centimeters, degrees, etc.
# each of these converts a measure into the agents internal units,
# e.g. seconds/minutes/hours to ticks
# inches/centimeters/feet to meters or blocks (assume 1 block in mc equals 1 meter in real world)
conversion_factors = {
"seconds": TICKS_PER_SEC,
"minutes": TICKS_PER_MINUTE,
"hours": TICKS_PER_HOUR,
}
def convert_comparison_value(comparison_value, unit):
if not unit:
return comparison_value
assert conversion_factors.get(unit)
return ScaledValue(comparison_value, conversion_factors[unit])
class FixedValue(ComparisonValue):
def __init__(self, agent, value):
super().__init__(agent)
self.value = value
def get_value(self):
return self.value
# TODO store more in memory,
# or at least
# make some TimeNodes as side effects
# WARNING: elapsed mode uses get_time at construction as 0
class TimeValue(ComparisonValue):
"""
modes are elapsed, time, and world_time.
if "elapsed" or "time" uses memory.get_time as timer
if "elapsed", value is offset by time at creation
if "world_time" uses memory.get_world_time
"""
def __init__(self, agent, mode="elapsed"):
self.mode = mode
self.offset = 0.0
if self.mode == "elapsed":
self.offset = agent.memory.get_time()
self.get_time = agent.memory.get_time
elif self.mode == "time":
self.get_time = agent.memory.get_time
else: # world_time
self.get_time = agent.memory.get_world_time
def get_value(self):
return self.get_time() - self.offset
# TODO unit conversions?
class MemoryColumnValue(ComparisonValue):
def __init__(self, agent, search_data, mem=None):
super().__init__(agent)
self.search_data = search_data
# TODO expand beyond ref objects
self.mem = mem
if not self.mem:
self.searcher = ReferenceObjectSearcher(search_data=search_data)
def get_value(self):
if self.mem:
return self.search_data["attribute"]([self.mem])[0]
mems = self.searcher.search(self.agent.memory)
if len(mems) > 0:
# TODO/FIXME! deal with more than 1 better
return self.search_data["attribute"](mems)[0]
else:
return
class LinearExtentValue(ComparisonValue):
# this is a linear extent with both source and destination filled.
# e.g. "when you are as far from the house as the cow is from the house"
# but NOT for "when the cow is 3 steps from the house"
# in the latter case, one of the two entities will be given by the filters
def __init__(self, agent, linear_exent_attribute, mem=None, search_data=None):
super().__init__(agent)
self.linear_extent_attribute = linear_exent_attribute
assert mem or search_data
self.searcher = None
self.mem = mem
if not self.mem:
self.searcher = ReferenceObjectSearcher(search_data=search_data)
def get_value(self):
if self.mem:
mems = [self.mem]
else:
mems = self.searcher.search(self.agent.memory)
if len(mems) > 0:
# TODO/FIXME! deal with more than 1 better
return self.linear_extent_attribute(mems)[0]
else:
return
class Condition:
def __init__(self, agent):
self.agent = agent
def check(self) -> bool:
raise NotImplementedError("Implemented by subclass")
class NeverCondition(Condition):
def __init__(self, agent):
super().__init__(agent)
self.name = "never"
def check(self):
return False
class AndCondition(Condition):
""" conditions should be an iterable"""
def __init__(self, agent, conditions):
super().__init__(agent)
self.name = "and"
self.conditions = conditions
def check(self):
for c in self.conditions:
if not c.check():
return False
return True
class OrCondition(Condition):
""" conditions should be an iterable"""
def __init__(self, agent, conditions):
super().__init__(agent)
self.name = "or"
self.conditions = conditions
def check(self):
for c in self.conditions:
if c.check():
return True
return False
# start_time and end_time are in (0, 1)
# 0 is sunrise, .5 is sunset
def build_special_time_condition(agent, start_time, end_time, epsilon=0.01):
value_left = TimeValue(agent, mode="world_time")
if end_time > 0:
start = Comparator(
comparison_type="GREATER_THAN_EQUAL", value_left=value_left, value_right=start_time
)
end = Comparator(
comparison_type="LESS_THAN_EQUAL", value_left=value_left, value_right=end_time
)
return AndCondition(agent, [start, end])
else:
return Comparator(
comparison_type="CLOSE_TO",
value_left=value_left,
value_right=start_time,
epsilon=epsilon,
)
# TODO make this more ML friendly?
# eventually do "x minutes before condition"? how?
# KEEPS state (did the event occur- starts timer then)
class TimeCondition(Condition):
"""
if event is None, the timer starts now
if event is not None, it should be a condition, timer starts on the condition being true
This time condition is true when the comparator between
timer (as value_left) and the comparator's value_right is true
if comparator is a string, it should be "SUNSET" / "SUNRISE" / "DAY" / "NIGHT" / "AFTERNOON" / "MORNING"
else it should be built in the parent, and the value_right should be commeasurable (properly scaled)
"""
def __init__(self, agent, comparator, event=None):
super().__init__(agent)
self.special = None
self.event = event
if type(comparator) is str:
if comparator == "SUNSET":
self.special = build_special_time_condition(agent, 0.5, -1)
elif comparator == "SUNRISE":
self.special = build_special_time_condition(agent, 0.0, -1)
elif comparator == "MORNING":
self.special = build_special_time_condition(agent, 0, 0.25)
elif comparator == "AFTERNOON":
self.special = build_special_time_condition(agent, 0.25, 0.5)
elif comparator == "DAY":
self.special = build_special_time_condition(agent, 0.0, 0.5)
elif comparator == "NIGHT":
self.special = build_special_time_condition(agent, 0.5, 1.0)
else:
raise NotImplementedError("unknown special time condition type: " + comparator)
else:
if not event:
comparator.value_left = TimeValue(agent, mode="elapsed")
self.comparator = comparator
def check(self):
if not self.event:
return self.comparator.check()
else:
if self.event.check():
self.comparator.value_left = TimeValue(self.agent, mode="elapsed")
self.event = None
return self.comparator.check()
class Comparator(Condition):
def __init__(
self, agent, comparison_type="EQUAL", value_left=None, value_right=None, epsilon=0
):
super().__init__(agent)
self.comparison_type = comparison_type
self.value_left = value_left
self.value_right = value_right
self.epsilon = epsilon
# raise errors if no value left or right?
# raise errors if strings compared with > < etc.?
# FIXME handle type mismatches
# TODO less types, use NotCondition
# TODO MOD_EQUAL, MOD_CLOSE
def check(self):
value_left = self.value_left.get_value()
value_right = self.value_right.get_value()
if not self.value_left:
return False
if not value_right:
return False
if self.comparison_type == "GREATER_THAN_EQUAL":
return value_left >= value_right
elif self.comparison_type == "GREATER_THAN":
return value_left > value_right
elif self.comparison_type == "EQUAL":
return value_left == value_right
elif self.comparison_type == "NOT_EQUAL":
return value_left != value_right
elif self.comparison_type == "LESS_THAN":
return value_left < value_right
elif self.comparison_type == "CLOSE_TO":
return abs(value_left - value_right) <= self.epsilon
else:
# self.comparison_type == "LESS_THAN_EQUAL":
return value_left <= value_right
| craftassist-master | python/base_agent/condition.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import copy
import json
import logging
import os
import re
import spacy
from typing import Tuple, Dict, Optional
from glob import glob
import sentry_sdk
import preprocess
from base_agent.memory_nodes import ProgramNode
from base_agent.dialogue_manager import DialogueManager
from base_agent.dialogue_objects import (
BotCapabilities,
BotGreet,
DialogueObject,
Say,
coref_resolve,
process_spans,
)
from mcevent import sio
from post_process_logical_form import post_process_logical_form
###TODO wrap these, clean up
# For QA model
dirname = os.path.dirname(__file__)
web_app_filename = os.path.join(dirname, "../craftassist/webapp_data.json")
from base_util import hash_user
sp = spacy.load("en_core_web_sm")
class NSPDialogueManager(DialogueManager):
def __init__(self, agent, dialogue_object_classes, opts):
super(NSPDialogueManager, self).__init__(agent, None)
# "dialogue_object_classes" should be a dict with keys
# interpeter, get_memory, and put_memory;
# the values are the corresponding classes
self.dialogue_objects = dialogue_object_classes
self.QA_model = None
# the following are still scripted and are handled directly from here
self.botCapabilityQuery = [
"what can you do",
"what else can you do",
"what do you know",
"tell me what you can do",
"what things can you do",
"what are your capabilities",
"show me what you can do",
"what are you capable of",
"help me",
"help",
"do something",
]
safety_words_path = opts.ground_truth_data_dir + "safety.txt"
if os.path.isfile(safety_words_path):
self.safety_words = self.get_safety_words(safety_words_path)
else:
self.safety_words = []
# Load bot greetings
greetings_path = opts.ground_truth_data_dir + "greetings.json"
if os.path.isfile(greetings_path):
self.botGreetings = json.load(open(greetings_path))
else:
self.botGreetings = {"hello": ["hi", "hello", "hey"], "goodbye": ["bye"]}
logging.info("using QA_model_path={}".format(opts.QA_nsp_model_path))
logging.info("using model_dir={}".format(opts.nsp_model_dir))
# Instantiate the QA model
if opts.QA_nsp_model_path:
from ttad.ttad_model.ttad_model_wrapper import ActionDictBuilder
self.QA_model = ActionDictBuilder(
opts.QA_nsp_model_path,
embeddings_path=opts.nsp_embeddings_path,
action_tree_path=opts.nsp_grammar_path,
)
# Instantiate the main model
if opts.nsp_data_dir is not None:
from ttad.ttad_transformer_model.query_model import TTADBertModel as Model
self.model = Model(model_dir=opts.nsp_model_dir, data_dir=opts.nsp_data_dir)
self.debug_mode = False
# if web_app option is enabled
self.webapp_dict = {}
self.web_app = opts.web_app
if self.web_app:
logging.info("web_app flag has been enabled")
logging.info("writing to file: %r " % (web_app_filename))
# os.system("python ./python/craftassist/web_app_socket.py &")
# ground_truth_data is the ground truth action dict from templated
# generations and will be queried first if checked in.
self.ground_truth_actions = {}
if not opts.no_ground_truth:
if os.path.isdir(opts.ground_truth_data_dir):
files = glob(opts.ground_truth_data_dir + "datasets/*.txt")
for dataset in files:
with open(dataset) as f:
for line in f.readlines():
text, logical_form = line.strip().split("|")
clean_text = text.strip('"')
self.ground_truth_actions[clean_text] = json.loads(logical_form)
self.dialogue_object_parameters = {
"agent": self.agent,
"memory": self.agent.memory,
"dialogue_stack": self.dialogue_stack,
}
@sio.on("queryParser")
def query_parser(sid, data):
logging.info("inside query parser.....")
logging.info(data)
x = self.get_logical_form(s=data["chat"], model=self.model)
logging.info(x)
payload = {"action_dict": x}
sio.emit("render_parser_output", payload)
def add_to_dict(self, chat_message, action_dict): # , text):
print("adding %r dict for message : %r" % (action_dict, chat_message))
self.webapp_dict[chat_message] = {"action_dict": action_dict} # , "text": text}
with open(web_app_filename, "w") as f:
json.dump(self.webapp_dict, f)
def maybe_get_dialogue_obj(self, chat: Tuple[str, str]) -> Optional[DialogueObject]:
"""Process a chat and maybe modify the dialogue stack"""
if len(self.dialogue_stack) > 0 and self.dialogue_stack[-1].awaiting_response:
return None
# chat is a single line command
speaker, chatstr = chat
preprocessed_chatstrs = preprocess.preprocess_chat(chatstr)
# Push appropriate DialogueObjects to stack if incomign chat
# is one of the scripted ones
if any([chat in self.botCapabilityQuery for chat in preprocessed_chatstrs]):
return BotCapabilities(**self.dialogue_object_parameters)
for greeting_type in self.botGreetings:
if any([chat in self.botGreetings[greeting_type] for chat in preprocessed_chatstrs]):
return BotGreet(greeting_type, **self.dialogue_object_parameters)
# NOTE: preprocessing in model code is different, this shouldn't break anything
logical_form = self.get_logical_form(s=preprocessed_chatstrs[0], model=self.model)
return self.handle_logical_form(speaker, logical_form, preprocessed_chatstrs[0])
def handle_logical_form(self, speaker: str, d: Dict, chatstr: str) -> Optional[DialogueObject]:
"""Return the appropriate DialogueObject to handle an action dict "d"
"d" should have spans resolved by corefs not yet resolved to a specific
MemoryObject
"""
coref_resolve(self.agent.memory, d, chatstr)
logging.info('logical form post-coref "{}" -> {}'.format(hash_user(speaker), d))
ProgramNode.create(self.agent.memory, d)
if d["dialogue_type"] == "NOOP":
return Say("I don't know how to answer that.", **self.dialogue_object_parameters)
elif d["dialogue_type"] == "HUMAN_GIVE_COMMAND":
return self.dialogue_objects["interpreter"](
speaker, d, **self.dialogue_object_parameters
)
elif d["dialogue_type"] == "PUT_MEMORY":
return self.dialogue_objects["put_memory"](
speaker, d, **self.dialogue_object_parameters
)
elif d["dialogue_type"] == "GET_MEMORY":
logging.info("this model out: %r" % (d))
logging.info("querying QA model now")
if self.QA_model:
QA_model_d = self.get_logical_form(
s=chatstr, model=self.QA_model, chat_as_list=True
)
logging.info("QA model out: %r" % (QA_model_d))
if (
QA_model_d["dialogue_type"] != "GET_MEMORY"
): # this happens sometimes when new model sayas its an Answer action but previous says noop
return Say(
"I don't know how to answer that.", **self.dialogue_object_parameters
)
return self.dialogue_objects["get_memory"](
speaker, QA_model_d, **self.dialogue_object_parameters
)
else:
return self.dialogue_objects["get_memory"](
speaker, d, **self.dialogue_object_parameters
)
else:
raise ValueError("Bad dialogue_type={}".format(d["dialogue_type"]))
def get_logical_form(self, s: str, model, chat_as_list=False) -> Dict:
"""Query model to get the logical form"""
if s in self.ground_truth_actions:
d = self.ground_truth_actions[s]
logging.info('Found gt action for "{}"'.format(s))
else:
logging.info("Querying the semantic parsing model")
if chat_as_list:
d = model.parse([s])
else:
d = model.parse(chat=s) # self.ttad_model.parse(chat=s)
# perform lemmatization on the chat
logging.info('chat before lemmatization "{}"'.format(s))
lemmatized_chat = sp(s)
chat = " ".join(str(word.lemma_) for word in lemmatized_chat)
logging.info('chat after lemmatization "{}"'.format(chat))
# Get the words from indices in spans
process_spans(d, re.split(r" +", s), re.split(r" +", chat))
logging.info('ttad pre-coref "{}" -> {}'.format(chat, d))
# web app
if self.web_app:
# get adtt output
# t = ""
# try:
# t = adtt.adtt(d)
# except:
# t = ""
self.add_to_dict(chat_message=s, action_dict=d)
# log to sentry
sentry_sdk.capture_message(
json.dumps({"type": "ttad_pre_coref", "in_original": s, "out": d})
)
sentry_sdk.capture_message(
json.dumps({"type": "ttad_pre_coref", "in_lemmatized": chat, "out": d})
)
logging.info('logical form before grammar update "{}'.format(d))
d = post_process_logical_form(copy.deepcopy(d))
logging.info('logical form after grammar fix "{}"'.format(d))
return d
| craftassist-master | python/base_agent/nsp_dialogue_manager.py |
import uuid
import ast
from typing import Optional, List, Dict, cast
from base_util import XYZ, POINT_AT_TARGET, to_player_struct
from task import Task
class MemoryNode:
TABLE_COLUMNS = ["uuid"]
PROPERTIES_BLACKLIST = ["agent_memory", "forgetme"]
NODE_TYPE: Optional[str] = None
@classmethod
def new(cls, agent_memory, snapshot=False) -> str:
memid = uuid.uuid4().hex
t = agent_memory.get_time()
agent_memory._db_write(
"INSERT INTO Memories VALUES (?,?,?,?,?,?)", memid, cls.NODE_TYPE, t, t, t, snapshot
)
return memid
def __init__(self, agent_memory, memid: str):
self.agent_memory = agent_memory
self.memid = memid
def get_tags(self) -> List[str]:
return self.agent_memory.get_tags_by_memid(self.memid)
def get_properties(self) -> Dict[str, str]:
blacklist = self.PROPERTIES_BLACKLIST + self._more_properties_blacklist()
return {k: v for k, v in self.__dict__.items() if k not in blacklist}
def update_recently_attended(self) -> None:
self.agent_memory.set_memory_attended_time(self.memid)
self.snapshot(self.agent_memory)
def _more_properties_blacklist(self) -> List[str]:
"""Override in subclasses to add additional keys to the properties blacklist"""
return []
def snapshot(self, agent_memory):
"""Override in subclasses if necessary to properly snapshot."""
read_cmd = "SELECT "
for r in self.TABLE_COLUMNS:
read_cmd += r + ", "
read_cmd = read_cmd.strip(", ")
read_cmd += " FROM " + self.TABLE + " WHERE uuid=?"
data = agent_memory._db_read_one(read_cmd, self.memid)
if not data:
raise ("tried to snapshot nonexistent memory")
archive_memid = self.new(agent_memory, snapshot=True)
new_data = list(data)
new_data[0] = archive_memid
if hasattr(self, "ARCHIVE_TABLE"):
archive_table = self.ARCHIVE_TABLE
else:
archive_table = self.TABLE
write_cmd = "INSERT INTO " + archive_table + "("
qs = ""
for r in self.TABLE_COLUMNS:
write_cmd += r + ", "
qs += "?, "
write_cmd = write_cmd.strip(", ")
write_cmd += ") VALUES (" + qs.strip(", ") + ")"
agent_memory._db_write(write_cmd, *new_data)
link_archive_to_mem(agent_memory, self.memid, archive_memid)
def link_archive_to_mem(agent_memory, memid, archive_memid):
agent_memory.add_triple(subj=archive_memid, pred_text="_archive_of", obj=memid)
agent_memory.add_triple(subj=memid, pred_text="_has_archive", obj=archive_memid)
class ProgramNode(MemoryNode):
"""represents logical forms (outputs from the semantic parser)"""
TABLE_COLUMNS = ["uuid", "logical_form"]
TABLE = "Programs"
NODE_TYPE = "Program"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
text = self.agent_memory._db_read_one(
"SELECT logical_form FROM Programs WHERE uuid=?", self.memid
)
self.logical_form = ast.literal_eval(text)
@classmethod
def create(cls, memory, logical_form, snapshot=False) -> str:
memid = cls.new(memory, snapshot=snapshot)
memory._db_write(
"INSERT INTO Programs(uuid, logical_form) VALUES (?,?)", memid, format(logical_form)
)
return memid
class NamedAbstractionNode(MemoryNode):
"""a abstract concept with a name, to be used in triples"""
TABLE_COLUMNS = ["uuid", "name"]
TABLE = "NamedAbstractions"
NODE_TYPE = "NamedAbstraction"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
name = self.agent_memory._db_read_one(
"SELECT name FROM NamedAbstractions WHERE uuid=?", self.memid
)
self.name = name
@classmethod
def create(cls, memory, name, snapshot=False) -> str:
memid = memory._db_read_one("SELECT uuid FROM NamedAbstractions WHERE name=?", name)
if memid:
return memid[0]
memid = cls.new(memory, snapshot=snapshot)
memory._db_write("INSERT INTO NamedAbstractions(uuid, name) VALUES (?,?)", memid, name)
return memid
# the table entry just has the memid and a modification time,
# actual set elements are handled as triples
class SetNode(MemoryNode):
""" for representing sets of objects, so that it is easier to build complex relations
using RDF/triplestore format. is currently fetal- not used in main codebase yet """
TABLE_COLUMNS = ["uuid"]
TABLE = "SetMems"
NODE_TYPE = "Set"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
# FIXME put the member triples
@classmethod
def create(cls, memory, snapshot=False) -> str:
memid = cls.new(memory, snapshot=snapshot)
memory._db_write("INSERT INTO SetMems(uuid) VALUES (?)", memid, memory.get_time())
return memid
def get_members(self):
return self.agent_memory.get_triples(pred_text="set_member_", obj=self.memid)
def snapshot(self, agent_memory):
return SetNode.create(agent_memory, snapshot=True)
class ReferenceObjectNode(MemoryNode):
""" generic memory node for anything that has a spatial location and can be
used a spatial reference (e.g. to the left of the x)."""
TABLE = "ReferenceObjects"
NODE_TYPE = "ReferenceObject"
ARCHIVE_TABLE = "ArchivedReferenceObjects"
def get_pos(self) -> XYZ:
raise NotImplementedError("must be implemented in subclass")
def get_point_at_target(self) -> POINT_AT_TARGET:
raise NotImplementedError("must be implemented in subclass")
def get_bounds(self):
raise NotImplementedError("must be implemented in subclass")
class PlayerNode(ReferenceObjectNode):
""" represents humans and other agents that can affect the world """
TABLE_COLUMNS = ["uuid", "eid", "name", "x", "y", "z", "pitch", "yaw", "ref_type"]
NODE_TYPE = "Player"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
eid, name, x, y, z, pitch, yaw = self.agent_memory._db_read_one(
"SELECT eid, name, x, y, z, pitch, yaw FROM ReferenceObjects WHERE uuid=?", self.memid
)
self.eid = eid
self.name = name
self.pos = (x, y, z)
self.pitch = pitch
self.yaw = yaw
@classmethod
def create(cls, memory, player_struct) -> str:
memid = cls.new(memory)
memory._db_write(
"INSERT INTO ReferenceObjects(uuid, eid, name, x, y, z, pitch, yaw, ref_type) VALUES (?,?,?,?,?,?,?,?,?)",
memid,
player_struct.entityId,
player_struct.name,
player_struct.pos.x,
player_struct.pos.y,
player_struct.pos.z,
player_struct.look.pitch,
player_struct.look.yaw,
"player",
)
memory.tag(memid, "_player")
memory.tag(memid, "_physical_object")
memory.tag(memid, "_animate")
# this is a hack until memory_filters does "not"
memory.tag(memid, "_not_location")
return memid
@classmethod
def update(cls, memory, p, memid) -> str:
cmd = "UPDATE ReferenceObjects SET eid=?, name=?, x=?, y=?, z=?, pitch=?, yaw=? WHERE "
cmd = cmd + "uuid=?"
memory._db_write(
cmd, p.entityId, p.name, p.pos.x, p.pos.y, p.pos.z, p.look.pitch, p.look.yaw, memid
)
return memid
def get_pos(self) -> XYZ:
x, y, z = self.agent_memory._db_read_one(
"SELECT x, y, z FROM ReferenceObjects WHERE uuid=?", self.memid
)
self.pos = (x, y, z)
return self.pos
# TODO: use a smarter way to get point_at_target
def get_point_at_target(self) -> POINT_AT_TARGET:
x, y, z = self.pos
# use the block above the player as point_at_target
return cast(POINT_AT_TARGET, (x, y + 1, z, x, y + 1, z))
def get_bounds(self):
x, y, z = self.pos
return x, x, y, y, z, z
def get_struct(self):
return to_player_struct(self.pos, self.yaw, self.pitch, self.eid, self.name)
class SelfNode(PlayerNode):
"""special PLayerNode for representing the agent's self"""
TABLE_COLUMNS = ["uuid", "eid", "name", "x", "y", "z", "pitch", "yaw", "ref_type"]
NODE_TYPE = "Self"
# locations should always be archives?
class LocationNode(ReferenceObjectNode):
"""ReferenceObjectNode representing a raw location (a point in space) """
TABLE_COLUMNS = ["uuid", "x", "y", "z", "ref_type"]
NODE_TYPE = "Location"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
x, y, z = self.agent_memory._db_read_one(
"SELECT x, y, z FROM ReferenceObjects WHERE uuid=?", self.memid
)
self.location = (x, y, z)
self.pos = (x, y, z)
@classmethod
def create(cls, memory, xyz: XYZ) -> str:
memid = cls.new(memory)
memory._db_write(
"INSERT INTO ReferenceObjects(uuid, x, y, z, ref_type) VALUES (?, ?, ?, ?, ?)",
memid,
xyz[0],
xyz[1],
xyz[2],
"location",
)
return memid
def get_bounds(self):
x, y, z = self.pos
return x, x, y, y, z, z
def get_pos(self) -> XYZ:
return self.pos
def get_point_at_target(self) -> POINT_AT_TARGET:
x, y, z = self.pos
return cast(POINT_AT_TARGET, (x, y, z, x, y, z))
# locations should always be archives?
class AttentionNode(LocationNode):
"""ReferenceObjectNode representing spatial attention"""
TABLE_COLUMNS = ["uuid", "x", "y", "z", "type_name", "ref_type"]
NODE_TYPE = "Attention"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
# we use the type_name field to store whose attention it is
attender = self.agent_memory._db_read_one(
"SELECT type_name FROM ReferenceObjects WHERE uuid=?", self.memid
)
self.attender = attender
@classmethod
def create(cls, memory, xyz: XYZ, attender=None) -> str:
memid = cls.new(memory)
memory._db_write(
"INSERT INTO ReferenceObjects(uuid, x, y, z, type_name, ref_type) VALUES (?, ?, ?, ?, ?, ?)",
memid,
xyz[0],
xyz[1],
xyz[2],
attender,
"attention",
)
return memid
class TimeNode(MemoryNode):
"""represents a temporal 'location' """
TABLE_COLUMNS = ["uuid", "time"]
TABLE = "Times"
NODE_TYPE = "Time"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
t = self.agent_memory._db_read_one("SELECT time FROM Times WHERE uuid=?", self.memid)
self.time = t
@classmethod
def create(cls, memory, time: int) -> str:
memid = cls.new(memory)
memory._db_write("INSERT INTO Times(uuid, time) VALUES (?, ?)", memid, time)
return memid
class ChatNode(MemoryNode):
"""represents a chat/utterance from another agent/human """
TABLE_COLUMNS = ["uuid", "speaker", "chat", "time"]
TABLE = "Chats"
NODE_TYPE = "Time"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
speaker, chat_text, time = self.agent_memory._db_read_one(
"SELECT speaker, chat, time FROM Chats WHERE uuid=?", self.memid
)
self.speaker_id = speaker
self.chat_text = chat_text
self.time = time
@classmethod
def create(cls, memory, speaker: str, chat: str) -> str:
memid = cls.new(memory)
memory._db_write(
"INSERT INTO Chats(uuid, speaker, chat, time) VALUES (?, ?, ?, ?)",
memid,
speaker,
chat,
memory.get_time(),
)
return memid
class TaskNode(MemoryNode):
""" represents a task object that was placed on the agent's task_stack """
TABLE_COLUMNS = ["uuid", "action_name", "pickled", "paused", "created_at", "finished_at"]
TABLE = "Tasks"
NODE_TYPE = "Task"
def __init__(self, agent_memory, memid: str):
super().__init__(agent_memory, memid)
pickled, created_at, finished_at, action_name = self.agent_memory._db_read_one(
"SELECT pickled, created_at, finished_at, action_name FROM Tasks WHERE uuid=?", memid
)
self.task = self.agent_memory.safe_unpickle(pickled)
self.created_at = created_at
self.finished_at = finished_at
self.action_name = action_name
@classmethod
def create(cls, memory, task: Task) -> str:
memid = cls.new(memory)
task.memid = memid # FIXME: this shouldn't be necessary, merge Task and TaskNode?
memory._db_write(
"INSERT INTO Tasks (uuid, action_name, pickled, created_at) VALUES (?,?,?,?)",
memid,
task.__class__.__name__,
memory.safe_pickle(task),
memory.get_time(),
)
return memid
def get_chat(self) -> Optional[ChatNode]:
"""Return the memory of the chat that caused this task's creation, or None"""
triples = self.agent_memory.get_triples(pred_text="chat_effect_", obj=self.memid)
if triples:
chat_id, _, _ = triples[0]
return ChatNode(self.agent_memory, chat_id)
else:
return None
def get_parent_task(self) -> Optional["TaskNode"]:
"""Return the 'TaskNode' of the parent task, or None"""
triples = self.agent_memory.get_triples(subj=self.memid, pred_text="_has_parent_task")
if len(triples) == 0:
return None
elif len(triples) == 1:
_, _, parent_memid = triples[0]
return TaskNode(self.agent_memory, parent_memid)
else:
raise AssertionError("Task {} has multiple parents: {}".format(self.memid, triples))
def get_root_task(self) -> Optional["TaskNode"]:
mem = self
parent = self.get_parent_task()
while parent is not None:
mem = parent
parent = mem.get_parent_task()
return mem
def get_child_tasks(self) -> List["TaskNode"]:
"""Return tasks that were spawned beause of this task"""
r = self.agent_memory.get_triples(pred_text="_has_parent_task", obj=self.memid)
memids = [m for m, _, _ in r]
return [TaskNode(self.agent_memory, m) for m in memids]
def all_descendent_tasks(self, include_root=False) -> List["TaskNode"]:
"""Return a list of 'TaskNode' objects whose _has_parent_task root is this task
If include_root is True, include this node in the list.
Tasks are returned in the order they were finished.
"""
descendents = []
q = [self]
while q:
task = q.pop()
children = task.get_child_tasks()
descendents.extend(children)
q.extend(children)
if include_root:
descendents.append(self)
return sorted(descendents, key=lambda t: t.finished_at)
def __repr__(self):
return "<TaskNode: {}>".format(self.task)
# list of nodes to register in memory
NODELIST = [
TaskNode,
ChatNode,
LocationNode,
AttentionNode,
SetNode,
TimeNode,
PlayerNode,
SelfNode,
ProgramNode,
NamedAbstractionNode,
]
| craftassist-master | python/base_agent/memory_nodes.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
The current control flow of dialogue is:
1. A chat comes in and Dialogue manager reads it or the bot triggers a
dialogue because of memory/perception/task state
2. The dialogue manager puts a DialogueObject on the DialogueStack.
3. The DialogueStack calls .step() which in turn calls the DialogueObject.step()
that performs some action as implemented in the step method. The step could
also possibly interact with the agent's memory. And finally the step() makes
a call and decides if the DialogueObject is finished.
- The step() returns a string: maybe_chat, a dict: maybe_data.
- The step()'s outputs are read by the manager which can decide to put another
DialogueObject on the stack.
The maybe_data from the output of the dialogue object's step() can
contain a 'push' key; this overrides the manager's decision on what to push to
the stack.
Control flow for interpreter and clarification:
The interpreter is also a kind of DialogueObject, and a clarification step is
the interpreter returning control to the DialogueManager, which pushes a
ConfirmTask or ConfirmReferenceObject as a DialogueObject onto the DialogueStack.
The manager takes as an input: the agent and the model used for manager.
It creates a DialogueStack.
agent_mem, dialogue_stack, dialogue_object_data, where
dialogue_object_data is for explicit commands to force the manager to
return a specific Dialogue object to put on the stack.
"""
import logging
from typing import Tuple, Optional
from dialogue_stack import DialogueStack
from .dialogue_objects import DialogueObject, Say
class DialogueManager(object):
def __init__(self, agent, model):
self.agent = agent
self.dialogue_stack = DialogueStack(agent, agent.memory)
self.model = model
def get_safety_words(self, safety_words_path):
"""Read a list of safety words to prevent abuse."""
with open(safety_words_path) as f:
safety_lines = f.readlines()
safety_words = []
for l in safety_lines:
w = l.strip("\n").lower()
if w != "" and w[0] != "<" and w[0] != "#":
safety_words.append(w)
return safety_words
def is_safe(self, string):
safety_set = set(self.safety_words)
cmd_set = set(string.lower().split())
notsafe = len(cmd_set & safety_set) > 0
return not notsafe
# the dialogue manager model should access the task stack and chat history
# through the agent's memory, adding the most recent chat here as convenience
# maybe add a get_new_chat to memory and don't pass?
# chat is a (speaker, str) tuple
def step(self, chat: Tuple[str, str]):
# check safety
if not self.is_safe(chat[1]):
self.dialogue_stack.append_new(Say, "Please don't be rude.")
return
if chat[1]:
logging.info("Dialogue stack pre-run_model: {}".format(self.dialogue_stack.stack))
# NOTE: the model is responsible for not putting a new
# object on the stack if it sees that whatever is on
# the stack should continue.
# TODO: Maybe we need a HoldOn dialogue object?
obj = self.maybe_get_dialogue_obj(chat)
if obj is not None:
self.dialogue_stack.append(obj)
# Always call dialogue_stack.step(), even if chat is empty
if len(self.dialogue_stack) > 0:
self.dialogue_stack.step()
def maybe_get_dialogue_obj(self, chat: Tuple[str, str]) -> Optional[DialogueObject]:
raise NotImplementedError("Must implement maybe_get_dialogue_object in subclass")
| craftassist-master | python/base_agent/dialogue_manager.py |
import sys
import logging
import random
import re
import time
from core import BaseAgent
from base_util import hash_user
random.seed(0)
# a BaseAgent with:
# 1: a controller that is (mostly) a dialogue manager, and the dialogue manager
# is powered by a neural semantic parser.
# 2: has a turnable head, can point, and has basic locomotion
# 3: can send and receive chats
# this name is pathetic please help
class LocoMCAgent(BaseAgent):
def __init__(self, opts, name=None):
logging.info("Agent.__init__ started")
self.name = name or default_agent_name()
self.opts = opts
self.init_physical_interfaces()
super(LocoMCAgent, self).__init__(opts, name=self.name)
self.uncaught_error_count = 0
self.last_chat_time = 0
self.last_task_memid = None
self.areas_to_perceive = []
def init_physical_interfaces(self):
"""
should define or otherwise set up
(at least):
self.send_chat(),
movement primitives, including
self.look_at(x, y, z):
self.set_look(look):
self.point_at(...),
self.relative_head_pitch(angle)
...
"""
raise NotImplementedError
def init_perception(self):
"""
should define (at least):
self.get_pos()
self.get_incoming_chats()
and the perceptual modules that write to memory
all modules that should write to memory on a perceive() call
should be registered in self.perception_modules, and have
their own .perceive() fn
"""
raise NotImplementedError
def init_memory(self):
""" something like:
self.memory = memory.AgentMemory(
db_file=os.environ.get("DB_FILE", ":memory:"),
db_log_path="agent_memory.{}.log".format(self.name),
)
"""
raise NotImplementedError
def init_controller(self):
"""
dialogue_object_classes["interpreter"] = ....
dialogue_object_classes["get_memory"] = ....
dialogue_object_classes["put_memory"] = ....
self.dialogue_manager = NSPDialogueManager(self,
dialogue_object_classes,
self.opts)
logging.info("Initialized DialogueManager")
"""
raise NotImplementedError
def handle_exception(self, e):
logging.exception(
"Default handler caught exception, db_log_idx={}".format(self.memory.get_db_log_idx())
)
self.send_chat("Oops! I got confused and wasn't able to complete my last task :(")
self.memory.task_stack_clear()
self.dialogue_manager.dialogue_stack.clear()
self.uncaught_error_count += 1
if self.uncaught_error_count >= 100:
sys.exit(1)
def step(self):
if self.count == 0:
logging.info("First top-level step()")
super().step()
def task_step(self, sleep_time=0.25):
# Clean finished tasks
while (
self.memory.task_stack_peek() and self.memory.task_stack_peek().task.check_finished()
):
self.memory.task_stack_pop()
# If nothing to do, wait a moment
if self.memory.task_stack_peek() is None:
time.sleep(sleep_time)
return
# If something to do, step the topmost task
task_mem = self.memory.task_stack_peek()
if task_mem.memid != self.last_task_memid:
logging.info("Starting task {}".format(task_mem.task))
self.last_task_memid = task_mem.memid
task_mem.task.step(self)
self.memory.task_stack_update_task(task_mem.memid, task_mem.task)
def get_time(self):
# round to 100th of second, return as
# n hundreth of seconds since agent init
return self.memory.get_time()
def perceive(self, force=False):
for v in self.perception_modules.values():
v.perceive(force=force)
def controller_step(self):
"""Process incoming chats and modify task stack"""
raw_incoming_chats = self.get_incoming_chats()
if raw_incoming_chats:
# force to get objects
self.perceive(force=True)
logging.info("Incoming chats: {}".format(raw_incoming_chats))
incoming_chats = []
for raw_chat in raw_incoming_chats:
match = re.search("^<([^>]+)> (.*)", raw_chat)
if match is None:
logging.info("Ignoring chat: {}".format(raw_chat))
continue
speaker, chat = match.group(1), match.group(2)
speaker_hash = hash_user(speaker)
logging.info("Incoming chat: ['{}' -> {}]".format(speaker_hash, chat))
if chat.startswith("/"):
continue
incoming_chats.append((speaker, chat))
self.memory.add_chat(self.memory.get_player_by_name(speaker).memid, chat)
if len(incoming_chats) > 0:
# change this to memory.get_time() format?
self.last_chat_time = time.time()
# for now just process the first incoming chat
self.dialogue_manager.step(incoming_chats[0])
else:
self.dialogue_manager.step((None, ""))
def default_agent_name():
"""Use a unique name based on timestamp"""
return "bot.{}".format(str(time.time())[3:13])
| craftassist-master | python/base_agent/loco_mc_agent.py |
import copy
# move location inside reference_object for Fill and Destroy actions
def fix_fill_and_destroy_location(action_dict):
action_name = action_dict["action_type"]
if action_name in ["FILL", "DESTROY"]:
if "location" in action_dict:
if "reference_object" not in action_dict:
action_dict["reference_object"] = {}
action_dict["reference_object"]["location"] = action_dict["location"]
action_dict.pop("location")
return action_dict
# fix for location_type, adding them to reference object instead
def fix_location_type_in_location(d):
new_d = copy.deepcopy(d)
for key, value in d.items():
if key == "location_type":
if value in ["SPEAKER_LOOK", "AGENT_POS", "SPEAKER_POS", "COORDINATES"]:
# keep value the same for SPEAKER_LOOK, update for all others.
updated_value = value
if value == "AGENT_POS":
updated_value = "AGENT"
elif value == "SPEAKER_POS":
updated_value = "SPEAKER"
elif value == "COORDINATES":
updated_value = {"coordinates_span": d["coordinates"]}
# add to reference object instead
if "reference_object" in d:
if not new_d.get("filters"):
new_d["filters"] = []
new_d["reference_object"]["special_reference"] = updated_value
else:
new_d["reference_object"] = {"special_reference": updated_value}
new_d.pop(key)
new_d.pop("coordinates", None)
if type(value) == dict:
new_d[key] = fix_location_type_in_location(value)
return new_d
# fix reference object to have properties inside 'filters'
def fix_reference_object_with_filters(d):
new_d = copy.deepcopy(d)
for key, value in d.items():
if key in ["reference_object", "reference_object_1", "reference_object_2"]:
val = d[key]
if "repeat" in val:
new_d[key] = {"repeat": val["repeat"]}
val.pop("repeat")
new_d[key]["filters"] = val
elif "location" in val:
new_d[key] = fix_location_type_in_location(val)
else:
new_d[key] = {"filters": val}
if type(val) == dict:
new_d[key]["filters"] = fix_reference_object_with_filters(val)
elif type(value) == dict:
new_d[key] = fix_reference_object_with_filters(value)
return new_d
def post_process_logical_form(logical_form):
# since model is now updated
return logical_form
# TODO(kavya): Also post process PUT_MEMORY and GET_MEMORY
if logical_form["dialogue_type"] != "HUMAN_GIVE_COMMAND":
return logical_form
new_action_sequence = []
for action_dict in logical_form["action_sequence"]:
dict_with_fill_destroy_fix = fix_fill_and_destroy_location(action_dict)
dict_with_location_type_fix = fix_location_type_in_location(
copy.deepcopy(dict_with_fill_destroy_fix)
)
dict_with_filters_fix = fix_reference_object_with_filters(
copy.deepcopy(dict_with_location_type_fix)
)
new_action_sequence.append(dict_with_filters_fix)
logical_form["action_sequence"] = new_action_sequence
return logical_form
| craftassist-master | python/base_agent/post_process_logical_form.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# TODO rewrite functions in intepreter and helpers as classes
# finer granularity of (code) objects
# interpreter is an input to interpret ref object, maybe clean that up?
class ReferenceObjectInterpreter:
def __init__(self, interpret_reference_object):
self.interpret_reference_object = interpret_reference_object
def __call__(self, *args, **kwargs):
return self.interpret_reference_object(*args, **kwargs)
| craftassist-master | python/base_agent/dialogue_objects/reference_object_helpers.py |
from condition import (
LinearExtentValue,
LinearExtentAttribute,
FixedValue,
convert_comparison_value,
)
from base_util import ErrorWithResponse, number_from_span
from base_agent.memory_nodes import ReferenceObjectNode
from dialogue_object_utils import tags_from_dict
def interpret_span_value(interpreter, speaker, d, comparison_measure=None):
num = number_from_span(d)
if num:
v = FixedValue(interpreter.agent, num)
# always convert everything to internal units
# FIXME handle this better
v = convert_comparison_value(v, comparison_measure)
else:
v = FixedValue(interpreter.agent, d)
return v
def maybe_specific_mem(interpreter, speaker, ref_obj_d):
mem = None
search_data = None
if ref_obj_d.get("special_reference"):
# this is a special ref object, not filters....
cands = interpreter.subinterpret["reference_objects"](interpreter, speaker, ref_obj_d)
return cands[0], None
filters_d = ref_obj_d.get("filters", {})
coref = filters_d.get("contains_coreference")
if coref != "NULL":
# this is a particular entity etc, don't search for the mem at check() time
if isinstance(coref, ReferenceObjectNode):
mem = coref
else:
cands = interpreter.subinterpret["reference_objects"](interpreter, speaker, ref_obj_d)
if not cands:
# FIXME fix this error
raise ErrorWithResponse("I don't know which objects attribute you are talking about")
# TODO if more than one? ask?
else:
mem = cands[0]
else:
# this object is only defined by the filters and might be different at different moments
tags = tags_from_dict(filters_d)
# make a function, reuse code with get_reference_objects FIXME
search_data = [{"pred_text": "has_tag", "obj_text": tag} for tag in tags]
return mem, search_data
def interpret_linear_extent(interpreter, speaker, d, force_value=False):
location_data = {}
default_frame = getattr(interpreter.agent, "default_frame") or "AGENT"
frame = d.get("frame", default_frame)
if frame == "SPEAKER":
frame = speaker
if type(frame) is dict:
frame = frame.get("player_span", "unknown_player")
if frame == "AGENT":
location_data["frame"] = "AGENT"
else:
p = interpreter.agent.memory.get_player_by_name(frame)
if p:
location_data["frame"] = p.eid
else:
raise ErrorWithResponse("I don't understand in whose frame of reference you mean")
location_data["relative_direction"] = d.get("relative_direction", "AWAY")
# FIXME!!!! has_measure
rd = d.get("source")
fixed_role = "source"
if not rd:
rd = d.get("destination")
fixed_role = "destination"
mem, sd = maybe_specific_mem(interpreter, speaker, rd)
L = LinearExtentAttribute(interpreter.agent, location_data, mem=mem, fixed_role=fixed_role)
# TODO some sort of sanity check here, these should be rare:
if (d.get("source") and d.get("destination")) or force_value:
rd = d.get("destination")
mem = None
sd = None
if rd:
mem, sd = maybe_specific_mem(interpreter, speaker, rd["filters"])
L = LinearExtentValue(interpreter.agent, L, mem=mem, search_data=sd)
return L
| craftassist-master | python/base_agent/dialogue_objects/attribute_helper.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import logging
import numpy as np
import random
from string_lists import MAP_YES, MAP_NO
from base_util import pos_to_np
from enum import Enum
class DialogueObject(object):
def __init__(self, agent, memory, dialogue_stack, featurizer=None, max_steps=50):
self.agent = agent
self.memory = memory
self.dialogue_stack = dialogue_stack
self.featurizer = featurizer
self.finished = False
self.awaiting_response = False
self.max_steps = max_steps # finish after this many steps to avoid getting stuck
self.current_step = 0
self.progeny_data = (
[]
) # this should have more structure and some methods for adding/accessing?
def step(self):
raise NotImplementedError("Subclasses must implement step()")
def update_progeny_data(self, data):
self.progeny_data.append(data)
def check_finished(self):
"""Check if the object is finished processing."""
self.current_step += 1
if self.current_step == self.max_steps:
logging.error("Stepped {} {} times, finishing".format(self, self.max_steps))
self.finished = True
return self.finished
def featurize(self):
if self.featurizer is not None:
return self.featurizer(self)
else:
return "empty"
def __repr__(self):
return str(type(self))
"""This class represents a sub-type of DialogueObject to await
a response from the user."""
# TODO check who is speaking
class AwaitResponse(DialogueObject):
def __init__(self, wait_time=800, **kwargs):
super().__init__(**kwargs)
self.init_time = self.memory.get_time()
self.response = []
self.wait_time = wait_time
self.awaiting_response = True
def step(self):
"""Wait for wait_time for an answer. Mark finished when a chat comes in."""
chatmem = self.memory.get_most_recent_incoming_chat(after=self.init_time + 1)
if chatmem is not None:
self.finished = True
return "", {"response": chatmem}
if self.memory.get_time() - self.init_time > self.wait_time:
self.finished = True
# FIXME this shouldn't return data
return "Okay! I'll stop waiting for you to answer that.", {"response": None}
return "", None
"""This class represents a sub-type of DialogueObject to say / send a chat
to the user."""
class Say(DialogueObject):
def __init__(self, response_options, **kwargs):
super().__init__(**kwargs)
if len(response_options) == 0:
raise ValueError("Cannot init a Say with no response options")
if type(response_options) is str:
self.response_options = [response_options]
else:
self.response_options = response_options
def step(self):
"""Return one of the response_options."""
self.finished = True
return random.choice(self.response_options), None
"""This class represents a sub-type of the Say DialogueObject above to answer
something about the current capabilities of the bot, to the user."""
class BotCapabilities(Say):
def __init__(self, **kwargs):
response_options = [
'Try looking at something and tell me "go there"',
'Try looking at a structure and tell me "destroy that"',
'Try looking somewhere and tell me "build a wall there"',
"Try building something and giving it a name",
"Try naming something and telling me to build it",
]
super().__init__(response_options, **kwargs)
"""Types of bot greetings."""
class GreetingType(Enum):
HELLO = "hello"
GOODBYE = "goodbye"
"""This class represents a sub-type of the Say DialogueObject above to greet
the user as a reply to a greeting."""
class BotGreet(Say):
def __init__(self, greeting_type, **kwargs):
if greeting_type == GreetingType.GOODBYE.value:
response_options = ["goodbye", "bye", "see you next time!"]
else:
response_options = ["hi there!", "hello", "hey", "hi"]
super().__init__(response_options, **kwargs)
"""This class represents a sub-type of the DialogueObject to answer
questions about the current status of the bot, to the user."""
class BotStackStatus(DialogueObject):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.ing_mapping = {
"Build": "building",
"Destroy": "excavating",
"Dig": "digging",
"Move": "moving",
}
def step(self):
"""return the current task name status."""
self.finished = True
task_mem = self.memory.task_stack_find_lowest_instance(list(self.ing_mapping.keys()))
if task_mem is None:
answer_options = [
"Idle. You can tell me what to do!",
"I am doing nothing.",
"Nothing. Waiting for your command.",
]
else:
doing = self.ing_mapping[task_mem.task.__class__.__name__]
answer_options = ["I am " + doing, doing]
return random.choice(answer_options), None
"""This class represents a sub-type of the DialogueObject to register feedback /
reward given by the user in the form of chat."""
class GetReward(DialogueObject):
def step(self):
"""associate pos / neg reward to chat memory."""
self.finished = True
chatmem = self.memory.get_most_recent_incoming_chat()
if chatmem.chat_text in [
"that is wrong",
"that was wrong",
"that was completely wrong",
"not that",
"that looks horrible",
"that is not what i asked",
"that is not what i told you to do",
"that is not what i asked for" "not what i told you to do",
"you failed",
"failure",
"fail",
"not what i asked for",
]:
self.memory.tag(chatmem.memid, "neg_reward")
# should probably tag recent actions too? not just the text of the chat
elif chatmem.chat_text in [
"good job",
"that is really cool",
"that is awesome",
"awesome",
"that is amazing",
"that looks good",
"you did well",
"great",
"good",
"nice",
]:
self.memory.tag(chatmem.memid, "pos_reward")
return "Thanks for letting me know.", None
"""This class represents a sub-type of the DialogueObject to answer questions
about the current location of the bot."""
class BotLocationStatus(DialogueObject):
def step(self):
"""Extract bot's current location."""
self.finished = True
# Get the agent's current location
agent_pos = pos_to_np(self.agent.get_player().pos)
agent_coordinates = " , ".join([str(pos) for pos in agent_pos])
answer_options = [
"I am here at location : %r" % (agent_coordinates),
"I am standing at : %r" % (agent_coordinates),
"I am at : %r" % (agent_coordinates),
]
return random.choice(answer_options), None
"""This class represents a sub-type of the DialogueObject to answer questions
about where the bot is heading."""
class BotMoveStatus(DialogueObject):
def step(self):
"""Extract bot's target coordinates."""
self.finished = True
task = self.memory.task_stack_find_lowest_instance("Move")
if task is None:
answer_options = [
"I am not going anywhere",
"I am not heading anywhere",
"I am not off to anywhere",
]
else:
target_coordinates = " , ".join([str(pos) for pos in task.target])
answer_options = [
"I am heading to location : %r" % (target_coordinates),
"I am walking over to : %r" % (target_coordinates),
"I am moving to : %r" % (target_coordinates),
]
return random.choice(answer_options), None
"""This class represents a sub-type of the DialogueObject to ask a clarification
question about something."""
class ConfirmTask(DialogueObject):
def __init__(self, question, tasks, **kwargs):
super().__init__(**kwargs)
self.question = question # chat text that will be sent to user
self.tasks = tasks # list of Task objects, will be pushed in order
self.asked = False
def step(self):
"""Ask a confirmation question and wait for response."""
# Step 1: ask the question
if not self.asked:
self.dialogue_stack.append_new(AwaitResponse)
self.dialogue_stack.append_new(Say, self.question)
self.asked = True
return "", None
# Step 2: check the response and add the task if necessary
self.finished = True
if len(self.progeny_data) == 0:
return None, None
if hasattr(self.progeny_data[-1]["response"], "chat_text"):
response_str = self.progeny_data[-1]["response"].chat_text
else:
response_str = "UNK"
if response_str in MAP_YES:
for task in self.tasks:
self.memory.task_stack_push(task)
return None, None
"""This class represents a sub-type of the DialogueObject to confirm if the
reference object is correct."""
class ConfirmReferenceObject(DialogueObject):
def __init__(self, reference_object, **kwargs):
super().__init__(**kwargs)
r = reference_object
if hasattr(r, "get_point_at_target"):
self.bounds = r.get_point_at_target()
else:
# this should be an error
self.bounds = tuple(np.min(r, axis=0)) + tuple(np.max(r, axis=0))
self.pointed = False
self.asked = False
def step(self):
"""Confirm the block object by pointing and wait for answer."""
if not self.asked:
self.dialogue_stack.append_new(Say, "do you mean this?")
self.asked = True
return "", None
if not self.pointed:
self.agent.point_at(self.bounds)
self.dialogue_stack.append_new(AwaitResponse)
self.pointed = True
return "", None
self.finished = True
if len(self.progeny_data) == 0:
output_data = None
else:
if hasattr(self.progeny_data[-1]["response"], "chat_text"):
response_str = self.progeny_data[-1]["response"].chat_text
else:
response_str = "UNK"
if response_str in MAP_YES:
output_data = {"response": "yes"}
elif response_str in MAP_NO:
output_data = {"response": "no"}
else:
output_data = {"response": "unkown"}
return "", output_data
| craftassist-master | python/base_agent/dialogue_objects/dialogue_object.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
from dialogue_object import (
AwaitResponse,
BotCapabilities,
BotGreet,
BotLocationStatus,
BotStackStatus,
DialogueObject,
GetReward,
ConfirmTask,
ConfirmReferenceObject,
Say,
)
from dialogue_object_utils import (
SPEAKERLOOK,
SPEAKERPOS,
AGENTPOS,
is_loc_speakerlook,
process_spans,
coref_resolve,
tags_from_dict,
strip_prefix,
)
from reference_object_helpers import ReferenceObjectInterpreter
from condition_helper import ConditionInterpreter
__all__ = [
AwaitResponse,
BotCapabilities,
BotGreet,
BotLocationStatus,
BotStackStatus,
DialogueObject,
GetReward,
ConfirmTask,
ConfirmReferenceObject,
Say,
SPEAKERLOOK,
SPEAKERPOS,
AGENTPOS,
is_loc_speakerlook,
coref_resolve,
process_spans,
tags_from_dict,
strip_prefix,
ReferenceObjectInterpreter,
ConditionInterpreter,
]
| craftassist-master | python/base_agent/dialogue_objects/__init__.py |
from typing import Optional
from base_util import ErrorWithResponse
from condition import (
Condition,
NeverCondition,
AndCondition,
OrCondition,
Comparator,
MemoryColumnValue,
FixedValue,
TimeCondition,
TableColumn,
)
from attribute_helper import interpret_linear_extent, interpret_span_value, maybe_specific_mem
class ConditionInterpreter:
def __init__(self):
# extra layer of indirection to allow easier split into base_agent and specialized agent conditions...
self.condition_types = {
"NEVER": self.interpret_never,
"AND": self.interpret_and,
"OR": self.interpret_or,
"TIME": self.interpret_time,
"COMPARATOR": self.interpret_comparator,
}
# to avoid having to redefine interpret_comparator in agents if necessary ...
# TODO distance between
self.value_extractors = {
"filters": MemoryColumnValue,
"span": FixedValue,
"distance_between": None,
}
def __call__(self, interpreter, speaker, d) -> Optional[Condition]:
ct = d.get("condition_type")
if ct:
if self.condition_types.get(ct):
# condition_type NEVER doesn't have a "condition" sibling
if ct == "NEVER":
return self.condition_types[ct](interpreter, speaker, d)
if not d.get("condition"):
raise ErrorWithResponse(
"I thought there was a condition but I don't understand it"
)
return self.condition_types[ct](interpreter, speaker, d["condition"])
else:
raise ErrorWithResponse("I don't understand that condition")
else:
return None
def interpret_never(self, interpreter, speaker, d) -> Optional[Condition]:
return NeverCondition(interpreter.agent)
def interpret_or(self, interpreter, speaker, d) -> Optional[Condition]:
orlist = d["or_condition"]
conds = []
for c in orlist:
new_condition = self(interpreter, speaker, d)
if new_condition:
conds.append(new_condition)
return OrCondition(interpreter.agent, conds)
def interpret_and(self, interpreter, speaker, d) -> Optional[Condition]:
orlist = d["and_condition"]
conds = []
for c in orlist:
new_condition = self(interpreter, speaker, d)
if new_condition:
conds.append(new_condition)
return AndCondition(interpreter.agent, conds)
def interpret_time(self, interpreter, speaker, d):
event = None
if d.get("special_time_event"):
return TimeCondition(interpreter.agent, d["special_time_event"])
else:
if not d.get("comparator"):
raise ErrorWithResponse("I don't know how to interpret this time condition")
dc = d["comparator"]
dc["input_left"] = {"value_extractor": "NULL"}
comparator = self.interpret_comparator(interpreter, speaker, dc)
if d.get("event"):
event = self(interpreter, speaker, d["event"])
return TimeCondition(interpreter.agent, comparator, event=event)
# TODO distance between
# TODO make this more modular. what if we want to redefine just distance_between in a new agent?
def interpret_comparator(self, interpreter, speaker, d):
input_left_d = d.get("input_left")
input_right_d = d.get("input_right")
if (not input_right_d) or (not input_left_d):
return None
value_extractors = {}
for inp_pos in ["input_left", "input_right"]:
inp = d[inp_pos]["value_extractor"]
if type(inp) is str:
if inp == "NULL":
value_extractors[inp_pos] = None
else:
# this is a span
cm = d.get("comparison_measure")
v = interpret_span_value(interpreter, speaker, inp, comparison_measure=cm)
value_extractors[inp_pos] = v
elif inp.get("output"):
# this is a filter
# TODO FIXME! deal with count
# TODO logical form etc.?
a = inp["output"]["attribute"]
if type(a) is str:
search_data = {"attribute": TableColumn(interpreter.agent, a)}
elif a.get("linear_extent"):
search_data = {
"attribute": interpret_linear_extent(
interpreter, speaker, a["linear_extent"]
)
}
mem, sd = maybe_specific_mem(interpreter, speaker, {"filters": inp})
if sd:
for k, v in sd.items():
search_data[k] = v
# TODO wrap this in a ScaledValue using condtition.convert_comparison_value
# and "comparison_measure"
value_extractors[inp_pos] = MemoryColumnValue(
interpreter.agent, search_data, mem=mem
)
else:
raise ErrorWithResponse(
"I don't know understand that condition, looks like a comparator but value is not filters or span"
)
comparison_type = d.get("comparison_type")
if not comparison_type:
ErrorWithResponse(
"I think you want me to compare two things in a condition, but am not sure what type of comparison"
)
return Comparator(
interpreter.agent,
value_left=value_extractors["input_left"],
value_right=value_extractors["input_right"],
comparison_type=comparison_type,
)
# TODO not
| craftassist-master | python/base_agent/dialogue_objects/condition_helper.py |
from copy import deepcopy
SPEAKERLOOK = {"reference_object": {"special_reference": "SPEAKER_LOOK"}}
SPEAKERPOS = {"reference_object": {"special_reference": "SPEAKER"}}
AGENTPOS = {"reference_object": {"special_reference": "AGENT"}}
def strip_prefix(s, pre):
if s.startswith(pre):
return s[len(pre) :]
return s
# FIXME!? maybe start using triples appropriately now?
def tags_from_dict(d):
return [
strip_prefix(tag, "the ")
for key, tag in d.items()
if key.startswith("has_") and isinstance(tag, str)
]
def is_loc_speakerlook(d):
# checks a location dict to see if it is SPEAKER_LOOK
r = d.get("reference_object")
if r and r.get("special_reference"):
if r["special_reference"] == "SPEAKER_LOOK":
return True
return False
def process_spans(d, original_words, lemmatized_words):
if type(d) is not dict:
return
for k, v in d.items():
if type(v) == dict:
process_spans(v, original_words, lemmatized_words)
elif type(v) == list and type(v[0]) == dict:
for a in v:
process_spans(a, original_words, lemmatized_words)
else:
try:
sentence, (L, R) = v
if sentence != 0:
raise NotImplementedError("Must update process_spans for multi-string inputs")
assert 0 <= L <= R <= (len(lemmatized_words) - 1)
except ValueError:
continue
except TypeError:
continue
original_w = " ".join(original_words[L : (R + 1)])
# The lemmatizer converts 'it' to -PRON-
if original_w == "it":
d[k] = original_w
else:
d[k] = " ".join(lemmatized_words[L : (R + 1)])
#####FIXME!!!
# this is bad
# and
# in addition to being bad, abstraction is leaking
def coref_resolve(memory, d, chat):
"""Walk logical form "d" and replace coref_resolve values
Possible substitutions:
- a subdict lik SPEAKERPOS
- a MemoryNode object
- "NULL"
Assumes spans have been substituted.
"""
c = chat.split()
if not type(d) is dict:
return
for k, v in d.items():
if type(v) == dict:
coref_resolve(memory, v, chat)
if type(v) == list:
for a in v:
coref_resolve(memory, a, chat)
v_copy = v
if k == "location":
# v is a location dict
for k_ in v:
if k_ == "contains_coreference":
v_copy = deepcopy(v)
val = SPEAKERPOS if "here" in c else SPEAKERLOOK
v_copy["reference_object"] = val["reference_object"]
v_copy["contains_coreference"] = "resolved"
d[k] = v_copy
elif k == "filters":
# v is a reference object dict
for k_ in v:
if k_ == "contains_coreference":
v_copy = deepcopy(v)
if "this" in c or "that" in c:
v_copy["location"] = SPEAKERLOOK
v_copy["contains_coreference"] = "resolved"
else:
mems = memory.get_recent_entities("BlockObject")
if len(mems) == 0:
mems = memory.get_recent_entities(
"Mob"
) # if its a follow, this should be first, FIXME
if len(mems) == 0:
v_copy[k_] = "NULL"
else:
v_copy[k_] = mems[0]
else:
v_copy[k_] = mems[0]
d[k] = v_copy
# fix/delete this branch! its for old broken spec
else:
for k_ in v:
if k_ == "contains_coreference":
v_copy = deepcopy(v)
if "this" in c or "that" in c:
v_copy["location"] = SPEAKERLOOK
v_copy["contains_coreference"] = "resolved"
d[k] = v_copy
if __name__ == "__main__":
x = eval(
"{'dialogue_type': 'PUT_MEMORY', 'filters': {'reference_object':{'contains_coreference': 'yes'}}, 'upsert': {'memory_data': {'memory_type': 'TRIPLE', 'has_tag': 'j'}}}"
)
y = coref_resolve(None, x, "that is a j")
| craftassist-master | python/base_agent/dialogue_objects/dialogue_object_utils.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file has the definitions and properties of the components that go into the
action tree.
Following is a list of component nodes:
- Schematic, that can be of type:
- CategoryObject
- Shape, that can be of type:
- BlockShape
- RectanguloidShape
- HollowRectanguloidShape
- CubeShape
- HollowCubeShape
- SphereShape
- HollowSphereShape
- PyramidShape
- RectangleShape
- SquareShape
- TriangleShape
- CircleShape
- DiskShape
- EllipsoidShape
- DomeShape
- ArchShape
- TowerShape
- Location, that can be of type:
- Coordinates
- LocationDelta
- SpeakerLook
- SpeakerPos
- AgentPos
- BlockObject, that can be of type:
- Object
- PointedObject
- Mob
"""
import os
import random
from collections import OrderedDict
from generate_utils import *
SUBCOMPONENT_LABELS = [
"wall",
"roof",
"window",
"foundation",
"door",
"floor",
"ceiling",
"siding",
"column",
"porch",
"entrance",
"corner",
"balcony",
"railing",
"decoration",
"support",
"base",
"pillar",
"beam",
"step",
"ledge",
"fence",
"facade",
"overhang",
"footing",
"walkway",
"stairs",
"basement",
"chimney",
"doorway",
"cornerstone",
"deck",
"side",
"eave",
"sill",
"patio",
"frame",
"steps",
"windowsill",
"post",
"header",
"pane",
"ridge",
"roofing",
"awning",
"rooftop",
"trim",
"stair",
"gable",
"garden",
"light",
"brick",
"edge",
"fascia",
"entryway",
"gutter",
"platform",
"panel",
"foot",
"ground",
"trap",
"frontage",
"storage",
"torch",
"crawlspace",
"soffit",
"eaves",
"tower",
"parapet",
"jamb",
"attic",
"staircase",
"skylight",
"barrier",
"glass",
"terrace",
"room",
"doorstep",
"pier",
"ladder",
"bedroom",
"cladding",
"partition",
"kitchen",
"doorknob",
"stairway",
"opening",
"shutter",
"exterior",
"strut",
"garage",
"glazing",
"shingles",
"stoop",
"yard",
"sidewalk",
"rail",
"casing",
"substructure",
"paneling",
]
MOBS = [
"elder guardian",
"wither skeleton",
"stray",
"husk",
"zombie villager",
"skeleton horse",
"zombie horse",
"donkey",
"mule",
"evoker",
"vex",
"vindicator",
"creeper",
"skeleton",
"spider",
"zombie",
"slime",
"ghast",
"zombie pigman",
"enderman",
"cave spider",
"silverfish",
"blaze",
"magma cube",
"bat",
"witch",
"endermite",
"guardian",
"pig",
"sheep",
"cow",
"chicken",
"squid",
"mooshroom",
"horse",
"rabbit",
"polar bear",
"llama",
"parrot",
"villager",
"ocelot",
"wolf",
"shulker",
]
BLOCK_TYPES = [
"air",
"stone",
"granite",
"polished granite",
"diorite",
"polished diorite",
"andesite",
"polished andesite",
"dirt",
"coarse dirt",
"podzol",
"cobblestone",
"oak wood plank",
"spruce wood plank",
"birch wood plank",
"jungle wood plank",
"acacia wood plank",
"dark oak wood plank",
"oak sapling",
"spruce sapling",
"birch sapling",
"jungle sapling",
"acacia sapling",
"dark oak sapling",
"bedrock",
"flowing water",
"still water",
"flowing lava",
"still lava",
"sand",
"red sand",
"gravel",
"gold ore",
"iron ore",
"coal ore",
"oak wood",
"spruce wood",
"birch wood",
"jungle wood",
"oak leaves",
"spruce leaves",
"birch leaves",
"jungle leaves",
"sponge",
"wet sponge",
"glass",
"lapis lazuli ore",
"lapis lazuli block",
"dispenser",
"sandstone",
"chiseled sandstone",
"smooth sandstone",
]
ABSTRACT_SIZE = [
"really tiny",
"very tiny",
"tiny",
"really small",
"very small",
"really little",
"very little",
"small",
"little",
"medium",
"medium sized",
"big",
"large",
"really big",
"very big",
"really large",
"very large",
"huge",
"gigantic",
"really huge",
"very huge",
"really gigantic",
"very gigantic",
]
COLOURS = ["red", "blue", "green", "yellow", "purple", "grey", "brown", "black", "orange"]
with open(os.path.join(os.path.dirname(__file__), "categories.txt")) as f:
CATEGORIES = [line.strip() for line in f.readlines()] + SUBCOMPONENT_LABELS
SHAPE_NAMES = [
"box",
"rectanguloid",
"cube",
"empty box",
"hollow box",
"hollow rectanguloid",
"cube",
"empty cube",
"hollow cube",
"ball",
"sphere",
"dome",
"empty sphere",
"empty ball",
"hollow ball",
"spherical shell",
"hollow sphere",
"pyramid",
"rectangle",
"square",
"triangle",
"circle",
"disk",
"ellipsoid",
"dome",
"arch",
"tower",
"wall",
"platform",
"slab",
]
CONCRETE_OBJECT_NAMES = SHAPE_NAMES + SUBCOMPONENT_LABELS + CATEGORIES
CONDITION_TYPES = ["ADJACENT_TO_BLOCK_TYPE", "NEVER"]
class ComponentNode:
"""This class is a node in the action tree and represents the components of the
tree that are not Actions.
A node can have a list of node types, it can be (CHOICES).
generate() : is responsible for initializing the CHOICES.
generate_description() : Generates the natural language description.
to_dict() : Generates the action tree recursively over the children.
"""
CHOICES = None # a list of node types that can be substituted for this node
def __init__(self, template_attr={}):
self.args = None # populated by self.generate()
self.description = None # populated by self.generate_description()
self._action_description = None
self._template_attr = template_attr
def generate_description(self):
if self.description is None:
self.description = self._generate_description()
return self.description
@classmethod
def generate(cls):
if cls.CHOICES:
c = random.choice(cls.CHOICES)
return c.generate()
return cls()
def __repr__(self):
if self.args:
return "<{} ({})>".format(type(self).__name__, ", ".join(map(str, self.args)))
else:
return "<{}>".format(type(self).__name__)
def to_dict(self):
d = {}
if hasattr(self, "location_type") and type(self.location_type) == type:
self.location_type = to_snake_case(self.location_type.__name__, case="upper")
if self.location_type in ["BLOCK_OBJECT", "MOB"]:
self.location_type = "REFERENCE_OBJECT"
# For each recursive child, pass along the description of topmost action.
if getattr(self, "_location", None) is not None:
self._location._action_description = self._action_description
d["location"] = self._location.to_dict()
if getattr(self, "_reference_object", None) is not None:
self._reference_object._action_description = self._action_description
d["reference_object"] = self._reference_object.to_dict()
if getattr(self, "_block_object", None) is not None:
self._block_object._action_description = self._action_description
d["reference_object"] = self._block_object.to_dict()
if getattr(self, "_block_object_1", None) is not None:
self._block_object_1._action_description = self._action_description
d["reference_object_1"] = self._block_object_1.to_dict()
if getattr(self, "_block_object_2", None) is not None:
self._block_object_2._action_description = self._action_description
d["reference_object_2"] = self._block_object_2.to_dict()
if getattr(self, "_repeat", None):
self._repeat._action_description = self._action_description
# For between or any repeats that only need plural of names
# don't add repeat dict
if self._repeat.to_dict()["repeat_key"] != "ALL_ONLY":
d["repeat"] = self._repeat.to_dict()
if getattr(self, "_mob", None) is not None:
self._mob._action_description = self._action_description
d["reference_object"] = self._mob.to_dict()
if getattr(self, "_mob_1", None) is not None:
self._mob_1._action_description = self._action_description
d["reference_object_1"] = self._mob_1.to_dict()
if getattr(self, "_mob_2", None) is not None:
self._mob_2._action_description = self._action_description
d["reference_object_2"] = self._mob_2.to_dict()
# fix reference object filters
for key in ["reference_object", "reference_object_1", "reference_object_2"]:
if key in d:
val = d[key]
if "repeat" in val:
d[key] = {"repeat": val["repeat"]}
val.pop("repeat")
d[key]["filters"] = val
else:
d[key] = {"filters": val}
if getattr(self, "_memory_data", None) is not None:
self._memory_data._action_description = self._action_description
d["memory_data"] = self._memory_data.to_dict()
for attr, val in self.__dict__.items():
if (
not attr.startswith("_")
and val not in (None, "")
and attr != "args"
and attr != "description"
and attr != "template"
):
d[attr] = val
if (attr.startswith("has_")) or (
attr
in ["coordinates", "steps", "block_type", "repeat_count", "target_action_type"]
):
span = find_span(self._action_description, val)
d[attr] = span
# fix location type now
if "location_type" in d:
value = d["location_type"]
if value in ["SPEAKER_LOOK", "AGENT_POS", "SPEAKER_POS", "COORDINATES"]:
updated_value = value # same for coordinates and speaker_look
if value == "AGENT_POS":
updated_value = "AGENT"
elif value == "SPEAKER_POS":
updated_value = "SPEAKER"
elif value == "COORDINATES":
updated_value = {"coordinates_span": d["coordinates"]}
# add to reference object instead
if "reference_object" in d:
d["reference_object"]["special_reference"] = updated_value
else:
d["reference_object"] = {"special_reference": updated_value}
d.pop("location_type")
d.pop("coordinates", None)
return d
###############
## SCHEMATIC ##
###############
class CategoryObject(ComponentNode):
"""CategoryObject is picked from a list of objects we have from the
minecraft_specs folder.
__init__ (): Pick the object, assign name and block_type.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(template_attr=template_attr)
cat_object = random.choice(self._template_attr.get("non_shape_names", CATEGORIES))
if repeat_key:
cat_object = make_plural(cat_object)
self.has_name = cat_object
self.has_block_type = (
random.choice(self._template_attr.get("block_types", BLOCK_TYPES))
if block_type
else None
)
def _generate_description(self):
out_dict = {}
out_dict["word"] = self.has_name
if self.has_block_type:
out_dict["block_type"] = self.has_block_type
return out_dict
class Shape(ComponentNode):
"""Shape is a superclass for different Shape types like: Cube, rectanguloid,
sphere etc.
__init__(): Picks the block_type. The specific shape attributes are assigned in the individual
child classes.
"""
KEYS = [
"has_size",
"has_thickness",
"has_radius",
"has_height",
"has_slope",
"has_orientation",
"has_distance",
"has_base",
]
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(template_attr=template_attr)
self.has_block_type = (
random.choice(self._template_attr.get("block_types", BLOCK_TYPES))
if block_type
else None
)
self.has_name = None
def _generate_description(self):
of = random.choice(["of", "with"])
attrs = []
for key in self.KEYS:
val = getattr(self, key, None)
if val is None:
continue
if type(val) in (list, tuple):
# For has_size format the text as: a b c
# a x b x c or a by b by c
if key == "has_size":
val = random.choice(
[
" ".join(map(str, val)),
" x ".join(map(str, val)),
" by ".join(map(str, val)),
]
)
key = key[4:] # extract "size" from "has_size"
attrs.append("{} {} {}".format(of, key, val))
random.shuffle(attrs)
out_dict = {}
out_dict["word"] = self._word
if attrs:
out_dict["shape_attributes"] = attrs
if self.has_block_type:
out_dict["block_type"] = self.has_block_type
return out_dict
class BlockShape(Shape):
"""Subclass of Shape represents a single block.
__init__(): Assigning shape type, size and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type)
# block is a 1 X 1 X 1 rectanguloid
"""schematic_attributes specifies whether any 1x3 size can be assigned or height, width etc
are assigned separately one at a time.
"""
self._word = random.choice(["block", "square"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class RectanguloidShape(Shape):
"""Subclass of Shape represents a rectanguloid.
__init__(): Assigning shape type, size and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
# rectanguloid is width x height x thickness
"""schematic_attributes specifies whether any 1x3 size can be assigned or height, width etc
are assigned separately one at a time.
"""
if schematic_attributes:
if type(schematic_attributes) == bool:
self.has_size = random.sample(
self._template_attr.get("size", range(3, 51)), 3
) # pick 3 random numbers
elif type(schematic_attributes) == dict: # assign only what's specified.
if "height" in schematic_attributes:
self.has_height = schematic_attributes["height"]
if "width" in schematic_attributes:
self.has_width = schematic_attributes["width"]
self._word = random.choice(["rectanguloid"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class HollowRectanguloidShape(Shape):
"""Subclass of Shape, represents a hollow rectanguloid.
__init__(): Assigning shape type, size, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if (
schematic_attributes
): # schematic_attributes specifies that the size and thickness have to be assigned
self.has_size = random.sample(self._template_attr.get("size", range(3, 51)), 3)
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 6)))
if pick_random()
else None
)
self._word = random.choice(["box", "empty box", "hollow box", "hollow rectanguloid"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class CubeShape(Shape):
"""Subclass of Shape, represents a cube.
__init__(): Assigning shape type, size and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_size = (
random.choice(self._template_attr.get("size", range(3, 51)))
if schematic_attributes
else None
)
self._word = random.choice(["cube"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class HollowCubeShape(Shape):
"""Subclass of Shape, represents a hollow cube.
__init__(): Assigning shape type, size, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_size = random.choice(self._template_attr.get("size", range(3, 51)))
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 6)))
if pick_random()
else None
)
self._word = random.choice(["empty cube", "hollow cube"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class SphereShape(Shape):
"""Subclass of Shape, represents a sphere.
__init__(): Assigning shape type, radius and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_radius = random.choice(self._template_attr.get("radius", range(3, 51)))
self._word = random.choice(["ball", "sphere"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class HollowSphereShape(Shape):
"""Subclass of Shape, repesents a hollow sphere.
__init__(): Assigning shape type, radius, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_thickness = random.choice(self._template_attr.get("thickness", range(1, 6)))
self.has_radius = (
random.choice(self._template_attr.get("radius", range(3, 51)))
if pick_random()
else None
)
self._word = random.choice(
["empty sphere", "empty ball", "hollow ball", "spherical shell", "hollow sphere"]
)
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class PyramidShape(Shape):
"""Subclass of Shape, repesents a pyramid.
__init__(): Assigning shape type, radius, height, slope and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_radius = random.choice(self._template_attr.get("radius", range(3, 51)))
self.has_height = (
random.choice(self._template_attr.get("height", range(3, 51)))
if pick_random()
else None
)
self.has_slope = (
random.choice(self._template_attr.get("slope", range(1, 11)))
if pick_random()
else None
)
self._word = random.choice(["pyramid"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class RectangleShape(Shape):
"""Subclass of Shape, repesents a rectangle.
__init__(): Assigning shape type, size, orientation type and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
if type(schematic_attributes) == bool:
self.has_size = random.sample(self._template_attr.get("size", range(3, 51)), 2)
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
elif type(schematic_attributes) == dict:
if "height" in schematic_attributes:
self.has_height = schematic_attributes["height"]
if "length" in schematic_attributes:
self.has_length = schematic_attributes["length"]
self._word = random.choice(["rectangle", "wall", "slab", "platform"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class SquareShape(Shape):
"""Subclass of Shape, repesents a square.
__init__(): Assigning shape type, size, orientation type and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_size = random.choice(self._template_attr.get("size", range(3, 51)))
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
self._word = random.choice(["square"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class TriangleShape(Shape):
"""Subclass of Shape, represents an equilateral triangle.
__init__(): Assigning shape type, size, orientation type, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_size = random.choice(self._template_attr.get("size", range(3, 11)))
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 6)))
if pick_random()
else None
)
self._word = random.choice(["triangle"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class CircleShape(Shape):
"""Subclass of Shape, repesents a circle.
__init__(): Assigning shape type, radius, orientation type, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_radius = random.choice(self._template_attr.get("radius", range(3, 51)))
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 6)))
if pick_random()
else None
)
self._word = random.choice(["circle"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class DiskShape(Shape):
"""Subclass of Shape, represents a disk.
__init__(): Assigning shape type, radius, orientation type, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_radius = random.choice(self._template_attr.get("radius", range(3, 51)))
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 6)))
if pick_random()
else None
)
self._word = random.choice(["disk"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class EllipsoidShape(Shape):
"""Subclass of Shape, represents an ellipsoid.
__init__(): Assigning shape type, size, and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
self.has_size = (
random.sample(self._template_attr.get("size", range(3, 51)), 3)
if schematic_attributes
else None
)
self._word = random.choice(["ellipsoid"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class DomeShape(Shape):
"""Subclass of Shape, repesents a dome.
__init__(): Assigning shape type, radius, thickness and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_radius = random.choice(self._template_attr.get("radius", range(10, 51)))
self.has_orientation = random.choice(["xy", "yz", "xz"]) if pick_random() else None
self.has_thickness = (
random.choice(self._template_attr.get("thickness", range(1, 4)))
if pick_random()
else None
)
self._word = random.choice(["dome"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class ArchShape(Shape):
"""Subclass of Shape, repesents an arch.
__init__(): Assigning shape type, size, orientation type, distance and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
self.has_size = random.choice(self._template_attr.get("size", range(3, 51)))
self.has_orientation = random.choice(["xy", "xz"]) if pick_random() else None
self.has_distance = (
random.choice(self._template_attr.get("distance", range(1, 50, 2)))
if pick_random()
else None
)
self._word = random.choice(["arch", "archway"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class TowerShape(Shape):
"""Subclass of Shape, represents a tower.
__init__(): Assigning shape type, size, orientation type, distance and word.
"""
def __init__(
self, block_type=False, schematic_attributes=False, repeat_key=None, template_attr={}
):
super().__init__(block_type=block_type, template_attr=template_attr)
if schematic_attributes:
if type(schematic_attributes) == bool:
self.has_height = random.choice(self._template_attr.get("height", range(1, 12)))
self.has_base = (
random.choice(self._template_attr.get("base", range(-3, 6)))
if pick_random()
else None
)
elif type(schematic_attributes) == dict:
if "height" in schematic_attributes:
self.has_height = schematic_attributes["height"]
if "base" in schematic_attributes:
self.has_base = schematic_attributes["base"]
self._word = random.choice(["tower", "stack"])
if repeat_key:
self._word = make_plural(self._word)
self.has_name = self._word
class Schematic(ComponentNode):
"""A Schematic can be either a Shape or a CategoryObject
"""
def __init__(
self,
only_block_type=True, # only have a block type and no other attribute
block_type=False, # should the schematic have a block type
schematic_attributes=False, # a dict of explicit attributes requested if any
schematic_type=None, # type of Schematic : Shape or CategoryObject
abstract_size=None, # abstract size attribute
colour=None, # if the Schematic should have colour
repeat_key=None, # kind of repetition
repeat_dir=None, # direction of repetition
template_attr={},
multiple_schematics=False,
):
super().__init__(template_attr=template_attr)
self.has_size = None
self.has_colour = None
self._repeat = None
self._schematics_type = None
self.has_block_type = None
# if the Schematic only has a block type and no other attribute
if only_block_type:
self.has_block_type = random.choice(
self._template_attr.get("block_types", BLOCK_TYPES)
)
return
# if the type if given assing, else pick randomly
if schematic_type:
schematic_type = schematic_type
else:
schematic_type = random.choice([Shape, CategoryObject])
if schematic_type == Shape: # Shape class has CHOICES
schematic_type = random.choice(Shape.CHOICES)
# the repeat kind. 'FOR' indicates for count, 'ALL' indicates -> for every.
if repeat_key == "FOR":
random_step_count = random.choice(self._template_attr.get("count", range(1, 101)))
# pick a value for the count
repeat_count = random.choice(
[str(random_step_count), int_to_words(random_step_count), "a few", "some"]
)
self._repeat = Repeat(
repeat_key=repeat_key, repeat_count=repeat_count, repeat_dir=repeat_dir
)
elif repeat_key == "ALL":
self._repeat = Repeat(repeat_key="ALL", repeat_dir=repeat_dir)
elif repeat_key == "ALL_ONLY":
self._repeat = Repeat(repeat_key="ALL_ONLY")
self._schematics_type = schematic_type(
block_type=block_type,
schematic_attributes=schematic_attributes,
repeat_key=repeat_key,
template_attr=template_attr,
)
# Inherit the keys from schematic type for the action tree
for key, val in self._schematics_type.__dict__.items():
if key.startswith("has_"):
setattr(self, key, val)
if multiple_schematics:
cat_object_name = random.choice(self._template_attr.get("non_shape_names", CATEGORIES))
shape_name = random.choice(SHAPE_NAMES)
self.has_name = self.has_name + "__&&__" + random.choice([shape_name, cat_object_name])
if abstract_size: # add an abstract size if the flag is set
self.has_size = random.choice(ABSTRACT_SIZE)
if colour: # add colour if colour flag is set
self.has_colour = random.choice(COLOURS)
def _generate_description(self):
out_dict = OrderedDict()
# If the Schematic only has a block_type
if not self._schematics_type:
out_dict["block_type"] = self.has_block_type
return out_dict
# get the tree from the child an expand with the parent's attributes
child_dict = self._schematics_type.generate_description()
if self._repeat and self._repeat.repeat_key == "FOR":
out_dict["object_prefix"] = self._repeat.repeat_count
if self.has_size:
out_dict["size"] = self.has_size
if self.has_colour:
out_dict["colour"] = self.has_colour
out_dict.update(child_dict)
if "__&&__" in self.has_name:
out_dict["word"] = self.has_name
return out_dict
##############
## LOCATION ##
##############
class Coordinates(ComponentNode):
"""Coordinates is a list of x, y, z coordinates
__init__(): pick the coordinates
_generate_description() : different ways of representing coordinates in text
"""
def __init__(self, template_attr={}):
super().__init__(template_attr=template_attr)
self.coordinates = random.sample(
self._template_attr.get("coordinates", range(-100, 101)), 3
)
def __repr__(self):
return "<Abs {}>".format(self.coordinates)
def _generate_description(self):
location = random.choice(
[
"at loc {} {} {}",
"at location {} {} {}",
"at loc: {} {} {}",
"at location: {} {} {}",
"at coordinates: {} {} {}",
]
).format(*self.coordinates)
return location
class LocationDelta(ComponentNode):
"""LocationDelta picks the relative direction type.
__init__(): pick the direction type
"""
def __init__(
self,
relative_direction=True, # indicates relative to something vs itself
direction_type=None, # value of direction
additional_direction=None,
):
super().__init__()
self._relative_pos = relative_direction
if additional_direction is None:
additional_direction = []
# Assign value of _direction_type to be the key name if assigned, else True
direction_list = [
"LEFT",
"RIGHT",
"UP",
"DOWN",
"FRONT",
"BACK",
"AWAY",
] + additional_direction
self._direction_type = direction_type if direction_type else random.choice(direction_list)
def _generate_description(self):
direction_dict = {}
# LocationDelta being used as being relative to a BlockObject/ Mob
# vs being used with self (AgentPos)
if self._relative_pos:
direction_dict["LEFT"] = ["to the left of", "towards the left of"]
direction_dict["RIGHT"] = ["to the right of", "towards the right of"]
direction_dict["UP"] = ["above", "on top of", "to the top of", "over the", "over"]
direction_dict["DOWN"] = ["below", "under"]
direction_dict["FRONT"] = ["in front of"]
direction_dict["BACK"] = ["behind"]
direction_dict["AWAY"] = ["away from"]
direction_dict["INSIDE"] = ["inside"]
direction_dict["OUTSIDE"] = ["outside"]
direction_dict["NEAR"] = ["next to", "close to", "near"]
direction_dict["CLOCKWISE"] = ["clockwise"]
direction_dict["ANTICLOCKWISE"] = ["anticlockwise"]
direction_dict["BETWEEN"] = ["between", "in between", "in the middle of"]
direction_dict["ACROSS"] = ["across", "across from"]
else:
direction_dict["LEFT"] = ["to the left", "to your left", "east", "left"]
direction_dict["RIGHT"] = ["to the right", "to your right", "right", "west"]
direction_dict["UP"] = ["up", "north"]
direction_dict["DOWN"] = ["down", "south"]
direction_dict["FRONT"] = ["front", "forward", "to the front"]
direction_dict["BACK"] = ["back", "backwards", "to the back"]
direction_dict["AWAY"] = ["away"]
direction_dict["CLOCKWISE"] = ["clockwise"]
direction_dict["ANTICLOCKWISE"] = ["anticlockwise"]
return random.choice(direction_dict[self._direction_type])
class SpeakerLook(ComponentNode):
"""SpeakerLook is where the speaker is looking.
This class has no attributes of its own, except for the decription
"""
def _generate_description(self):
return random.choice(["there", "over there", "where I am looking"])
class SpeakerPos(ComponentNode):
"""SpeakerPos is where the speaker is.
This class has no attributes of its own, except for the decription
"""
def _generate_description(self):
return random.choice(["here", "over here"])
class AgentPos(ComponentNode):
"""AgentPos is where the agent is.
This class has no attributes of its own, except for the decription
"""
def _generate_description(self):
return random.choice(["where you are", "where you are standing"])
class Location(ComponentNode):
"""Location can be of different types: Coordinates, BlockObject, Mob,
AgentPos, SpeakerPos, SpeakerLook
__init__(): Pick the location_type, instantiate it (_child), pick location's coordinates
(if location_type == "Coordinates"), instantiate relative_direction if any, pick
number of steps.
"""
def __init__(
self,
location_type=None, # indicates whether type can be assigned and which one
relative_direction=None, # if relative direction id involved
relative_direction_value=None, # value of direction
additional_direction=None,
steps=False, # does Location involves steps
repeat_key=None, # repeat at Location
coref_resolve=None, # coref resolution type
bo_coref_resolve=None,
template_attr={},
):
def assign_relative_direction(self, relative_direction):
if relative_direction:
self.relative_direction = self._dirn_relative._direction_type
elif (relative_direction is None) and (self.location_type in [BlockObject, Mob]):
self.relative_direction = self._dirn_relative._direction_type
super().__init__(template_attr=template_attr)
self.steps = None
self.relative_direction = None
self.location_type = None
self.contains_coreference = None
relative_to_other = True # if True -> relative_direction is wrt to something else
# relative to itself.
"""Set the relative direction for location, if specified"""
self._dirn_relative = LocationDelta(
relative_direction=relative_to_other,
direction_type=relative_direction_value,
additional_direction=additional_direction,
)
assign_relative_direction(self, relative_direction)
"""Assign the location type"""
# Location type None is for no location type
if type(location_type) is not list:
location_type = [location_type]
bo_coref_resolve = [bo_coref_resolve] if bo_coref_resolve else None
if self.relative_direction == "BETWEEN" and len(location_type) == 1:
repeat_key = "ALL_ONLY"
self._child = []
for i, l_type in enumerate(location_type):
if l_type == "SpeakerLookMob":
# TODO: fix this!!
self.location_type = SpeakerLook
elif l_type not in [None, "ANY"]: # specific type
self.location_type = l_type
elif l_type == "ANY" and relative_direction: # relative to itself
relative_to_other = False
self.location_type = AgentPos
elif coref_resolve:
self.contains_coreference = coref_resolve
else:
# For type "ANY" or None specified, pick a random location
self.location_type = random.choice([Coordinates, BlockObject, Mob])
"""Pick the child and other attributes based on location type"""
if self.location_type not in [BlockObject, Mob]:
location_child = self.location_type() if self.location_type else None
self._child.append(location_child)
if self.location_type == Coordinates:
self.coordinates = self._child[-1].coordinates
elif self.location_type == BlockObject:
bo_type = None
no_child = False
if bo_coref_resolve and bo_coref_resolve[i]:
bo_type = PointedObject
no_child = True
# For BlockObjects, control the depth of the tree by removing the
# recursive location
coreference_type = (
bo_coref_resolve[i] if (bo_coref_resolve and bo_coref_resolve[i]) else None
)
self._child.append(
BlockObject(
block_object_location=False,
block_object_type=bo_type,
repeat_key=repeat_key,
coref_type=coreference_type,
no_child=no_child,
template_attr=template_attr,
)
)
if len(location_type) == 1:
self._block_object = self._child[-1]
elif i == 0:
self._block_object_1 = self._child[-1]
elif i == 1:
self._block_object_2 = self._child[-1]
# when the location_type needs to be SpeakerLook but we want properties of Mob
# eg : "follow that pig"
elif l_type == "SpeakerLookMob" or self.location_type == Mob:
mob_resolve = bo_coref_resolve[i] if bo_coref_resolve else None
self._child.append(
Mob(repeat_key=repeat_key, coref_type=mob_resolve, template_attr=template_attr)
)
if len(location_type) == 1:
self._mob = self._child[-1]
elif i == 0:
self._mob_1 = self._child[-1]
elif i == 1:
self._mob_2 = self._child[-1]
assign_relative_direction(self, relative_direction)
"""Select steps """
if steps:
random_step_count = random.choice(self._template_attr.get("step", range(1, 101)))
self.steps = random.choice(
[str(random_step_count), int_to_words(random_step_count), "few"]
)
def _generate_description(self):
out_dict = OrderedDict() # the OrderedDict ensures that the order of values is maintained.
if self.steps:
out_dict["steps"] = self.steps + " steps"
if self.relative_direction:
out_dict["relative_direction"] = self._dirn_relative.generate_description()
for child in self._child:
obj_name = to_snake_case(type(child).__name__) # key names are snake case
if child:
out_dict[obj_name] = child.generate_description()
if self.contains_coreference:
out_dict["coref"] = self.contains_coreference
return out_dict
#################
## BLOCKOBJECT ##
#################
class Object(ComponentNode):
"""Object can be any generic thing that exists in the Minecraft environment.
__init__(): Pick the size and colour
The name of the object is picked in _generate_description() and can be : 'thing', 'shape', 'structure', 'object'
"""
def __init__(
self, repeat_key_val=None, coref_type=None, template_attr={}
): # value of repeat key
super().__init__(template_attr=template_attr)
self._repeat = None
self._repeat_all_text = None
# Pick size and color at random.
self.has_size = random.choice([""] + ABSTRACT_SIZE) if pick_random() else None
self.has_colour = random.choice([""] + COLOURS) if pick_random() else None
# The object can either be an abstract shape with size / color or a concrete named object.
"""If none of size and colour have been picked, deifnitely pick a name,
to avoid : the shape , the structure etc"""
if (not self.has_size) and (not self.has_colour):
self.has_name = random.choice(
self._template_attr.get("non_shape_names", CONCRETE_OBJECT_NAMES)
)
else:
self.has_name = (
random.choice(self._template_attr.get("non_shape_names", CONCRETE_OBJECT_NAMES))
if pick_random()
else None
)
# pick the kind of repetition
if repeat_key_val:
if repeat_key_val == "ALL":
self._repeat = Repeat(repeat_key="ALL")
self._repeat_all_text = random.choice(["all", "each", "every"])
elif repeat_key_val == "ALL_ONLY":
self._repeat = Repeat(repeat_key="ALL_ONLY")
else:
self._repeat = Repeat(repeat_key="FOR", repeat_count=repeat_key_val)
# make name plural for all kind of repeats except for 'each' and 'every'.
if self.has_name and self._repeat:
repeat_key_type = self._repeat.repeat_key
if (
repeat_key_type == "FOR"
or (repeat_key_type == "ALL" and self._repeat_all_text == "all")
or repeat_key_type == "ALL_ONLY"
):
self.has_name = make_plural(self.has_name)
def _generate_description(self):
out_dict = {}
out_dict["object_prefix"] = "the"
if self._repeat:
repeat_key_type = self._repeat.repeat_key
if repeat_key_type == "ALL":
out_dict["object_prefix"] = self._repeat_all_text
elif repeat_key_type == "FOR":
out_dict["object_prefix"] = self._repeat.repeat_count
if self.has_size:
out_dict["size"] = self.has_size
if self.has_colour:
out_dict["colour"] = self.has_colour
if self.has_name:
out_dict["name"] = self.has_name
if "name" not in out_dict:
phrase = random.choice(["thing", "shape", "structure", "object"])
if self._repeat:
repeat_key_type = self._repeat.repeat_key
if (
repeat_key_type == "FOR"
or (repeat_key_type == "ALL" and self._repeat_all_text == "all")
or repeat_key_type == "ALL_ONLY"
):
phrase = make_plural(phrase)
out_dict["object"] = phrase
return out_dict
class PointedObject(ComponentNode):
"""PointedObject is an object that the speaker is pointing at.
__init__(): Pick the size and colour
The name is picked later in _generate_description
"""
KEYS = ["has_size", "has_colour"]
def __init__(
self, repeat_key_val=None, coref_type=None, template_attr={}
): # value of repeat key
super().__init__(template_attr=template_attr)
self._coref_type = coref_type
self._repeat = None
self.has_size = random.choice([""] + ABSTRACT_SIZE) if pick_random() else None
self.has_colour = random.choice([""] + COLOURS) if pick_random() else None
self._word = random.choice(["this", "that"])
# the kind of repetition
if repeat_key_val:
if repeat_key_val in ["ALL", "ALL_ONLY"]:
self._repeat = Repeat(repeat_key=repeat_key_val)
else:
self._repeat = Repeat(repeat_key="FOR", repeat_count=repeat_key_val)
self.has_name = (
random.choice(self._template_attr.get("non_shape_names", CONCRETE_OBJECT_NAMES))
if pick_random()
else None
)
if self.has_name and self._repeat:
self.has_name = make_plural(self.has_name)
def _generate_description(self):
out_dict = {}
out_dict["object_prefix"] = self._word
out_dict["object"] = None
if self._repeat:
repeat_key_type = self._repeat.repeat_key
if repeat_key_type == "ALL":
if self._coref_type:
out_dict["object_prefix"] = "each of"
else:
out_dict["object_prefix"] = "each of " + random.choice(["those", "these"])
elif repeat_key_type == "FOR":
phrase = random.choice(["those ", "these "])
if self._coref_type:
out_dict["object_prefix"] = self._repeat.repeat_count
else:
out_dict["object_prefix"] = phrase + self._repeat.repeat_count
if self.has_size:
out_dict["size"] = self.has_size
if self.has_colour:
out_dict["colour"] = self.has_colour
if self.has_name:
out_dict["name"] = self.has_name
object_description = random.choice(["thing", "shape", "structure", "object"])
if self._repeat:
object_description = make_plural(object_description)
# If size or colour assigned, it needs to have a description/ name.
if ("size" in out_dict) or ("colour" in out_dict):
if "name" not in out_dict:
out_dict["object"] = object_description
else:
if self._repeat:
out_dict["object"] = object_description # the plural description
# Assign name/thing optionally
elif "name" not in out_dict:
out_dict["object"] = object_description if pick_random() else None
return out_dict
class BlockObject(ComponentNode):
"""BlockObject can be anything that physically exists in the Minecraft environment.
There can be two types of physical objects: PointedObject or an Object, as described above,
__init__(): Pick the block_object_type, size, colour, description of the object.
If an explicit list of block_object_attributes is given, those are assigned, otherwise
inherit the child's attributes.
If block_object_type is specified, assign that, else picked randomly.
If block_object_location is specified, then assign a location else location is optional.
"""
def __init__(
self,
block_object_type=None, # the kind of BlockObject: Object / PointedObject
block_object_attributes=None, # explicit attributes of the blockobject
block_object_location=None, # the location of the blockobject if any
no_child=False, # should this blockobject have a child
repeat_key=None, # what kind of repetition
repeat_no_child=None, # if only repeat and no children
repeat_location=None, # repetition in location
coref_type=None, # coreference type
template_attr={},
):
super().__init__(template_attr=template_attr)
self.has_size = None
self.has_colour = None
self._object_desc = None
self._location = None
self.has_name = None
self._repeat = None
block_object_repeat_cnt = None
# the kind of repetition
if repeat_key == "FOR":
random_step_count = random.choice(self._template_attr.get("count", range(1, 101)))
block_object_repeat_cnt = random.choice(
[str(random_step_count), int_to_words(random_step_count), "few"]
)
self._repeat = Repeat(repeat_key=repeat_key, repeat_count=block_object_repeat_cnt)
elif repeat_key == "ALL":
self._repeat = Repeat(repeat_key="ALL")
block_object_repeat_cnt = "ALL"
elif repeat_key == "ALL_ONLY":
self._repeat = Repeat(repeat_key="ALL_ONLY")
block_object_repeat_cnt = "ALL_ONLY"
# If only repeat_key and no other children
if repeat_no_child:
return
"""Assign block object type"""
# If object_type is specified, assign that, else pick at random
# for "what you built" etc
if coref_type:
self.contains_coreference = coref_type
if block_object_type is None and coref_type is not None:
return
elif block_object_type:
self._block_object_type = block_object_type
else:
self._block_object_type = Object # PointedObject if pick_random(0.4) else Object
self._child = self._block_object_type(
repeat_key_val=block_object_repeat_cnt,
coref_type=coref_type,
template_attr=template_attr,
)
"""Assign block object's attributes"""
# If attribute list is not explicitly defined, pull all from
# children if child exists.
if not block_object_attributes and (not no_child):
for key, val in self._child.__dict__.items():
if key.startswith("has_"):
setattr(self, key, val)
elif block_object_attributes is not None:
# Only assign the specified attributes
for attr in block_object_attributes:
if attr == "size":
self.has_size = random.choice(ABSTRACT_SIZE)
if attr == "colour":
self.has_colour = random.choice(COLOURS)
if attr == "object":
thing_desc = random.choice(["thing", "shape", "structure", "object"])
self._object_desc = thing_desc
if attr == "objects":
self._object_desc = make_plural(
random.choice(["thing", "shape", "structure", "object"])
)
if attr == "name":
name_desc = random.choice(
self._template_attr.get("non_shape_names", CONCRETE_OBJECT_NAMES)
)
self.has_name = name_desc
if attr == "names":
self.has_name = make_plural(
random.choice(
self._template_attr.get("non_shape_names", CONCRETE_OBJECT_NAMES)
)
)
"""Assign block object location"""
if self._block_object_type == PointedObject:
if coref_type:
self._location = None # Location(coref_resolve=coref_type)
else:
self._location = Location(location_type=SpeakerLook, template_attr=template_attr)
# coref_type_val = coref_type if coref_type else self._child._word
else:
# If generic Object, if location explicitly specified then assign else optional.
if block_object_location is True:
self._location = Location(template_attr=template_attr)
elif block_object_location is False:
self._location = None
elif block_object_location is None:
self._location = Location(template_attr=template_attr) if pick_random() else None
elif block_object_location in [BlockObject, Mob]:
self._location = Location(
location_type=block_object_location,
repeat_key=repeat_location,
template_attr=template_attr,
)
def _generate_description(self):
# Also populate things from child, in case default values are needed
# Example when BlockObject is a reference for a Location.
object_desc = self._child.generate_description()
locn_desc = None
if self._block_object_type == Object and self._location:
locn_desc = self._location.generate_description()
out_dict = OrderedDict()
out_dict["object_prefix"] = object_desc["object_prefix"]
if self.has_size:
out_dict["size"] = self.has_size
if self.has_colour:
out_dict["colour"] = self.has_colour
if self.has_name:
out_dict["name"] = self.has_name
if self._object_desc:
out_dict["object"] = self._object_desc
# We need this when BlockObject is used as a reference_object
if "object" in object_desc and object_desc["object"]:
out_dict["abstract_structure"] = object_desc["object"]
if locn_desc:
out_dict["location"] = locn_desc
return out_dict
#################
## MOB ##
#################
class Mob(ComponentNode):
"""Mob is a mobile object in Minecraft. We have a list of these defined at the top.
__init__(): Pick the mob name and location
"""
def __init__(
self,
mob_location=None, # specify the location of the mob if any
repeat_key=None, # the kind of repetition
repeat_location=None, # repetitions in location if allowed
coref_type=None,
template_attr={},
):
super().__init__(template_attr=template_attr)
self._repeat = None
self._location = None
self.has_name = random.choice(self._template_attr.get("mob_names", MOBS))
self.contains_coreference = coref_type
"""Assign location of the mob if any"""
if mob_location:
self._location = Location(
location_type=mob_location, repeat_key=repeat_location, template_attr=template_attr
)
# the kind of repetition
if repeat_key == "FOR":
random_step_count = random.choice(self._template_attr.get("count", range(1, 101)))
repeat_count = random.choice(
[str(random_step_count), int_to_words(random_step_count), "few"]
)
self._repeat = Repeat(repeat_key=repeat_key, repeat_count=repeat_count)
elif repeat_key in ["ALL", "ALL_ONLY"]:
self._repeat = Repeat(repeat_key=repeat_key)
def _generate_description(self):
location_desc = None
if self._location:
location_desc = self._location.generate_description()
out_dict = {}
if self._repeat:
key_type = self._repeat.repeat_key
if key_type == "ALL":
out_dict["mob_prefix"] = random.choice(["all the", "each", "every", "all"])
elif key_type == "FOR":
out_dict["mob_prefix"] = self._repeat.repeat_count
elif key_type == "ALL_ONLY":
out_dict["mob_prefix"] = "the"
elif pick_random():
out_dict["mob_prefix"] = "the"
# update name to be plural if repetitions
if self._repeat:
if ("mob_prefix" not in out_dict) or (out_dict["mob_prefix"] not in ["each", "every"]):
self.has_name = make_plural(self.has_name)
out_dict["mob"] = self.has_name
if location_desc:
out_dict["location"] = location_desc
return out_dict
####################
## STOP CONDITION ##
####################
class StopCondition(ComponentNode):
"""Stop Condition defines the condition to terminate a loop.
The different stop condition types are specified in : CONDITION_TYPES
__init__(): Assign the condition type and other keys based on the condition
"""
def __init__(
self,
condition_type=None, # condition type to terminate the loop
block_type=None, # optional, needed for condition_type: AdjacentToBlockType
):
super().__init__()
self.condition_type = condition_type if condition_type else None
self.block_type = (
random.choice(self._template_attr.get("block_types", BLOCK_TYPES))
if block_type
else None
)
def _generate_description(self):
out_dict = {}
if self.block_type:
out_dict["block_type"] = self.block_type
return out_dict
##################
### REPEAT ###
##################
class Repeat(ComponentNode):
"""Repeat class defines the kind of loop, the number of times the loop should
be run as well the direction of loop execution.
"""
def __init__(
self,
repeat_key=None, # the loop type: 'FOR' / 'ALL'
repeat_count=None, # optional, needed for counting the loop
repeat_dir=None, # the direction of loop execution
):
super().__init__()
self.repeat_key = repeat_key if repeat_key else None
self.repeat_count = repeat_count if repeat_count else None
self.repeat_dir = repeat_dir if repeat_dir else None
def _generate_description(self):
return {}
###################
### FILTERS ###
###################
class Filters(ComponentNode):
"""Filters class defines the name of filters and their values.
This is used with GetMemory and PutMemory actions
"""
def __init__(
self,
temporal=None, # the temporal value
mem_type=None, # type of memory object
action_type=None,
block_object_attr=None,
bo_updated=False,
location_attr=None,
location_updated=False,
mob_attr=None,
mob_updated=False,
):
super().__init__()
self.temporal = temporal if temporal else None
self.type = mem_type if mem_type else None
self.action_type = action_type if action_type else None
self._location = None
self._reference_object = None
if bo_updated:
self._reference_object = BlockObject(**block_object_attr)
if location_updated:
self._location = Location(**location_attr)
if mob_updated:
self._reference_object = Mob(**mob_attr)
def _generate_description(self):
out_dict = {}
if self._reference_object:
out_dict = self._reference_object.generate_description()
if self._location:
out_dict.update(self._location.generate_description())
return out_dict
###################
### UPSERT ###
###################
class Upsert(ComponentNode):
"""Upsert class defines the memoryt type and data that needs to be upserted
into the bot's memory
"""
def __init__(
self, memory_type=None, reward_value=None, has_tag=None, has_size=None, has_colour=None
):
super().__init__()
self._memory_data = None
if memory_type:
self._memory_data = MemoryData(
reward_value=reward_value,
memory_type=memory_type,
has_tag=has_tag,
has_size=has_size,
has_colour=has_colour,
)
def _generate_description(self):
return {}
######################
### MemoryData ###
######################
class MemoryData(ComponentNode):
def __init__(
self, reward_value=None, memory_type=None, has_tag=None, has_colour=None, has_size=None
):
super().__init__()
self.reward_value = reward_value if reward_value else None
self.memory_type = memory_type if memory_type else None
self.has_tag = has_tag if has_tag else None
self.has_size = has_size if has_size else None
self.has_colour = has_colour if has_colour else None
def _generate_description(self):
return {}
##################
## CHOICE LISTS ##
##################
Shape.CHOICES = [
RectanguloidShape,
HollowRectanguloidShape,
CubeShape,
HollowCubeShape,
SphereShape,
HollowSphereShape,
PyramidShape,
RectangleShape,
SquareShape,
TriangleShape,
CircleShape,
DiskShape,
EllipsoidShape,
DomeShape,
ArchShape,
TowerShape,
BlockShape,
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/tree_components.py |
import numpy as np
import random
from generate_dialogue import generate_actions
import sys
import os
import uuid
import json
TTAD_GEN_DIR = os.path.dirname(os.path.realpath(__file__))
CRAFTASSIST_DIR = os.path.join(TTAD_GEN_DIR, "../../")
sys.path.append(CRAFTASSIST_DIR)
from generate_data import *
import re
from dialogue_objects.interpreter_helper import coref_resolve, interpret_shape_schematic
from word_maps import SPECIAL_SHAPE_FNS, SPECIAL_SHAPES_CANONICALIZE, SPAWN_OBJECTS
from size_words import size_str_to_int
import shapes
import block_data
import snowballstemmer
stemmer = snowballstemmer.stemmer("english")
# from word2number.w2n import word_to_num
CHOICES = [Move, Build, Destroy, Dig, Copy, Fill, Spawn, Dance]
#############################################################
# modified from size_words...
#############################################################
RANGES = {
"tiny": (2, 3),
"small": (2, 3),
"medium": (2, 4),
"large": (4, 5),
"huge": (5, 6),
"gigantic": (5, 6),
}
class Dummy:
pass
def inspect_ads(template_attributes, condition):
while True:
a = get_good_ad(template_attributes)
if eval(condition):
print(a[0])
print(json.dumps(a[1], sort_keys=True, indent=4))
break
return a
def process_spans(d, words):
for k, v in d.items():
if type(v) == dict:
process_spans(v, words)
continue
try:
if k != "has_attribute":
sentence, (L, R) = v
if sentence != 0:
raise NotImplementedError("Must update process_spans for multi-string inputs")
assert 0 <= L <= R <= (len(words) - 1)
except ValueError:
continue
except TypeError:
continue
d[k] = " ".join(words[L : (R + 1)])
class EmptyWorkspaceMemory:
def get_recent_entities(self, x=None):
return []
def surgery_by_value(ad, old_value, new_value):
for k, v in ad.items():
if type(v) is dict:
surgery_by_value(v, old_value, new_value)
else:
if v == old_value:
ad[k] = new_value
def get_fields_by_key(ad_and_parent, key):
parent = ad_and_parent[0]
ad = ad_and_parent[1]
if type(ad) is not dict:
return []
else:
values = []
for k, v in ad.items():
u = get_fields_by_key((k, v), key)
values.extend(u)
if k == key:
values.append((parent, v))
return values
# TODO make sure if object has attributes and a location
# e.g. speakerlook there isn't a conflict ?
def get_good_ad(template_attributes, flat=False):
ok = False
while not ok:
ad_and_text = generate_actions(1, CHOICES, template_attributes)
ok = True
if len(ad_and_text[0][0]) > 1:
# filter dialogues
ok = False
continue
text = ad_and_text[0][0][0]
ad = ad_and_text[1][0]["action_sequence"][0]
atpd = template_attributes.get("distribution")
if atpd is not None:
if np.random.rand() > atpd[ad["action_type"]]:
ok = False
continue
fill_spans_and_coref_resolve(ad, text)
ref_objs = get_fields_by_key((None, ad), "reference_object")
if len(ref_objs) > 0:
for r in ref_objs:
p = r[0]
o = r[1]
# filter things like 'go above the 5 cubes'
if p == "location" and o.get("repeat") is not None:
ok = False
# filter things like 'destroy the 5 cubes' (unfortunately killing 'all' rn too, FIXME)
if ad["action_type"] == "DESTROY" and o.get("repeat") is not None:
ok = False
# filter things like 'copy the 5 cubes' (unfortunately killing 'all' rn too, FIXME)
if ad["action_type"] == "BUILD" and o.get("repeat") is not None:
ok = False
# filter "between" FIXME!!!! probably should do two-object betweens
# betweens = get_fields_by_key((None, ad), "reference_object_1")
# if len(betweens)>0:
# ok = False
# but one object one would lead to bias bc of duplicate
betweens = get_fields_by_key((None, ad), "relative_direction")
if len(betweens) > 0 and betweens[0][1] == "BETWEEN":
ok = False
# filter exact coordinates
c = get_fields_by_key((None, ad), "coordinates")
if len(c) > 0:
ok = False
# filter stop conditions of 'ADJACENT_TO_BLOCK_TYPE'
c = get_fields_by_key((None, ad), "condition_type")
if len(c) > 0 and c[0][1] == "ADJACENT_TO_BLOCK_TYPE":
ok = False
# FOR NOW, FILTERING RELDIRS UP, DOWN, INSIDE, OUTSIDE, AWAY!!! FIXME!!
c = get_fields_by_key((None, ad), "relative_direction")
if len(c) > 0 and c[0][1] in ["UP", "DOWN", "INSIDE", "OUTSIDE", "AWAY"]:
ok = False
r = get_fields_by_key((None, ad), "repeat_key")
# filter finite repeats of move actions ("move three steps twice")
if ad["action_type"] == "MOVE" and len(r) > 0 and r[0][1] == "FOR":
ok = False
# filter large objects
# s = get_fields_by_key((None, ad), "has_size")
# for i in s:
# for size in ["gigantic", "huge", "colossal", "large", "big"]:
# if size in i[1]:
# new_size = random.choice(["medium", "small"])
# surgery_by_value(ad, size, new_size)
# text = text.replace(size, new_size)
r = get_fields_by_key((None, ad), "schematic")
if flat:
if len(r) > 0:
for s in r:
name = s[1].get("has_name")
if name is not None:
# FIXME this is not grammatical...
new_name = random.choice(template_attributes["non_shape_names"])
surgery_by_value(ad, name, new_name)
text = text.replace(name, new_name)
r = get_fields_by_key((None, ad), "has_block_type")
if len(r) > 0:
allowed_blocks = template_attributes.get("allowed_blocktypes")
if allowed_blocks:
for (_, btype) in r:
if btype not in allowed_blocks:
new_btype = random.choice(allowed_blocks)
text = text.replace(btype, new_btype)
surgery_by_value(ad, btype, new_btype)
# filter empty builds and empty moves:
# if ad["action_type"] == "MOVE": TODO
return text, ad, ref_objs
def fill_spans_and_coref_resolve(ad, text):
W = EmptyWorkspaceMemory()
process_spans(ad, re.split(r" +", text))
coref_resolve(W, ad)
return ad
def regularize_ref_obj_dict(ref_obj_dict, flat=False):
# TODO make me optional
if ref_obj_dict.get("has_colour") is None:
ref_obj_dict["has_colour"] = random.choice(list(block_data.COLOR_BID_MAP.keys()))
if flat:
ref_obj_dict["has_orientation"] = "xz"
if ref_obj_dict.get("has_size") is None:
ref_obj_dict["has_size"] = "medium"
# takes the piece of the action dict and makes it into a game object
# does not put locs, these need to be fixed after
def specify_object(ref_obj_dict, sl=32, flat=False):
shape_keys = [
"has_size",
"has_thickness",
"has_radius",
"has_depth",
"has_width",
"has_height",
"has_length",
"has_slope",
"has_orientation",
"has_distance",
"has_base",
"has_colour",
]
##############################################
# hack to deal with size ranges in size_words
##############################################
fake_interpreter = Dummy()
fake_interpreter.agent = Dummy()
def ssti(s):
return size_str_to_int(s, ranges=RANGES)
fake_interpreter.agent.size_str_to_int = ssti
name = ref_obj_dict.get("has_name")
if name is not None:
stemmed_name = stemmer.stemWord(name)
shapename = SPECIAL_SHAPES_CANONICALIZE.get(name) or SPECIAL_SHAPES_CANONICALIZE.get(
stemmed_name
)
if SPAWN_OBJECTS.get(name):
return name
elif SPAWN_OBJECTS.get(stemmed_name):
return stemmed_name
if shapename:
regularize_ref_obj_dict(ref_obj_dict, flat=flat)
blocks, _ = interpret_shape_schematic(
fake_interpreter, None, ref_obj_dict, shapename=shapename
)
return blocks
else:
# somethings wrong, abort
return None
else:
if ref_obj_dict.get("has_shape"):
regularize_ref_obj_dict(ref_obj_dict, flat=flat)
blocks, _ = interpret_shape_schematic(fake_interpreter, None, ref_obj_dict)
return blocks
elif any(k in shape_keys for k in ref_obj_dict.keys()):
regularize_ref_obj_dict(ref_obj_dict, flat=flat)
if flat:
shapename = random.choice(["TRIANGLE", "CIRCLE", "DISK", "RECTANGLE"])
else:
shapename = random.choice(list(SPECIAL_SHAPE_FNS.keys()))
blocks, _ = interpret_shape_schematic(
fake_interpreter, None, ref_obj_dict, shapename=shapename
)
return blocks
else:
# somethings wrong, abort
return None
def choose_loc(obj_rad, reldir, viewer_pos, view_vector, ref_obj_loc, sl=32, num_tries=100):
reldir_perp = np.array((-view_vector[1], view_vector[0]))
tform = np.stack((reldir_perp, view_vector), axis=1)
obj_coords = tform.transpose() @ (ref_obj_loc - viewer_pos)
for i in range(num_tries):
loc = np.random.randint(-sl // 2, sl // 2, size=(2))
loc_coords = tform.transpose() @ (loc - viewer_pos)
if reldir == "LEFT":
if loc_coords[0] > obj_coords[0] + obj_rad:
return loc
if reldir == "RIGHT":
if loc_coords[0] < obj_coords[0] - obj_rad:
return loc
if reldir == "BACK":
if loc_coords[1] < obj_coords[1] - obj_rad:
return loc
if reldir == "FRONT":
if loc_coords[1] > obj_coords[1] + obj_rad:
return loc
if reldir == "NEAR":
# 4 is arbitrary
if max(abs(np.subtract(loc, ref_obj_loc))) - obj_rad < 4:
return loc
return None
def maybe_speaker_look(ref_obj_dict, view_pos, sl):
location_type = ref_obj_dict.get("location", {}).get("location_type")
if location_type is not None and location_type == "SPEAKER_LOOK":
loc = np.add(view_pos, np.random.randint(-sl // 8, sl // 8, size=(2)))
else:
loc = np.random.randint(-sl // 2, sl // 2, size=(2))
return loc
# step 1, arrange all reference objects, holes to fill and player
# step 2, build decoys. for each ref object with some attributes (including a reference direction to another ref object)
# build/place a decoy with some attributes the same
# step 3, build random objects/mobs/pits
def build_ref_obj_scene(ad, ref_objs, sl=32, flat=False):
# first place the fake observer, we put them on a ring 75% away from the center of the cube, at ground level
c = np.random.randn(2)
c /= np.linalg.norm(c)
radius = 0.75 * sl / 2
p = radius * c
# the fake observer will look at the ground somewhere along a cone starting from the observer pointing towards
# the center of the square
# n = np.random.randn(2)
# n /= np.linalg.norm(n)
# n *= 0.05
# view_vector = -c + n
view_vector = -c
view_vector = view_vector / np.linalg.norm(
view_vector
) # unit vector in the direction of my look
d = radius + radius * np.random.uniform()
view_pos = p + d * view_vector # which grid location/cube (at ground height) am I looking at?
scene = {"mobs": [], "block_obj": [], "holes": []}
scene["fake_human"] = {"position": p, "view_vector": view_vector, "view_pos": view_pos}
scene["action_dict"] = ad
scene["ref_obj_dicts"] = {}
at = ad["action_type"]
if len(ref_objs) == 1 and at != "FILL" and at != "SPAWN":
# FIXME if loc is given in ad
loc = maybe_speaker_look(ref_objs[0][1], view_pos, sl)
obj = specify_object(ref_objs[0][1], sl=sl, flat=flat)
robj_id = uuid.uuid4().hex
scene["ref_obj_dicts"][robj_id] = ref_objs[0][1]
if type(obj) is str:
scene["mobs"].append({"mobname": obj, "loc": loc, "dict_id": robj_id})
return scene
else:
scene["block_obj"].append({"blocks": obj, "loc": loc, "dict_id": robj_id})
return scene
if len(ref_objs) == 1 and at == "FILL":
obj_loc = maybe_speaker_look(ref_objs[0][1], view_pos, sl)
obj = specify_object(ref_objs[0][1], sl=sl, flat=flat)
reldir = ad["location"]["relative_direction"]
robj_id = uuid.uuid4().hex
scene["ref_obj_dicts"][robj_id] = ref_objs[0][1]
if type(obj) is str:
scene["mobs"].append({"mobname": obj, "loc": obj_loc, "dict_id": robj_id})
hole_loc = choose_loc(1, reldir, view_pos, view_vector, obj_loc, sl=sl)
scene["holes"].append({"loc": hole_loc})
elif obj is not None and len(obj) > 0:
scene["block_obj"].append({"blocks": obj, "loc": obj_loc, "dict_id": robj_id})
bounds = shapes.get_bounds(obj)
rad = max(bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4])
hole_loc = choose_loc(rad, reldir, view_pos, view_vector, obj_loc, sl=sl)
scene["holes"].append({"loc": hole_loc})
# TODO fix relative location; put this in choose_loc, input the ref_obj
elif ref_objs[0][1].get("location")["location_type"] == "SPEAKER_LOOK":
scene["holes"].append({"loc": view_pos.astype("int64")})
elif ref_objs[0][1].get("location")["location_type"] == "SPEAKER_POS":
scene["holes"].append({"loc": p.astype("int64")})
return scene
if len(ref_objs) == 2:
if at == "DESTROY":
reldir = ad["reference_object"]["location"]["relative_direction"]
if ref_objs[0][0] == "action":
d = ref_objs[0][1]
r = ref_objs[1][1]
else:
d = ref_objs[1][1]
r = ref_objs[0][1]
d_id = uuid.uuid4().hex
r_id = uuid.uuid4().hex
scene["ref_obj_dicts"][d_id] = d
scene["ref_obj_dicts"][r_id] = r
to_destroy_obj = specify_object(d, sl=sl, flat=flat)
rel_obj = specify_object(r, sl=sl, flat=flat)
rel_obj_loc = maybe_speaker_look(r, view_pos, sl)
if type(rel_obj) is str:
rad = 1
scene["mobs"].append({"mobname": rel_obj, "loc": rel_obj_loc, "dict_id": r_id})
else:
scene["block_obj"].append({"blocks": rel_obj, "loc": rel_obj_loc, "dict_id": r_id})
bounds = shapes.get_bounds(rel_obj)
rad = max(bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4])
to_destroy_loc = choose_loc(rad, reldir, view_pos, view_vector, rel_obj_loc, sl=sl)
scene["block_obj"].append(
{"blocks": to_destroy_obj, "loc": to_destroy_loc, "dict_id": d_id}
)
return scene
# this is a copy, one ref object is to be copied, and the other gives
# the *target* location, so locations are independent
elif at == "BUILD":
if ref_objs[0][0] == "location":
c = ref_objs[1][1]
r = ref_objs[0][1]
else:
c = ref_objs[0][1]
r = ref_objs[1][1]
c_id = uuid.uuid4().hex
r_id = uuid.uuid4().hex
scene["ref_obj_dicts"][c_id] = c
scene["ref_obj_dicts"][r_id] = r
to_copy_obj = specify_object(c, sl=sl, flat=flat)
to_copy_obj_loc = maybe_speaker_look(c, view_pos, sl)
rel_obj = specify_object(r, sl=sl, flat=flat)
rel_obj_loc = np.random.randint(-sl // 2, sl // 2, size=(2))
scene["block_obj"].append(
{"blocks": to_copy_obj, "loc": to_copy_obj_loc, "dict_id": c_id}
)
if type(rel_obj) is str:
scene["mobs"].append({"mobname": rel_obj, "loc": rel_obj_loc, "dict_id": r_id})
else:
scene["block_obj"].append({"blocks": rel_obj, "loc": rel_obj_loc, "dict_id": r_id})
return scene
return scene
def add_distractors(
scene, template_attributes, sl=32, num_objs=3, num_holes=2, num_mobs=2, flat=False
):
while (
len(scene["block_obj"]) < num_objs
or len(scene["holes"]) < num_holes
or len(scene["mobs"]) < num_mobs
):
text, ad, ref_objs = get_good_ad(template_attributes, flat=flat)
distractor_scene = build_ref_obj_scene(ad, ref_objs, sl=sl, flat=flat)
if distractor_scene is not None:
# not careful about overlaps... should we be?
for bobj in distractor_scene["block_obj"]:
if len(scene["block_obj"]) < num_objs:
scene["block_obj"].append(bobj)
k = bobj["dict_id"]
v = distractor_scene["ref_obj_dicts"][k]
scene["ref_obj_dicts"][bobj["dict_id"]] = v
for hole in distractor_scene["holes"]:
if len(scene["holes"]) < num_holes:
scene["holes"].append(hole)
for mob in distractor_scene["mobs"]:
if len(scene["mobs"]) < num_mobs:
scene["mobs"].append(mob)
k = mob["dict_id"]
v = distractor_scene["ref_obj_dicts"][k]
scene["ref_obj_dicts"][mob["dict_id"]] = v
def get_slice(blocks, axis=0, coord=0):
return [b for b in blocks if b[0][axis] == coord]
def build_scene(template_attributes, sl=32, flat=False):
text, ad, ref_objs = get_good_ad(template_attributes, flat=flat)
S = build_ref_obj_scene(ad, ref_objs, sl=sl, flat=flat)
if S is not None:
S["non_distractors"] = []
for o in S["ref_obj_dicts"]:
S["non_distractors"].append(o)
S["text"] = text
add_distractors(S, template_attributes, sl=sl, flat=flat)
S["id_to_obj"] = {}
for m in S["mobs"]:
S["id_to_obj"][m["dict_id"]] = m
for m in S["block_obj"]:
S["id_to_obj"][m["dict_id"]] = m
if flat:
for b in S["block_obj"]:
if b["blocks"] is not None:
b["blocks"] = get_slice(b["blocks"], axis=1, coord=0)
return S
if __name__ == "__main__":
template_attributes = {"count": range(1, 5)}
template_attributes["step"] = range(1, 10)
template_attributes["non_shape_names"] = list(SPECIAL_SHAPES_CANONICALIZE.keys())
template_attributes["mob_names"] = ["pig", "sheep", "cow", "chicken", "rabbit"]
for i in range(1000):
print(i)
S = build_scene(template_attributes)
# import json
# x = {'a':{'at':'d', 'R':{'hs':'h', 'ha':'h', 'l':{'rd':'right', 'lt':'RO','R':{'hn':'donk'}}}}}
# print(json.dumps(x, sort_keys=True, indent=4))
# u = get_fields_by_key((None, x) , 'R')
# print(len(u))
| craftassist-master | python/base_agent/ttad/generation_dialogues/build_scene.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/base_agent/ttad/generation_dialogues/__init__.py |
if __name__ == "__main__":
import argparse
import pickle
import os
from tqdm import tqdm
from build_scene import *
from block_data import COLOR_BID_MAP
BLOCK_DATA = pickle.load(
open("/private/home/aszlam/minecraft_specs/block_images/block_data", "rb")
)
allowed_blocktypes = []
count = 0
for c, l in COLOR_BID_MAP.items():
for idm in l:
allowed_blocktypes.append(BLOCK_DATA["bid_to_name"][idm])
count += 1
parser = argparse.ArgumentParser()
parser.add_argument("--target", default="/checkpoint/aszlam/minecraft/inverse_model/flat_ads/")
parser.add_argument("--N", type=int, default=10000000)
# parser.add_argument("--num_per_chunk", type=int, default=10000000)
args = parser.parse_args()
template_attributes = {"count": range(1, 5)}
template_attributes["step"] = range(1, 10)
template_attributes["non_shape_names"] = ["triangle", "circle", "disk", "rectangle"]
template_attributes["mob_names"] = ["pig", "sheep", "cow", "chicken"]
template_attributes["allowed_blocktypes"] = allowed_blocktypes
template_attributes["distribution"] = {
"MOVE": 1.0,
"BUILD": 1.0,
"DESTROY": 1.0,
"DIG": 0.8,
"COPY": 0.8,
"FILL": 0.8,
"SPAWN": 0.1,
"DANCE": 0.8,
}
scenes = []
for i in tqdm(range(args.N)):
S = build_scene(template_attributes, sl=16, flat=True)
scenes.append(S)
f = open(os.path.join(args.target, "flat_scenes_dump.pk"), "wb")
pickle.dump(scenes, f)
f.close()
| craftassist-master | python/base_agent/ttad/generation_dialogues/build_scene_flat_script.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file generates action trees and language based on options from
command line.
"""
import json
from generate_data import *
class Action(ActionNode):
"""options for Actions"""
CHOICES = [
Move,
Build,
Destroy,
Noop,
Stop,
Resume,
Dig,
Copy,
Undo,
Fill,
Spawn,
Freebuild,
Dance,
GetMemory,
PutMemory,
]
human_give_command_actions = [
Move,
Build,
Destroy,
Stop,
Resume,
Dig,
Copy,
Undo,
Fill,
Spawn,
Freebuild,
Dance,
]
# Mapping of command line action type to action class
action_type_map = {
"move": Move,
"build": Build,
"destroy": Destroy,
"noop": Noop,
"stop": Stop,
"resume": Resume,
"dig": Dig,
"copy": Copy,
"undo": Undo,
"fill": Fill,
"spawn": Spawn,
"freebuild": Freebuild,
"dance": Dance,
"get_memory": GetMemory,
"put_memory": PutMemory,
}
arg_numeric_range_map = {
"length_range": "length",
"width_range": "width",
"depth_range": "depth",
"height_range": "height",
"size_range": "size",
"thickness_range": "thickness",
"radius_range": "radius",
"slope_range": "slope",
"distance_range": "distance",
"step_range": "step",
"count_range": "count",
"base_range": "base",
"coordinates_range": "coordinates",
}
arg_name_file_map = {
"non_shape_names": "non_shape_names",
"block_types_file": "block_types",
"mob_file": "mob_names",
}
child_key_map = {"BUILD": ["schematic", "reference_object"], "DESTROY": ["reference_object"]}
def add_new_similar_action(action_text, previous_action, name_2, curr_action, curr_index):
"""Append curr_action's action dict to previous_action's action_sequenceself.
curr_index is index of current action dict in action action_sequence"""
span = find_span(action_text, name_2)
action_type = curr_action["action_type"]
child_key = child_key_map[action_type]
child_key_name = None
for key in child_key:
if key in curr_action:
child_key_name = key
new_action = {child_key_name: {"has_name": span}, "action_type": action_type}
previous_action["action_sequence"].insert(curr_index + 1, new_action)
return previous_action
def fix_composite_in_dict(action_text, action_dict):
"""Find if action_dict has a schematic / reference_object that has two entitites
in it, if so, split them and create two different action dicts for each."""
action_description = [x.split() for x in action_text]
name_1, name_2 = None, None
sent_index = 0
if "action_sequence" in action_dict:
for i, curr_action in enumerate(action_dict["action_sequence"]):
action_type = curr_action["action_type"]
if action_type not in child_key_map:
continue
child_key = child_key_map[action_type]
for key in child_key:
if key in curr_action and "has_name" in curr_action[key]:
sent_index, indices = curr_action[key]["has_name"]
curr_sentence = action_text[sent_index]
curr_name = " ".join(curr_sentence.split()[indices[0] : indices[1] + 1])
if "__&&__" in curr_name:
# extract the two names
name_1, name_2 = curr_name.split("__&&__")
# fix the generated sentence
joining_word = random.choice([" and ", " and then "])
action_text[sent_index] = joining_word.join(curr_sentence.split("__&&__"))
# update the sentence split
action_description = [x.split() for x in action_text]
# fix this name's span
span = find_span(action_description, name_1)
curr_action[key]["has_name"] = span
# now add another action with the second name
action_dict = add_new_similar_action(
action_description, action_dict, name_2, curr_action, i
)
return action_dict
return action_dict
def fix_spans(d, prev_sentence_len):
"""This function updates the spans in d and shifts them by a value equal
to prev_sentence_len"""
for key, val in d.items():
if type(val) == list:
if type(val[0]) is int:
sent_index, span = val
index_1, index_2 = span
d[key] = [sent_index, [index_1 + prev_sentence_len, index_2 + prev_sentence_len]]
elif type(val[0]) is dict:
for v in val:
if type(v) is dict:
fix_spans(v, prev_sentence_len)
elif type(val) == dict:
fix_spans(val, prev_sentence_len)
return d
def combine_dicts(dict_1, dict_2, prev_sentence_len):
""" This function appends the 'action_sequence' of dict_2 to dict_1
after updating spans in dict_2 with length of sentence before it"""
dict_2 = fix_spans(dict_2, prev_sentence_len)
for action in dict_2["action_sequence"]:
dict_1["action_sequence"].append(action)
return dict_1
def create_composite_action(action_1, action_2):
"""This function takes in two actions, combines their texts together and
combines their dicts"""
text_1, text_2 = action_1.generate_description(), action_2.generate_description()
dict_1, dict_2 = action_1.to_dict(), action_2.to_dict()
# in case there are compostite schematics in either actions, expand action_sequence
# to accomodate them
dict_1 = fix_composite_in_dict(text_1, dict_1)
dict_2 = fix_composite_in_dict(text_2, dict_2)
# combine the sentences together
prev_text = text_1[0] + random.choice([" and ", " and then "])
composite_text = prev_text + text_2[0]
prev_action_length = len(prev_text.split())
# combine the dicts together
composite_dict = combine_dicts(dict_1, dict_2, prev_action_length)
return [composite_text], composite_dict
def generate_actions(n, action_type=None, template_attributes={}, composite=False):
""" Generate action tree and language based on action type """
texts = []
dicts = []
for _ in range(n):
# pick an action name
action_name = (
random.choice(action_type)
if type(action_type) is list
else action_type_map[action_type]
)
composite_flag = None
# if None, no preference mentioned, pick True at random
if composite is None:
composite_flag = True if random.random() < 0.3 else False
else:
# assign preference (True or False)
composite_flag = composite
# if composite flag is True, generate composite action
if composite_flag and action_name in human_give_command_actions:
template_attributes["dialogue_len"] = 1
# check how to optimize this call
action_1 = Action.generate(action_type=action_name, template_attr=template_attributes)
# pick another from human_give_command_actions
possible_choices = human_give_command_actions
next_action = random.choice(possible_choices)
action_2 = Action.generate(action_type=next_action, template_attr=template_attributes)
action_text, action_dict = create_composite_action(action_1, action_2)
elif composite_flag == False:
template_attributes["no_inbuilt_composites"] = True
action_1 = Action.generate(action_type=action_name, template_attr=template_attributes)
action_text = action_1.generate_description()
action_dict = action_1.to_dict()
action_dict = fix_composite_in_dict(action_text, action_dict)
else:
action_1 = Action.generate(action_type=action_name, template_attr=template_attributes)
action_text = action_1.generate_description()
action_dict = action_1.to_dict()
action_dict = fix_composite_in_dict(action_text, action_dict)
# else generate composite action at random
texts.append(action_text)
dicts.append(action_dict)
return texts, dicts
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-n", type=int, default=100)
parser.add_argument("--seed", "-s", type=int, default=0)
parser.add_argument("--chats_file", "-chats", type=str, default="noop_dataset.txt")
parser.add_argument("--action_type", default=Action.CHOICES)
parser.add_argument(
"--composite_action",
action="store_true",
help="this flag tells the script to create composite actions only",
)
parser.add_argument(
"--no_composite_actions",
action="store_true",
help="this flag tells the script to create no composite actions",
)
parser.add_argument(
"--length_range", nargs="+", default=None, help="Low and High for range of length"
)
parser.add_argument(
"--width_range", nargs="+", default=None, help="Low and High for range of width"
)
parser.add_argument(
"--depth_range", nargs="+", default=None, help="Low and High for range of depth"
)
parser.add_argument(
"--height_range", nargs="+", default=None, help="Low and High for range of height"
)
parser.add_argument(
"--size_range", nargs="+", default=None, help="Low and High for range of size"
)
parser.add_argument(
"--thickness_range", nargs="+", default=None, help="Low and High for range of thickness"
)
parser.add_argument(
"--radius_range", nargs="+", default=None, help="Low and High for range of radius"
)
parser.add_argument(
"--base_range", nargs="+", default=None, help="Low and High for range of base"
)
parser.add_argument(
"--slope_range", nargs="+", default=None, help="Low and High for range of slope"
)
parser.add_argument(
"--distance_range", nargs="+", default=None, help="Low and High for range of distance"
)
parser.add_argument(
"--step_range", nargs="+", default=None, help="Low and High for range of steps"
)
parser.add_argument(
"--coordinates_range",
nargs="+",
default=None,
help="Low and High for range of coordinates",
)
parser.add_argument(
"--count_range",
nargs="+",
default=None,
help="Low and High for range of count / repetitions",
)
parser.add_argument(
"--non_shape_names",
type=str,
default=None,
help="The file containing names of supported schematics (non standard shapes)",
)
parser.add_argument(
"--mob_file", type=str, default=None, help="The file containing names of supported mobs"
)
parser.add_argument(
"--block_types_file",
type=str,
default=None,
help="The file containing supported block objects",
)
args = parser.parse_args()
# load file containing negative examples of chats
try:
f = open(args.chats_file)
chats = [line.strip() for line in f]
f.close()
Noop.CHATS += [
x
for x in chats
if x
not in [
"good job",
"cool",
"that is really cool",
"that is awesome",
"awesome",
"that is amazing",
"that looks good",
"you did well",
"great",
"good",
"nice",
"that is wrong",
"that was wrong",
"that was completely wrong",
"not that",
"that looks horrible",
"that is not what i asked",
"that is not what i told you to do",
"that is not what i asked for",
"not what i told you to do",
"you failed",
"failure",
"fail",
"not what i asked for",
"where are you",
"tell me where you are",
"i do n't see you",
"i ca n't find you",
"are you still around",
"what are you doing",
"now what are you building",
"tell me what are you doing",
"what is your task",
"tell me your task",
"what are you up to",
"stop",
"wait",
"where are you going",
"what is this",
"come here",
"mine",
"what is that thing",
"come back",
"go back",
"what is that",
"keep going",
"tower",
"follow me",
"do n't do that",
"do n't move",
"hold on",
"this is pretty",
"continue",
"can you follow me",
"move",
"this is nice",
"this is sharp",
"this is very big",
"keep digging",
"circle",
"that is sharp",
"it looks nice",
]
]
except:
print("chats file not found")
random.seed(args.seed)
template_attributes = {}
arg_dict = args.__dict__
for key in arg_dict:
if arg_dict[key]:
# Assign numeric ranges
if key in arg_numeric_range_map:
low, high = [int(x) for x in arg_dict[key]]
template_attributes[arg_numeric_range_map[key]] = range(low, high)
# Assign names of schematic and reference objects
elif key in arg_name_file_map:
with open(arg_dict[key]) as f:
template_attributes[arg_name_file_map[key]] = [
line.strip() for line in f.readlines()
]
composite_flag = None
# assign composite_flag if user explcitly mentioned to create / avoid them
# else pick True at random inside generate_actions()
if args.composite_action:
composite_flag = True
if args.no_composite_actions:
composite_flag = False
for text, d in zip(
*generate_actions(
args.n,
args.action_type,
template_attributes=template_attributes,
composite=composite_flag,
)
):
for sentence in text:
print(sentence)
print(json.dumps(d))
print()
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_dialogue.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains utility functions used for the generation pipeline.
"""
import random
import re
ABERRANT_PLURAL_MAP = {
"appendix": "appendices",
"barracks": "barracks",
"cactus": "cacti",
"child": "children",
"criterion": "criteria",
"deer": "deer",
"echo": "echoes",
"elf": "elves",
"embargo": "embargoes",
"focus": "foci",
"fungus": "fungi",
"goose": "geese",
"hero": "heroes",
"hoof": "hooves",
"index": "indices",
"knife": "knives",
"leaf": "leaves",
"life": "lives",
"man": "men",
"mouse": "mice",
"nucleus": "nuclei",
"person": "people",
"phenomenon": "phenomena",
"potato": "potatoes",
"self": "selves",
"syllabus": "syllabi",
"tomato": "tomatoes",
"torpedo": "torpedoes",
"veto": "vetoes",
"woman": "women",
}
VOWELS = set("aeiou")
# A class for flagging when a value is updated.
class Arguments(dict):
values_updated = False
def __setitem__(self, item, value):
self.values_updated = True
super(Arguments, self).__setitem__(item, value)
def pick_random(prob=0.5):
"""Return True if given prob > random"""
if random.random() < prob:
return True
return False
def prepend_a_an(name):
"""Add a/an to a name"""
if name[0] in ["a", "e", "i", "o", "u"]:
return "an " + name
else:
return "a " + name
def make_plural(word):
"""Make plural of a given lowercase word word.
# Taken from : http://code.activestate.com/recipes/
577781-pluralize-word-convert-singular-word-to-its-plural/
"""
if not word:
return ""
plural = ABERRANT_PLURAL_MAP.get(word)
if plural:
return plural
root = word
try:
if word[-1] == "y" and word[-2] not in VOWELS:
root = word[:-1]
suffix = "ies"
elif word[-1] == "s":
if word[-2] in VOWELS:
if word[-3:] == "ius":
root = word[:-2]
suffix = "i"
else:
root = word[:-1]
suffix = "ses"
else:
suffix = "es"
elif word[-2:] in ("ch", "sh"):
suffix = "es"
elif word[-1] in ("x", "h"):
suffix = "es"
else:
suffix = "s"
except IndexError:
suffix = "s"
plural = root + suffix
return plural
def to_snake_case(word, case="lower"):
"""convert a given word to snake case"""
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", word)
snake_case = re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1)
if case == "upper":
return snake_case.upper()
return snake_case.lower()
def update_dict_with_span(action_dict, split, arg_types, args):
"""Update the given action_dict with spans for certain keys"""
for arg_type, arg in zip(arg_types, args):
arg_dict = arg.to_dict()
for key, val in arg_dict.items():
if (key.startswith("has_")) or (key == "Coordinates"):
arg_dict[key] = find_span(split, val)
action_dict.update({to_snake_case(arg_type.__name__): arg_dict})
return action_dict
def values_of_nested_dict(d):
"""Return all values of a nested dictionary"""
for v in d.values():
if isinstance(v, dict):
yield from values_of_nested_dict(v)
else:
yield v
def variants(sublist, int_list=False):
"""Find all supported variants of items in the sublist"""
result = []
result.append(sublist)
if int_list:
if len(sublist) == 3:
result.append([sublist[0], ",", sublist[1], ",", sublist[2]])
result.append([sublist[0], "x", sublist[1], "x", sublist[2]])
result.append([sublist[0], "by", sublist[1], "by", sublist[2]])
result.append(["(", sublist[0], sublist[1], sublist[2], ")"])
result.append(["(", sublist[0], ",", sublist[1], ",", sublist[2], ")"])
elif len(sublist) == 2:
result.append([sublist[0], ",", sublist[1]])
result.append([sublist[0], "x", sublist[1]])
result.append([sublist[0], "by", sublist[1]])
result.append(["(", sublist[0], sublist[1], ")"])
result.append(["(", sublist[0], ",", sublist[1], ")"])
return result
def find_sub_list(sublist, full_list, int_list=False):
"""Find start and end indices of sublist in full_list."""
sublist = [str(x) for x in sublist]
sublist_len = len(sublist)
# find all start indices for the first word in the text
indices = []
for i, e in enumerate(full_list):
if e == sublist[0]:
indices.append(i)
for index in indices:
start_idx = index
end_idx = index + sublist_len
if full_list[index - 1] == "(":
start_idx = index - 1
# if ( a , b , c )
if full_list[index + 1] == ",":
end_idx = start_idx + sublist_len + 4
else:
# ( a b c)
end_idx = start_idx + sublist_len + 2
# if text : a , b , c
# or a x b x c
# or a by b by c
elif (index + 1 < len(full_list)) and full_list[index + 1] in [",", "x", "by"]:
if sublist_len == 3:
end_idx = start_idx + sublist_len + 2
elif sublist_len == 2:
end_idx = start_idx + sublist_len + 1
# whole sublist has to fit, except when it is coordinates.
# coordinates can have different formats returned by variants().
if full_list[start_idx:end_idx] in variants(sublist, int_list):
return start_idx, end_idx - 1
return None
def find_span(input_list, val):
"""Find span of val in input_list"""
int_list = True
if type(val) == int:
val = str(val)
if type(val) == str:
if len(val.split()) > 1:
val = val.split()
int_list = False
found_index = 0
for i, sentence_split in enumerate(input_list):
if type(val) in [list, tuple]:
result = find_sub_list(val, sentence_split, int_list)
if result:
found_index = i
start, end = result
elif val in sentence_split:
found_index = i
start = sentence_split.index(val)
end = start
return [len(input_list) - found_index - 1, [start, end]]
def flatten_dict(d):
"""Flatten out a nested dictionary"""
def expand(key, value):
if isinstance(value, dict):
return [(k, v) for k, v in flatten_dict(value).items()]
else:
return [(key, value)]
items = [item for k, v in d.items() for item in expand(k, v)]
return dict(items)
def int_to_words(num):
"""Given an int32 number, print it in words in English.
Taken from: https://stackoverflow.com/a/32640407
"""
d = {
0: "zero",
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
9: "nine",
10: "ten",
11: "eleven",
12: "twelve",
13: "thirteen",
14: "fourteen",
15: "fifteen",
16: "sixteen",
17: "seventeen",
18: "eighteen",
19: "nineteen",
20: "twenty",
30: "thirty",
40: "forty",
50: "fifty",
60: "sixty",
70: "seventy",
80: "eighty",
90: "ninety",
}
k = 1000
m = k * 1000
b = m * 1000
t = b * 1000
assert 0 <= num
if num < 20:
return d[num]
if num < 100:
if num % 10 == 0:
return d[num]
else:
return d[num // 10 * 10] + " " + d[num % 10]
if num < k:
if num % 100 == 0:
return d[num // 100] + " hundred"
else:
return d[num // 100] + " hundred and " + int_to_words(num % 100)
if num < m:
if num % k == 0:
return int_to_words(num // k) + " thousand"
else:
return int_to_words(num // k) + " thousand " + int_to_words(num % k)
if num < b:
if (num % m) == 0:
return int_to_words(num // m) + " million"
else:
return int_to_words(num // m) + " million " + int_to_words(num % m)
if num < t:
if (num % b) == 0:
return int_to_words(num // b) + " billion"
else:
return int_to_words(num // b) + " billion " + int_to_words(num % b)
if num % t == 0:
return int_to_words(num // t) + " trillion"
else:
return int_to_words(num // t) + " trillion " + int_to_words(num % t)
raise AssertionError("Number is too large: %s" % str(num))
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_utils.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with Undo command.
"""
import random
from .template_object import *
#####################
### UNDO TEMPLATES ##
#####################
class ActionBuild(TemplateObject):
"""This template object repesents that the target action is Build."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Undo" in template_names:
phrases = [
"what you just built",
"what you made",
"the build action",
"the construction",
"what you built",
]
elif "Stop" in template_names:
phrases = ["building", "constructing", "completing"]
elif "Dont" in template_names:
phrases = [
"build anymore",
"build any more copies",
"build anything",
"make anything",
"construct anything",
"copy anything",
]
elif "Resume" in template_names:
phrases = ["building", "copying", "making copies"]
self.words = random.choice(phrases)
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
class ActionDestroy(TemplateObject):
"""This template object repesents that the target action is Destroy."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Undo" in template_names:
phrases = ["what you destroyed", "the destruction", "the destroy action"]
elif "Stop" in template_names:
phrases = ["destroying", "excavating", "destructing"]
elif "Dont" in template_names:
phrases = ["destroy anything", "destroy", "do the destroy action"]
elif "Resume" in template_names:
phrases = ["destroying", "excavating"]
self.words = random.choice(phrases)
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
class ActionFill(TemplateObject):
"""This template object repesents that the target action is Fill."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Undo" in template_names:
phrases = [
"what you just filled",
"filling",
"the fill action",
"the filling action",
"filling that",
"filling the hole",
]
elif "Stop" in template_names:
phrases = ["filling", "filling holes"]
elif "Dont" in template_names:
phrases = ["fill", "do the fill action"]
elif "Resume" in template_names:
phrases = ["filling"]
self.words = random.choice(phrases)
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
# NOTE(kavya): this should become a delete for undo tag. And How about for resume and stop ?
class ActionTag(TemplateObject):
"""This template object repesents that the target action is Tag."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Stop" in template_names:
command = random.choice(["tagging", "the tag action", "labeling"])
elif "Dont" in template_names:
command = random.choice(
["tag", "tag anything", "do any tagging", "do any labeling", "label anything"]
)
elif "Resume" in template_names:
command = random.choice(["tagging", "labeling"])
else:
phrases = [
"undo what you tagged",
"undo the tagging",
"undo the tag",
"undo the tag action",
"reset the tag action",
"forget I tagged that",
"forget that tag",
]
phrase = random.choice(phrases)
prefix = random.choice(["", random.choice(["can you", "please", "can you please"])])
command = (" ".join([prefix, phrase])).strip()
self.words = command
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
class ActionDig(TemplateObject):
"""This template object repesents that the target action is Dig."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Undo" in template_names:
phrases = ["what you dug", "the digging", "the hole", "the dig action", "digging"]
elif "Stop" in template_names:
phrases = ["digging"]
elif "Dont" in template_names:
phrases = ["dig", "dig anything"]
elif "Resume" in template_names:
phrases = ["digging"]
self.words = random.choice(phrases)
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
class ActionMove(TemplateObject):
"""This template object repesents that the target action is Move."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index=templ_index)
if "Stop" in template_names:
phrases = ["walking", "moving"]
elif "Dont" in template_names:
phrases = ["walk", "move"]
elif "Resume" in template_names:
phrases = ["moving", "walking"]
self.words = random.choice(phrases)
self.node.target_action_type = self.words
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.words
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/undo_commands.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with BlockObjects.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
from .location import *
#############################
### BLOCKOBJECT TEMPLATES ###
#############################
# TODO: refactor this function.
def define_block_object_type(
template_obj,
template_obj_name,
index,
reference_type=None,
block_obj_name=PointedObject,
templ_index=0,
):
template = get_template_names(template_obj, templ_index)
previous_template = None
if templ_index - 1 >= 0:
previous_template = get_template_names(template_obj, templ_index - 1)
if (
(
any(
x
in [
"Dig",
"Fill",
"FreebuildLocation",
"Copy",
"Build",
"BuildSingle",
"Stack",
"Place",
"Surround",
]
for x in template
)
or (
previous_template
and any(
x
in [
"Fill",
"FreebuildLocation",
"Copy",
"Build",
"BuildSingle",
"Stack",
"Place",
"Surround",
]
for x in previous_template
)
)
)
and (
(index - 1 >= 0)
and (
template[index - 1]
in ["RelativeDirectionTemplate", "Around", "Surround", "Between"]
)
)
) or (any(x in ["Move", "Stand", "Down"] for x in template)):
if (
"Between" in template
and type(template_obj.node._location_args["location_type"]) is list
):
template_obj.node._location_args["location_type"].append(BlockObject)
template_obj.node._location_args["bo_coref_resolve"].append(reference_type)
else:
template_obj.node._location_args["location_type"] = [BlockObject]
template_obj.node._location_args["bo_coref_resolve"] = [reference_type]
else:
template_obj.node._block_obj_args["block_object_type"] = block_obj_name # at SpeakerLook
if reference_type:
template_obj.node._block_obj_args["coref_type"] = reference_type
# If this is the last template object, no children
# If followed by is/looks like, no child
# If followed by a location, no child
location_template_names = [loc.__name__ for loc in LOCATION_TEMPLATES]
if (
(template[-1] == template_obj_name)
or (
any(
x
in [
"BlockObjectThat",
"BlockObjectCoref",
"BlockObjectThese",
"BlockObjectThose",
"BlockObjectThis",
"BlockObjectIt",
]
for x in template
)
)
or (template[index + 1] in ["NTimes", "ForMe", "TagDesc", "TagName"])
or (
(
index + 1 < len(template)
and (template[index + 1] in ["Is", "Looks", "With"] + location_template_names)
)
)
):
template_obj.node._block_obj_args["no_child"] = True
class BlockObjectCoref(TemplateObject):
"""This template object represents a BlockObject where the Speaker is pointing.
("this")"""
def add_generate_args(self, index=0, templ_index=0):
self._words = random.choice(
[
"what you built",
"what you just built",
"what you built just now",
"what you made",
"what you constructed just now",
]
)
define_block_object_type(
self,
"BlockObject",
index,
reference_type="yes", # self._words,
block_obj_name=None,
templ_index=templ_index,
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._words
class BlockObjectThis(TemplateObject):
"""This template object represents a BlockObject that can be a coreference.
("this")"""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
self._coref_val = "yes" # "this"
if any(x in ["RepeatAll", "RepeatCount"] for x in template_names):
self._coref_val = random.choice(["these", "those"])
define_block_object_type(
self, "BlockObjectThis", index, reference_type=self._coref_val, templ_index=templ_index
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._coref_val
class BlockObjectThese(TemplateObject):
"""This template object represents a BlockObject that can be a coreference
("these")"""
def add_generate_args(self, index=0, templ_index=0):
# "these"
define_block_object_type(
self, "BlockObjectThese", index, reference_type="yes", templ_index=templ_index
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "these"
class BlockObjectThat(TemplateObject):
"""This template object represents a BlockObject that can be a coreference
("that")"""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
self._word = "that"
if any(x in ["RepeatCountLocation", "RepeatAllLocation"] for x in template_names):
self._word = random.choice(["these", "those"])
elif index + 1 < len(template_names) and template_names[index + 1] == "RepeatCount":
self._word = random.choice(["these", "those"])
self._coref_val = "yes" # self._word
define_block_object_type(
self, "BlockObjectThat", index, reference_type=self._coref_val, templ_index=templ_index
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
template_names = get_template_names(self, templ_index)
if index + 1 < len(template_names):
if template_names[index + 1] == "RepeatAllLocation":
self._word = " ".join([random.choice(["each of", "all of"]), self._word])
elif template_names[index + 1] == "RepeatCountLocation":
if "object_prefix" in description:
count = description["object_prefix"]
elif (
"block_object" in description
and "object_prefix" in description["block_object"]
):
count = description["block_object"]["object_prefix"]
self._word = " ".join([count, "of", self._word])
return self._word
class BlockObjectIt(TemplateObject):
"""This template object represents a BlockObject that can be a coreference.
("it")"""
def add_generate_args(self, index=0, templ_index=0):
# "it"
define_block_object_type(
self, "BlockObjectIt", index, reference_type="yes", templ_index=templ_index
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "it"
class BlockObjectThose(TemplateObject):
"""This template object represents a BlockObject that can be a coreference.
("those")"""
def add_generate_args(self, index=0, templ_index=0):
# "those"
define_block_object_type(
self, "BlockObjectThose", index, reference_type="yes", templ_index=templ_index
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "those"
class AbstractDescription(TemplateObject):
"""This template object represents abstract description of a block object
like: 'object', 'thing' etc"""
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
if ("RepeatCount" in all_names) or ("All" in all_names):
# plural
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("objects")
else:
self.node._block_obj_args["block_object_attributes"] = ["objects"]
else:
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("object")
else:
self.node._block_obj_args["block_object_attributes"] = ["object"]
if "HumanReplace" in all_names:
if any(
x
in [
"BlockObjectThis",
"BlockObjectThat",
"BlockObjectIt",
"BlockObjectThose",
"BlockObjectThese",
]
for x in prev_template_names
):
# unset the coref resolve if it was set in previous command
if self.node._block_obj_args["coref_type"]:
self.node._block_obj_args["coref_type"] = None
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["object"]
prev_template_names = None
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
if prev_template_names and "RepeatCount" in prev_template_names:
word = make_plural(word)
return word
class ConcreteDescription(TemplateObject):
"""This template object represents concrete description / name of a block object"""
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
if ("RepeatCount" in all_names) or ("All" in all_names):
# plural
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("names")
else:
self.node._block_obj_args["block_object_attributes"] = ["names"]
else:
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("name")
else:
self.node._block_obj_args["block_object_attributes"] = ["name"]
if "HumanReplace" in all_names:
if any(
x
in [
"BlockObjectThis",
"BlockObjectThat",
"BlockObjectIt",
"BlockObjectThose",
"BlockObjectThese",
]
for x in prev_template_names
):
# unset the coref resolve if it was set in previous command
if self.node._block_obj_args["coref_type"]:
self.node._block_obj_args["coref_type"] = None
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["name"]
node_template = get_template_names(self, templ_index)
if node_template[index - 1] == "Copy":
word = random.choice([word, prepend_a_an(word)])
if "AskIs" in node_template and index == len(node_template) - 1:
word = prepend_a_an(word)
return word
class Colour(TemplateObject):
"""This template object ensures that the blockobject has a colour and is used
to separate out the attributes, one at a time."""
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
if "HumanReplace" in all_names:
if any(
x
in [
"BlockObjectThis",
"BlockObjectThat",
"BlockObjectIt",
"BlockObjectThose",
"BlockObjectThese",
]
for x in prev_template_names
):
# unset the coref resolve if it was set in previous command
if self.node._block_obj_args["coref_type"]:
self.node._block_obj_args["coref_type"] = None
self.node._block_obj_args["block_object_type"] = Object
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("colour")
else:
self.node._block_obj_args["block_object_attributes"] = ["colour"]
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["colour"]
return word
class Size(TemplateObject):
"""This template object ensures that the blockobject has a size and is used
to separate out the attributes, one at a time."""
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
if "HumanReplace" in all_names:
if any(
x
in [
"BlockObjectThis",
"BlockObjectThat",
"BlockObjectIt",
"BlockObjectThose",
"BlockObjectThese",
]
for x in prev_template_names
):
# unset the coref resolve if it was set in previous command
if self.node._block_obj_args["coref_type"]:
self.node._block_obj_args["coref_type"] = None
self.node._block_obj_args["block_object_type"] = Object
if self.node._block_obj_args["block_object_attributes"]:
self.node._block_obj_args["block_object_attributes"].append("size")
else:
self.node._block_obj_args["block_object_attributes"] = ["size"]
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["size"]
return word
class BlockObjectLocation(TemplateObject):
"""This template object ensures that the blockobject has a location."""
def add_generate_args(self, index=0, templ_index=0):
curr_template_names = get_template_names(self, templ_index)
if templ_index - 1 >= 0:
prev_template_names = get_template_names(self, templ_index - 1)
# For Answer action, make child None and location specific
if curr_template_names[1] in ["What", "WhatSee", "AskIs", "AskSize"]:
self.node._block_obj_args["block_object_location"] = random.choice([BlockObject, Mob])
self.node._block_obj_args["no_child"] = True
elif "HumanReplace" in curr_template_names:
if any(
x
in [
"What",
"AskSize",
"AskColour",
"AskIs",
"Copy",
"Destroy",
"TagDesc",
"TagName",
]
for x in prev_template_names
):
self.node._block_obj_args["block_object_location"] = random.choice(
[BlockObject, Mob]
)
self.node._block_obj_args["no_child"] = True
# if BO type was set to Pointed Object, reset it
if any(
x
in [
"BlockObjectThis",
"BlockObjectThat",
"BlockObjectIt",
"BlockObjectThose",
"BlockObjectThese",
]
for x in prev_template_names
):
# unset the coref resolve if it was set in previous command
if self.node._block_obj_args["coref_type"]:
self.node._block_obj_args["coref_type"] = None
self.node._block_obj_args["block_object_type"] = Object
else:
# pick any random location
self.node._block_obj_args["block_object_location"] = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["location"]
return word
BLOCKOBJECT_TEMPLATES = [
BlockObjectIt,
AbstractDescription,
ConcreteDescription,
Colour,
Size,
BlockObjectLocation,
BlockObjectThat,
BlockObjectThis,
BlockObjectThese,
BlockObjectCoref,
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/block_object.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with the Mob tree component.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
#####################
### MOB TEMPLATES ###
#####################
def set_mob_location(template_obj, location):
template_obj.node._mob_args["mob_location"] = location
# Note: this is for "this pig", no coref resolution needed
class MobThis(TemplateObject):
"""This template object represents 'this' mob"""
def add_generate_args(self, index=0, templ_index=0):
set_mob_location(self, SpeakerLook)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "this"
# Note: this is for "that pig", no coref resolution needed
class MobThat(TemplateObject):
"""This template object represents 'that' mob"""
def add_generate_args(self, index=0, templ_index=0):
set_mob_location(self, SpeakerLook)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "that"
class MobLocation(TemplateObject):
"""This template object ensures that Mob has a location"""
def add_generate_args(self, index=0, templ_index=0):
set_mob_location(self, "ANY")
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["location"]
return word
class MobName(TemplateObject):
"""This template object sets the argument type to be a Mob"""
def add_generate_args(self, index=0, templ_index=0):
self.node._arg_type = Mob
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_name = get_template_names(self, templ_index)
description = self.node.args[arg_index].generate_description()
if any(x in ["RepeatAll", "RepeatCount"] for x in template_name) and (
"mob_prefix" in description
):
return " ".join([description["mob_prefix"], description["mob"]])
elif "Spawn" in template_name:
mob_name = description["mob"]
# append a/an randomly: "Spawn pig" / "Spawn a pig"
return random.choice([mob_name, prepend_a_an(mob_name)])
return description["mob"]
MOB_TEMPLATES = [MobThis, MobThat, MobLocation, MobName]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/mob.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated specifically with the
Answer action.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
########################
### ANSWER TEMPLATES ###
########################
class What(TemplateObject):
'''This template object represents questions of type "what .."'''
def add_generate_args(self, index=0, templ_index=0):
self.node.answer_type = "TAG"
self.node.tag_name = "has_name"
self.node._filters_args["mem_type"] = "REFERENCE_OBJECT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["what", "what do you think"])
return phrase
class WhatSee(TemplateObject):
'''This template object represents questions of type: "what do you see at.."'''
def add_generate_args(self, index=0, templ_index=0):
self.node.answer_type = "TAG"
self.node.tag_name = "has_name"
self.node._filters_args["mem_type"] = "REFERENCE_OBJECT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["what do you see", "what do you observe"])
return phrase
class AskSize(TemplateObject):
'''This template object repesents questions of type: "what size is.."'''
def add_generate_args(self, index=0, templ_index=0):
self.node.answer_type = "TAG"
self.node.tag_name = "has_size"
self.node._filters_args["mem_type"] = "REFERENCE_OBJECT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
size_options = random.choice(
["what size is", "what size do you think is", "what is the size of"]
)
phrase = random.choice([size_options])
return phrase
class AskColour(TemplateObject):
'''This template object repesents questions of type: "what colour is.."'''
def add_generate_args(self, index=0, templ_index=0):
self.node.answer_type = "TAG"
self.node.tag_name = "has_colour"
self.node._filters_args["mem_type"] = "REFERENCE_OBJECT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(
[
"what colour is",
"what colour do you think is",
"what is the colour of",
"what color is",
"what color do you think is",
"what is the color of",
]
)
return phrase
class AskIs(TemplateObject):
'''This template object repesents questions of type: "is .."'''
def add_generate_args(self, index=0, templ_index=0):
self.node.answer_type = "EXISTS"
self.node._filters_args["mem_type"] = "REFERENCE_OBJECT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["is"])
return phrase
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/answer.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with repeats and stop
conditions.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
################################
### STOP CONDITION TEMPLATES ###
################################
"""Assign the repeat_val to the tree"""
def assign_repeat_key(template_obj, repeat_val, templ_index=0):
template_names = get_template_names(template_obj, templ_index)
if any(x in ["Build", "BuildSingle", "Stack", "Place"] for x in template_names):
template_obj.node._location_args["repeat_key"] = repeat_val
elif any(x in ["Dig", "Fill"] for x in template_names):
template_obj.node._location_args["repeat_key"] = repeat_val
elif any(x in ["Destroy", "Freebuild"] for x in template_names):
template_obj.node._block_obj_args["block_object_location"] = random.choice(
[BlockObject, Mob]
)
template_obj.node._block_obj_args["repeat_location"] = repeat_val
elif "Tag" in template_names:
if "MobName" in template_names:
template_obj.node._mob_args["mob_location"] = random.choice([BlockObject, Mob])
template_obj.node._mob_args["repeat_location"] = repeat_val
else:
template_obj.node._block_obj_args["block_object_location"] = random.choice(
[BlockObject, Mob]
)
template_obj.node._block_obj_args["repeat_location"] = repeat_val
class RepeatAllLocation(TemplateObject):
"""This template object repesents all / every / each for blockobject / mob used
as a reference for location.
eg: explode the disk on top of all the creepers"""
def add_generate_args(self, index=0, templ_index=0):
assign_repeat_key(self, "ALL", templ_index=templ_index)
class RepeatCountLocation(TemplateObject):
"""This template object repesents a count for blockobject / mob used
as a reference for location.
eg: Make a hole below 5 houses"""
def add_generate_args(self, index=0, templ_index=0):
assign_repeat_key(self, "FOR", templ_index=templ_index)
class RepeatCount(TemplateObject):
"""This template object repesents a count for blockobject / mob / schematic
eg: Make 5 holes there"""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if any(x in ["Build", "Stack", "Place"] for x in template_names):
self.node._schematics_args["repeat_key"] = "FOR"
elif any(x in ["Dig", "Fill"] for x in template_names):
count = random.choice(self.template_attr.get("count", range(2, 15)))
self.node._repeat_args["repeat_key"] = "FOR"
self.node._repeat_args["repeat_count"] = random.choice(
[str(count), int_to_words(count), "a few", "some"]
)
elif any(x in ["Destroy", "Freebuild"] for x in template_names):
self.node._block_obj_args["repeat_key"] = "FOR"
elif "Copy" in template_names:
self.node._block_obj_args["repeat_key"] = "FOR"
self.node._block_obj_args["no_child"] = True
elif "Tag" in template_names:
if "MobName" in template_names:
self.node._mob_args["repeat_key"] = "FOR"
else:
self.node._block_obj_args["repeat_key"] = "FOR"
self.node._block_obj_args["no_child"] = True
elif "Spawn" in template_names:
self.node._mob_args["repeat_key"] = "FOR"
def generate_description(self, arg_index=0, index=0, templ_index=0):
if len(self.node.args) > 0:
description = self.node.args[arg_index].generate_description()
if "object_prefix" in description:
return description["object_prefix"]
template_names = get_template_names(self, templ_index)
if ("Dig" in template_names) or ("Fill" in template_names):
return self.node._repeat_args["repeat_count"]
return None
class Around(TemplateObject):
"""This TemplateObject populates the repeat_dir as "Around" """
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["repeat_dir"] = "AROUND"
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "around"
class Surround(TemplateObject):
"""This TemplateObject populates the repeat_dir as "SURROUND" """
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["repeat_key"] = "ALL"
self.node._schematics_args["repeat_dir"] = "SURROUND"
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "surround"
class RepeatAll(TemplateObject):
"""This template object repesents "All" for blockobject / mob / schematic
eg: Tag every house as brown"""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
template_len = len(template_names) - 1
# only for destroy everything.
if (template_len == 2) and ("DestroySingle" in template_names):
self.node._block_obj_args["repeat_no_child"] = True
if "Build" in template_names:
self.node._schematics_args["repeat_key"] = "ALL"
elif any(x in ["Destroy", "Freebuild", "DestroySingle"] for x in template_names):
self.node._block_obj_args["repeat_key"] = "ALL"
elif "Copy" in template_names:
self.node._block_obj_args["repeat_key"] = "ALL"
self.node._block_obj_args["no_child"] = True
elif "Fill" in template_names:
self.node._repeat_args["repeat_key"] = "ALL"
elif "Tag" in template_names:
if "MobName" in template_names:
self.node._mob_args["repeat_key"] = "ALL"
else:
self.node._block_obj_args["repeat_key"] = "ALL"
self.node._block_obj_args["no_child"] = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if ("Copy" in template_names) and (len(self.node.args) > 0):
description = self.node.args[arg_index].generate_description()
if "object_prefix" in description:
return description["object_prefix"]
if "Fill" in template_names:
return random.choice(["all", "all the"])
return None
class ConditionTypeNever(TemplateObject):
"""This template object repesents the condition type "Never" for the Stop Condition
i.e. infinite loops.
eg: Follow me"""
def add_generate_args(self, index=0, templ_index=0):
self.node._condition_args["condition_type"] = "NEVER"
class ConditionTypeAdjacentBlockType(TemplateObject):
"""This template object repesents the condition type "adjacent to block type"
for Stop Condition i.e. stop when you are adjacent to a certain block type.
eg: Dig until you hit bedrock"""
def add_generate_args(self, index=0, templ_index=0):
self.node._condition_args["condition_type"] = "ADJACENT_TO_BLOCK_TYPE"
self.node._condition_args["block_type"] = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
block_type = description["block_type"]
template_names = get_template_names(self, templ_index)
prefixes = ["until you see", "until you reach", "until you find", "down to", "for"]
if "DownTo" in template_names:
prefixes = [""]
elif template_names[1] == "Dig": # some Move templates also have this
prefixes.append("until you hit")
prefix = random.choice(prefixes)
phrase = " ".join([prefix, block_type]).strip()
return phrase
CONDIITON_TEMPLATES = [ConditionTypeNever, ConditionTypeAdjacentBlockType]
REPEAT_KEY_TEMPLATES = [RepeatCount, RepeatAll]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/repeat_and_condition.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with Fill action.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
from .dig import *
#####################
## FILL TEMPLATES ###
#####################
class FillShape(TemplateObject):
"""This template object repesents the shape/ thing that needs to be filled."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
phrase = random.choice(dig_shapes)
if any(x in ["RepeatCount", "RepeatAll"] for x in template_names):
phrase = make_plural(random.choice(dig_shapes))
self.node.reference_object["has_name"] = phrase
self._phrase = phrase
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._phrase
# Note: this is for "fill that mine" , no coref resolution needed
class FillObjectThis(TemplateObject):
"""This template object repesents that the thing to be filled is where the speaker
is looking."""
def add_generate_args(self, index=0, templ_index=0):
self.node.reference_object["contains_coreference"] = "yes"
phrases = ["this", "that"]
template_names = get_template_names(self, templ_index)
if any(x in ["RepeatCount", "RepeatAll"] for x in template_names):
phrases = ["these", "those"]
self._word = random.choice(phrases)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._word
class FillBlockType(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node.has_block_type = random.choice(
self.template_attr.get("block_types", BLOCK_TYPES)
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self.node.has_block_type
class UseFill(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["use", "fill using", "fill with"])
return phrase
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/fill.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains common template objects used across different templates.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
#######################
## DANCE TEMPLATES ##
#######################
"""
Fly
Jump
Hop
Dance
Dance clockwise (#4 with repeat_dir)
Dance in a loop
"""
class Fly(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
command = ["fly", "fly"]
if index + 1 < len(all_names) and all_names[index + 1] == "ConditionTypeNever":
command = random.choice(
[["flying", "keep flying"], ["fly", "fly until I tell you to stop"]]
)
self.node.dance_type_name = command[0]
self.node._dance_text = command[1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = self.node._dance_text
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
class Jump(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
command = ["jump", "jump"]
if index + 1 < len(all_names) and all_names[index + 1] == "ConditionTypeNever":
command = random.choice(
[["jumping", "keep jumping"], ["jump", "jump until I tell you to stop"]]
)
self._dance_text = command[1]
self.node.dance_type_name = command[0]
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = self._dance_text
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = " ".join([prefix, command]).strip()
return new_command
class Walk(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node.dance_pattern = "MOVE_AROUND"
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["move", "walk", "go"])
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
class Hop(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
command = ["hop", "hop"]
if index + 1 < len(all_names) and all_names[index + 1] == "ConditionTypeNever":
command = random.choice(
[["hopping", "keep hopping"], ["hop", "hop until I tell you to stop"]]
)
self.node.dance_type_name = command[0]
self.node._dance_text = command[1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = self.node._dance_text
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/dance.py |
# fmt: off
from .action_names import *
from .answer import *
from .block_object import *
from .common import *
from .dig import *
from .fill import *
from .location import *
from .mob import *
from .schematics import *
from .special_shape_commands import *
from .repeat_and_condition import *
from .string_output import *
from .tag import *
from .template_object import *
from .undo_commands import *
from .dialogue_generic import *
from .dialogue_human_bot import *
from .dance import *
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains generic template objects associated with Dilogue.
"""
from generate_utils import *
from tree_components import *
from .template_object import *
class Human(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return None # "human:"
class HumanReplace(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._replace = True
if self.node._no_children:
self.node._no_children = False
def generate_description(self, arg_index=0, index=0, templ_index=0):
return None # "human:"
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/dialogue_generic.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects that generate only strings.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
################################
### GENERIC TEXT TEMPLATES ###
################################
"""The template objects under this section contribute only to the text /
description and do not alter the arguments of the parent node"""
class MadeOutOf(TemplateObject):
def generate_description(self, arg_index, index, templ_index=0):
if index == 0:
return "out of"
phrase = random.choice(["out of", "from", "using", "of", "with"])
return phrase
class OnGround(TemplateObject):
def generate_description(self, arg_index, index=0, templ_index=0):
return "on the ground"
class All(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["all", "all the"])
return phrase
class Every(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["every", "each"])
return phrase
class The(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "the"
class To(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "to"
class LocationWord(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
word = random.choice(["loc", "location", "loc:", "location:"])
return word
class Where(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "where"
class Is(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if index + 1 < len(template_names):
if template_names[index + 1] == "TagName":
return random.choice(["is", "looks like"])
elif template_names[index + 1] == "TagDesc":
return random.choice(["is", "looks"])
return "is"
class SurroundWith(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return random.choice(["with", "using"])
class With(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["with", "as"])
return command
class Blocks(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["blocks", "block"])
return phrase
class Squares(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["blocks", "squares", "block", "square", "tiles", "tile"])
return phrase
class Wide(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = "wide"
return phrase
class Long(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = "long"
return phrase
class High(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = "high"
return phrase
class Deep(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = "deep"
return phrase
class InARow(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["in a row", "next to each other"])
return phrase
class And(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = "and"
return phrase
class Under(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "under"
class Times(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "times"
class Everything(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "everything"
class DownTo(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "down to"
class Find(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["find me", "find"])
return phrase
class Up(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "up"
class ForMe(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["for me", ""])
return phrase
class OfDimensionsPhrase(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
all_names = get_template_names(self, templ_index)
phrases = ["of size", "of dimension", "of dimensions"]
if "RepeatCount" in all_names:
phrases.append("that are")
else:
phrases.append("that is")
return random.choice(phrases)
class Please(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["please", ""])
return phrase
class One(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
previous_template = get_template_names(self, templ_index - 1)
phrase_list = ["one"]
if any(x in ["RepeatCount", "RepeatAll"] for x in previous_template):
phrase_list = ["ones"]
phrase = random.choice(phrase_list)
return phrase
class Thing(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["thing", "structure"])
return phrase
class Using(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["using", "with"])
return phrase
class Dont(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "do n't"
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/string_output.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with the Location tree component.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
##########################
### LOCATION TEMPLATES ###
##########################
class MoveHere(TemplateObject):
"""This template object repesents the intent to move "here" and sets the location."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["location_type"] = SpeakerPos
def generate_description(self, arg_index=0, index=0, templ_index=0):
node_template = get_template_names(self, templ_index)
if node_template[-1] == "MoveHere":
phrase = random.choice(
[
"come back to me",
"move back to me",
"come to me",
"walk to me",
"come to where I am",
"move back to where I am",
"move to where I am",
"come back to where I am",
]
)
# For infinite loop
elif node_template[-1] == "ConditionTypeNever":
phrase = random.choice(
[
"follow me",
"keep following me",
"follow me around",
"keep walking with me",
"can you follow me",
"please follow me",
"can you please follow me",
]
)
return phrase
class MoveHereCoref(TemplateObject):
"""This template object repesents location to be where the speaker is looking."""
def add_generate_args(self, index=0, templ_index=0):
self._word = random.choice(
[
"come here",
"get over here",
"come back here",
"come back over here",
"get over here",
"move back here",
"walk back here",
]
)
self.node._location_args["location_type"] = None
self.node._location_args["coref_resolve"] = "yes" # self._word.split()[-1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._word
class Stand(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["relative_direction"] = True
self.node._location_args["relative_direction_value"] = "UP"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["stand on", "go on top of", "go stand on top of"])
template = get_template_names(self, templ_index)
if template[-1] not in ["BlockObjectThis", "BlockObjectThat", "ThereTemplateCoref"]:
phrase = " ".join([phrase, random.choice(["", "the"])]).strip()
return phrase
class Down(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["relative_direction"] = True
self.node._location_args["relative_direction_value"] = "DOWN"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["get down from", "come down from"])
template = get_template_names(self, templ_index)
if template[-1] not in ["BlockObjectThis", "BlockObjectThat", "ThereTemplateCoref"]:
phrase = " ".join([phrase, random.choice(["", "the"])]).strip()
return phrase
class LocationBlockObjectTemplate(TemplateObject):
"""This template object sets the location to be a reference to a blockobject"""
def add_generate_args(self, index=0, templ_index=0):
if (
type(self.node._location_args["location_type"]) is list
and self.node._location_args["location_type"][0] != BlockObject
):
self.node._location_args["location_type"].append(BlockObject)
else:
self.node._location_args["location_type"] = [BlockObject]
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
return description["block_object"]
class AroundString(TemplateObject):
"""This template object is used for the dance action and sets the direction
of dance: CLOCKWISE / ANTICLOCKWISE"""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["relative_direction"] = True
self.node._location_args["relative_direction_value"] = random.choice(
["CLOCKWISE", "ANTICLOCKWISE"]
)
def generate_description(self, arg_index=0, index=0, templ_index=0):
template = get_template_names(self, templ_index)
if "HumanReplace" in template:
return self.node._location_args["relative_direction_value"].lower()
phrase = random.choice(["around"])
return phrase
class Between(TemplateObject):
'''This template object represents relative direction "Between"'''
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["relative_direction"] = True
self.node._location_args["relative_direction_value"] = "BETWEEN"
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
return description["relative_direction"]
class RelativeDirectionTemplate(TemplateObject):
"""This template object repesents that the location is relative to something."""
def add_generate_args(self, index=0, templ_index=0):
template = get_template_names(self, templ_index)
self.node._location_args["relative_direction"] = True
if index + 1 < len(template):
self.node._location_args["additional_direction"] = []
if template[index + 1] == "LocationBlockObjectTemplate":
self.node._location_args["additional_direction"].extend(
["INSIDE", "OUTSIDE", "BETWEEN"]
)
if template[index + 1] in ["LocationBlockObjectTemplate", "LocationMobTemplate"]:
self.node._location_args["additional_direction"].append("NEAR")
if "BETWEEN" not in self.node._location_args["additional_direction"]:
self.node._location_args["additional_direction"].append("BETWEEN")
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
return description["relative_direction"]
class ClimbDirectionTemplate(TemplateObject):
"""This template object repesents that the location is on top of something."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["relative_direction"] = True
self.node._location_args["relative_direction_value"] = "UP"
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
return description["relative_direction"]
class CoordinatesTemplate(TemplateObject):
"""This template object repesents that the location is absolute coordinates."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["location_type"] = Coordinates
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
coordinates_list = " ".join((description["coordinates"].split())[2:])
return coordinates_list
class LocationMobTemplate(TemplateObject):
"""This template object repesents that location is a reference to a Mob."""
def add_generate_args(self, index=0, templ_index=0):
node_template = get_template_names(self, templ_index)
# handle "that pig"
if index >= 1 and node_template[index - 1] == "ThisTemplate":
if type(self.node._location_args["location_type"]) is list:
self.node._location_args["location_type"].append("SpeakerLookMob")
else:
self.node._location_args["location_type"] = ["SpeakerLookMob"]
else:
if type(self.node._location_args["location_type"]) is list and (
self.node._location_args["location_type"][0] != Mob
):
self.node._location_args["location_type"].append(Mob)
else:
self.node._location_args["location_type"] = [Mob]
def generate_description(self, arg_index=0, index=0, templ_index=0):
node_template = get_template_names(self, templ_index)
description = self.node.args[arg_index].generate_description()
mob_desc = description["mob"]
# drop "the" from "follow that the pig"
if ("mob_prefix" in mob_desc and index >= 1) and (
(node_template[index - 1] == "ThisTemplate") or ("BlockObjectThat" in node_template)
):
mob_desc = mob_desc.pop("mob_prefix")
return description["mob"]
class HereTemplate(TemplateObject):
"""This template object repesents location as where the speaker is."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["location_type"] = SpeakerPos
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["where I am", "where I am standing"])
return phrase
class HereTemplateCoref(TemplateObject):
"""This template object repesents location to be where the speaker is looking."""
def add_generate_args(self, index=0, templ_index=0):
self._word = random.choice(["here", "over here"])
self.node._location_args["location_type"] = None
self.node._location_args["coref_resolve"] = "yes" # self._word.split()[-1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._word
class ThereTemplate(TemplateObject):
"""This template object repesents location to be where the speaker is looking."""
def add_generate_args(self, index=0, templ_index=0):
self._word = random.choice(["where I am looking"])
self.node._location_args["location_type"] = SpeakerLook
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._word
class ThereTemplateCoref(TemplateObject):
"""This template object repesents location to be where the speaker is looking."""
def add_generate_args(self, index=0, templ_index=0):
self._word = random.choice(["there", "over there"])
self.node._location_args["location_type"] = None
self.node._location_args["coref_resolve"] = "yes" # self._word.split()[-1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._word
class YouTemplate(TemplateObject):
"""This template object repesents location to be where the agent is."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["location_type"] = AgentPos
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if "Dig" in template_names and "Under" in template_names:
return "you"
return random.choice(["where you are", "where you are standing"])
# NOTE: this is used for SpeakerLookMob type location, doesn't need coref resolution
class ThisTemplate(TemplateObject):
"""This template object repesents location to be where the agent is."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["location_type"] = SpeakerLook
def generate_description(self, arg_index=0, index=0, templ_index=0):
return random.choice(["this", "that"])
class StepsTemplate(TemplateObject):
"""This template object repesents that the location involves taking few "steps"."""
def add_generate_args(self, index=0, templ_index=0):
self.node._location_args["steps"] = True
template_name = get_template_names(self, templ_index)
if (index + 1 < len(template_name)) and (
template_name[index + 1] in ["ConditionCount", "NTimes"]
):
self.node._location_args["location_type"] = False
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
return description["steps"]
# The following templates generate only text in the context of
# Location templates.
class At(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
return "at"
class ALittle(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["a little", "a bit"])
return phrase
LOCATION_TEMPLATES = [
LocationBlockObjectTemplate,
RelativeDirectionTemplate,
CoordinatesTemplate,
LocationMobTemplate,
HereTemplate,
ThereTemplate,
ThereTemplateCoref,
YouTemplate,
ThisTemplate,
StepsTemplate,
At,
ALittle,
Between,
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/location.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with Dig action.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
#####################
### DIG TEMPLATES ###
#####################
dig_shapes = ["hole", "cave", "mine", "tunnel"]
"""This template object picks the shape of what will be dug"""
class DigSomeShape(TemplateObject):
def __init__(self, node, template_attr):
shape_type = DigShapeAny if pick_random(0.8) else DigShapeHole
self._child = shape_type(node=node, template_attr=template_attr)
def add_generate_args(self, index=0, templ_index=0):
self._child.add_generate_args(index=index, templ_index=templ_index)
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._child.generate_description(arg_index=arg_index, index=index)
"""This template object represents specific shapes. Meant to generate direct
commands like : make a hole , dig a mine"""
class DigShapeHole(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self._phrase = None
this_phrase = None
template_name = get_template_names(self, templ_index)
plural = False
phrase = random.choice(dig_shapes)
this_phrase = phrase
if "RepeatCount" in template_name:
phrase = make_plural(random.choice(dig_shapes))
this_phrase = phrase
plural = True
if not plural and (template_name[index - 1] not in ["DigDimensions", "DigAbstractSize"]):
this_phrase = phrase
phrase = random.choice([phrase, prepend_a_an(phrase)])
self.node.schematic["has_name"] = this_phrase
self._phrase = phrase
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._phrase
"""This template object covers a variety of dig shape types and is more general
than DigShapeHole. It can also lead to generations like: 'dig down until you hit bedrock'
"""
class DigShapeAny(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self._phrase = None
template_name = get_template_names(self, templ_index=0)
this_phrase = None
if "RepeatCount" in template_name:
phrase = make_plural(random.choice(dig_shapes))
this_phrase = phrase
elif "DownTo" in template_name:
if pick_random():
this_phrase = random.choice(dig_shapes + ["grass"])
phrase = this_phrase
else:
this_phrase = random.choice(dig_shapes)
phrase = "a " + this_phrase
elif template_name[index - 1] in ["DigDimensions", "DigAbstractSize"]:
phrase = random.choice(dig_shapes)
this_phrase = phrase
elif index + 1 < len(template_name) and template_name[index + 1] == "NumBlocks":
if pick_random():
this_phrase = random.choice(dig_shapes + ["under ground", "grass"])
phrase = this_phrase
else:
this_phrase = random.choice(dig_shapes)
phrase = "a " + this_phrase
else:
if pick_random():
this_phrase = random.choice(
dig_shapes
+ ["ground", "into ground", "under ground", "under grass", "grass", "down"]
)
phrase = this_phrase
else:
this_phrase = random.choice(dig_shapes)
phrase = "a " + this_phrase
self.node.schematic["has_name"] = this_phrase
self._phrase = phrase
def generate_description(self, arg_index=0, index=0, previous_text=None, templ_index=0):
return self._phrase
"""This template object assigns the dimensions: length, width and depth for
what needs to be dug."""
class DigDimensions(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node.schematic["has_length"] = random.choice(
self.template_attr.get("length", range(2, 15))
)
width_val = None
if pick_random():
width_val = random.choice(self.template_attr.get("width", range(15, 30)))
if width_val:
self.node.schematic["has_width"] = width_val
depth_val = None
if pick_random():
depth_val = random.choice(self.template_attr.get("width", range(30, 45)))
if depth_val:
self.node.schematic["has_depth"] = depth_val
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_name = get_template_names(self, templ_index)
sizes = [self.node.schematic["has_length"]]
if "has_width" in self.node.schematic:
sizes.append(self.node.schematic["has_width"])
if "has_depth" in self.node.schematic:
sizes.append(self.node.schematic["has_depth"])
out_size = random.choice([" x ".join(map(str, sizes)), " by ".join(map(str, sizes))])
if ("RepeatCount" in template_name) or ("OfDimensions" in template_name):
return out_size
return "a " + out_size
"""This template object assigns an abstract size for the shape that needs
to be dug."""
class DigAbstractSize(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self._size_description = random.choice(
ABSTRACT_SIZE + ["deep", "very deep", "really deep"]
)
self.node.schematic["has_size"] = self._size_description
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if "RepeatCount" in template_names:
return self._size_description
phrase = random.choice([self._size_description, prepend_a_an(self._size_description)])
return phrase
DIG_SHAPE_TEMPLATES = [DigSomeShape, DigShapeHole, DigShapeAny, DigDimensions, DigAbstractSize]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/dig.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated directly with Action names.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
class Dance(TemplateObject):
"""This template object repesents a single word 'Dance' command.
eg: dance / dance around"""
def add_generate_args(self, index=0, templ_index=0):
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template_len == 1:
self.node._no_children = True
single_commands = [
["dance", "dance"],
["dance", "do a dance"],
["dance", "show me a dance"],
]
all_names = get_template_names(self, templ_index)
template_len = len(all_names) - 1
if template_len == 2 and (all_names[-1] == "ConditionTypeNever"):
single_commands = [
["dancing", "keep dancing"],
["dance", "dance forever"],
["dance", "dance until I tell you to stop"],
]
command = random.choice(single_commands)
self.node.dance_type_name = command[0]
self.node._dance_text = command[1]
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = self.node._dance_text
prefix = random.choice(["", random.choice(["can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
class Move(TemplateObject):
"""This template object repesents the 'Move' command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["move", "go", "come", "walk"])
all_names = get_template_names(self, templ_index)
# If next argument is "Next", 'go next to X'
if all_names[1] == "Next" or ("Between" in all_names):
command = "go"
# for follow ups on a previous move command
if "HumanReplace" in all_names:
return None
# Infinite loop
if "ConditionTypeNever" in all_names and any(
x in ["LocationMobTemplate", "BlockObjectIt", "BlockObjectThat"] for x in all_names
):
command = random.choice(["follow", "catch", "keep following"])
elif "ClimbDirectionTemplate" in all_names:
command = random.choice(["climb"])
else:
# for away, use 'move'
description = self.node.args[0].generate_description()
if "relative_direction" in description:
if all_names[-1] != "ConditionTypeAdjacentBlockType":
if "away" in description["relative_direction"]:
command = "move"
else:
command = random.choice(["keep moving", "keep walking", "walk"])
elif "StepsTemplate" in all_names: # move X steps
command = random.choice(["move", "walk"])
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
class MoveSingle(TemplateObject):
"""This template object repesents a single word 'Move' command.
eg: move / move somewhere"""
def add_generate_args(self, index=0, templ_index=0):
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template[0] == "Human" and template_len == 1:
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
single_commands = ["move", "walk"]
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template[0] == "Human" and template_len == 1:
enhancements = ["anywhere", "somewhere", "around"]
new_commands = []
for comm in enhancements:
for command in single_commands:
new_commands.append(" ".join([command, comm]))
single_commands.extend(new_commands)
elif template_len == 2 and (template[-1] == "ConditionTypeNever"):
single_commands = ["keep walking", "keep moving"]
command = random.choice(single_commands)
prefix = random.choice(["", random.choice(["can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
### BUILD ###
class Build(TemplateObject):
"""This template object represents the 'Build' command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if "HumanReplace" in template_names:
return None
command_list = [
"build",
"make",
"construct",
"assemble",
"create",
"rebuild",
"install",
"place",
"put",
]
replace_flag = True if "HumanReplace" in template_names else False
if not replace_flag:
command_list.extend(["build me", "make me"])
command = random.choice(command_list)
if not replace_flag:
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please"])]
)
if command in ["build me", "make me"]:
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please"])]
)
new_command = (
random.choice([(" ".join([prefix, command])).strip(), "we need"])
if not replace_flag
else command
)
return new_command
class BuildSingle(TemplateObject):
"""This template object represents single word (no arguments) 'Build' command"""
def add_generate_args(self, index=0, templ_index=0):
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"build",
"make",
"construct",
"assemble",
"create",
"build something",
"build me something",
"make something",
"make something for me",
"make me something",
"construct something",
"assemble something",
"create something",
"build anything",
"build me anything",
"make anything",
"make me anything",
"construct anything",
"assemble anything",
"create anything",
"build something you know",
"build me something you know",
"make something you know",
"make me something you know",
"construct something you know",
"assemble something you know",
"create something you know",
"build anything you know",
"make anything you know",
"construct anything you know",
"assemble anything you know",
"create anything you know",
"build stuff",
"build me stuff",
"make stuff",
"create stuff",
"install something",
"install stuff",
"install something for me please",
]
)
prefix = random.choice(["", random.choice(["", "can you", "please", "can you please"])])
new_command = (" ".join([prefix, command])).strip()
return new_command
### DIG ###
class Dig(TemplateObject):
"""This template object repesents the Dig command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
template = self.node.template[templ_index]
template_names = get_template_names(self, templ_index)
command = random.choice(["dig", "mine", "clear"])
if (
"DigSomeShape" in template_names
and type(template[template_names.index("DigSomeShape")]._child).__name__
== "DigShapeHole"
):
command = random.choice(["make", "build"])
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "let 's", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
class DigSingle(TemplateObject):
"""This template object repesents single word Dig command with no arguments"""
def add_generate_args(self, index=0, templ_index=0):
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"dig",
"mine",
"dig something",
"mine something",
"dig anything",
"mine anything",
"dig stuff",
"make a hole",
]
)
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
### FREEBUILD ###
class Freebuild(TemplateObject):
"""This template object repesents a Freebuild command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"complete",
"can you please complete",
"please complete",
"can you complete",
"finish building",
]
)
return command
class FreebuildLocation(TemplateObject):
"""This template object repesents a Freebuild command with only Location"""
def add_generate_args(self, index=0, templ_index=0):
self.node._only_location = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"help me build something",
"help me make something",
"can you help me build something",
"can you help me make something",
"can you please help me build something",
"help me make something",
"help me make",
"help me build",
"build something with me",
"make something with me",
"let 's build something together",
"let 's build something",
]
)
return command
### DESTROY ###
class Destroy(TemplateObject):
"""This template object repesents the Destroy/ Destroy command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"destroy",
"destroy",
"remove",
"destruct",
"knock down",
"explode",
"blow up",
"tear down",
"dismantle",
"cut down",
"chop",
"clear",
"chop down",
]
)
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "let 's", "help me"])]
)
new_command = random.choice([(" ".join([prefix, command])).strip(), "i do n't want"])
return new_command
class DestroySingle(TemplateObject):
"""This template object repesents single word Destroy command with no arguments"""
def add_generate_args(self, index=0, templ_index=0):
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template_len == 1:
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
single_commands = ["destroy", "remove", "destruct", "knock down", "explode", "dismantle"]
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template_len == 1:
enhancements = ["something", "anything"]
new_commands = []
for comm in enhancements:
for command in single_commands:
new_commands.append(" ".join([command, comm]))
single_commands.extend(new_commands)
elif template_len == 2 and template[-1] == "RepeatAll":
single_commands.extend(["clear", "chop down"])
enhancements = [
"everything",
"everything around",
"everything until I ask you to stop",
"everything until I tell you to stop",
]
new_commands = []
for comm in enhancements:
for command in single_commands:
new_commands.append(" ".join([command, comm]))
new_commands.extend(["clear area", "clear the whole area"])
single_commands = new_commands
command = random.choice(single_commands)
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
### SPAWN ###
class Spawn(TemplateObject):
"""This template object repesents the Spawn command."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["spawn", "create", "produce", "generate"])
prefix_choice = ["can you", "please", "can you please", "help me"]
prefix = random.choice(["", random.choice(prefix_choice)])
command = (" ".join([prefix, phrase])).strip()
return command
### FILL ###
class Fill(TemplateObject):
"""This template object repesents the Fill command"""
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
phrases = ["fill", "cover"]
if "Up" not in template_names:
phrases.extend(["fill up", "cover up"])
phrase = random.choice(phrases)
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "help me"])]
)
command = (" ".join([prefix, phrase])).strip()
return command
### UNDO ###
class Undo(TemplateObject):
"""This template object repesents the Undo / revert action """
def add_generate_args(self, index=0, templ_index=0):
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template_len == 1:
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrases = ["undo", "revert"]
template = get_template_names(self, templ_index)
template_len = len(template) - 1
if template_len == 1:
phrases.extend(
["undo what you just did", "undo last action", "revert last action", "undo that"]
)
phrase = random.choice(phrases)
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "help me"])]
)
command = (" ".join([prefix, phrase])).strip()
return command
### STOP ###
class StopSingle(TemplateObject):
"""This template object repesents that the action that needs to be undone is
Build."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrases = [
"stop",
"hold on",
"wait",
"pause",
"stop doing that",
"stop doing what you are doing",
"stop what you are doing",
"do n't do that",
"stop task",
]
return random.choice(phrases)
class Stop(TemplateObject):
"""This template object repesents that the action that needs to be undone is
Build."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
return random.choice(["stop", "stay"])
### RESUME ###
class ResumeSingle(TemplateObject):
"""This template object repesents that the action that needs to be undone is
Build."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrases = [
"resume",
"continue",
"restart",
"start again",
"keep going on",
"keep going",
"keep doing that",
"keep doing what you were doing",
"continue doing that",
"continue doing what you were doing",
"continue what you were doing",
"go back to doing what you were doing",
"go back to what you were doing",
]
return random.choice(phrases)
class Resume(TemplateObject):
"""This template object repesents that the action that needs to be undone is
Build."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
return random.choice(["resume", "keep", "continue"])
### COPY ###
"""This template object represents the Copy action."""
class Copy(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
replace_flag = True if "HumanReplace" in template_names else False
if any(x in ["RepeatAll", "RepeatCount"] for x in template_names):
command = random.choice(
[
"make copies of",
"make me copies of",
"create copies of",
"copy",
"replicate",
"reproduce",
"emulate",
"make another of",
]
)
else:
template_names = get_template_names(self, templ_index)
command_list = ["copy", "replicate", "reproduce", "emulate"]
if not replace_flag:
command_list.extend(
[
"make a copy of",
"make me a copy of",
"create a copy of",
"make copy of",
"make another one of",
"build me another one of",
]
)
command = random.choice(command_list)
if not replace_flag:
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "help me"])]
)
new_command = (
random.choice([(" ".join([prefix, command])).strip()]) if not replace_flag else command
)
return new_command
class CopyMultiple(TemplateObject):
"""This template object represents the Copy action where mutiple copies need to be
made."""
def add_generate_args(self, index=0, templ_index=0):
num_copies = random.choice(self.template_attr.get("count", range(1, 101)))
self.num_copies = random.choice(
[str(num_copies), int_to_words(num_copies), "a few", "some"]
)
self.node._repeat_args["repeat_key"] = "FOR"
self.node._repeat_args["repeat_count"] = self.num_copies
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"make {} copies of",
"make me {} copies of",
"create {} copies of",
"make {} of",
"make me {} of",
"create {} of",
]
).format(self.num_copies)
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
"""This template object represents a single word Copy action with no arguments."""
class CopySingle(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._no_children = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(
[
"copy",
"make a copy",
"make me a copy",
"create a copy",
"copy something",
"make a copy of something",
"create a copy of something",
"copy anything",
"make a copy of anything",
"create a copy of anything",
]
)
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
### TAG ###
"""This template object represents the Tag action."""
class Tag(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["tag", "label", "name"])
prefix = random.choice(
["", random.choice(["", "can you", "please", "can you please", "let 's", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/action_names.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains common template objects used across different templates.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
#######################
## COMMON TEMPLATES ##
#######################
"""This template object represents the phrase: do X n times """
class NTimes(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
num_copies = random.choice(self.template_attr.get("count", range(1, 101)))
self.num_copies = random.choice([str(num_copies), int_to_words(num_copies)])
self.node._repeat_args["repeat_key"] = "FOR"
self.node._repeat_args["repeat_count"] = self.num_copies
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["{} times"]).format(self.num_copies)
return command
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/common.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with special shape commands
like : Wall, Stack, Place etc
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
##################################
## SPECIAL COMMANDS FOR SHAPES ###
##################################
class Wall(TemplateObject):
"""These template objects represent Schematics of type Shape that have an additional
'has_shape_' key in their dictionary.
This is mostly because the description of these doesn't occur in the
surface form to compute spans."""
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["schematic_type"] = RectangleShape
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["word"]
template_names = get_template_names(self, templ_index)
previous_template_name = template_names[index - 1]
# with a 0.5 probability, return with a/an
if previous_template_name == "Build":
if pick_random():
return prepend_a_an(word)
return word
class Stack(TemplateObject):
"""Rectanguloid with a height n"""
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["schematic_type"] = Shape
self.node._schematics_args["repeat_dir"] = "UP"
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["stack", "put up"])
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "let 's", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
class Place(TemplateObject):
"""Rectangualoid with a width n"""
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["schematic_type"] = Shape
self.node._schematics_args["repeat_dir"] = "RIGHT"
def generate_description(self, arg_index=0, index=0, templ_index=0):
command = random.choice(["place", "put"])
prefix = random.choice(
["", random.choice(["can you", "please", "can you please", "let 's", "help me"])]
)
new_command = (" ".join([prefix, command])).strip()
return new_command
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/special_shape_commands.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with Schematics.
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
###########################
### SCHEMATIC TEMPLATES ###
###########################
class UsingBlockType(TemplateObject):
"""This template ensures that the final generation has an attribute : block_type."""
def add_generate_args(self, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if any(x in ["BuildSingle", "Use"] for x in template_names):
self.node._schematics_args["only_block_type"] = True
if (
"Use" in template_names
and self.node._schematics_args["schematic_type"] is not None
):
self.node._schematics_args["only_block_type"] = False
self.node._schematics_args["block_type"] = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
block_type = description["block_type"]
template_name = get_template_names(self, templ_index)
previous_template_name = template_name[index - 1]
if previous_template_name == "Build":
return prepend_a_an(block_type)
return block_type
class AndBuild(TemplateObject):
"""This TemplateObject represents that there are two schematics that need to be built"""
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["multiple_schematics"] = True
class DescribingWord(TemplateObject):
"""This template object repesents the word / name of a schematic."""
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["word"]
template_names = get_template_names(self, templ_index)
previous_template_name = template_names[index - 1]
# with a 0.5 probability, return with a/an
if previous_template_name == "Build":
if pick_random():
return prepend_a_an(word)
return word
class NumBlocks(TemplateObject):
"""This template object represents a number of blocks and can be used to assign
height, width, depth etc."""
def add_generate_args(self, index=0, templ_index=0):
height = random.choice(self.template_attr.get("height", range(1, 12)))
self.num = int_to_words(height) if pick_random() else height
action_node = self.node
previous_template_name = type(action_node.template[templ_index][1]).__name__
if previous_template_name == "Dig":
dim_template = type(action_node.template[templ_index][index + 2]).__name__
if dim_template == "Wide":
action_node.schematic["has_width"] = self.num
elif dim_template == "Long":
action_node.schematic["has_length"] = self.num
elif dim_template == "Deep":
action_node.schematic["has_depth"] = self.num
elif previous_template_name == "Build":
dim_template = type(action_node.template[templ_index][index + 2]).__name__
node_attr = self.node._schematics_args["schematic_attributes"]
if dim_template == "High":
if node_attr:
node_attr["height"] = self.num
else:
self.node._schematics_args["schematic_attributes"] = {"height": self.num}
if dim_template == "Long":
if node_attr:
node_attr["length"] = self.num
else:
self.node._schematics_args["schematic_attributes"] = {"length": self.num}
def generate_description(self, arg_index=0, index=0, templ_index=0):
template_names = get_template_names(self, templ_index)
if template_names[index - 1] == "Build":
return "a " + str(self.num)
return str(self.num)
"""This template object represents an A by B dimension of a Schematic.
Eg: The 2 x 4 in "Build a 2 x 4 wall" """
class SchematicsDimensions(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["schematic_attributes"] = True
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
template_names = get_template_names(self, templ_index)
dimensions = None
multi_size_attr = None
# shape_attributes isn't supported for CategoryObject Schematics
# extract dimensions from the dict
if "shape_attributes" in description:
shape_attributes = description["shape_attributes"]
for attr in shape_attributes:
if "size" in attr:
size = attr.split("size")[1].strip() # extract '3 x 4' from 'of size 3 x 4'
if ("x" in size) or ("by" in size):
# if already formatted
multi_size_attr = attr
dimensions = size
else:
# else construct dimensions
sizes = size.split()
if len(sizes) > 1:
sizes = random.choice([" x ".join(sizes), " by ".join(sizes)])
multi_size_attr = attr
dimensions = sizes
if multi_size_attr:
shape_attributes.remove(multi_size_attr)
if dimensions and ("RepeatCount" not in template_names):
dimensions = "a " + dimensions # a 3 x 4 cube
return dimensions
return ""
"""This template object forces the Schematics to have explicit
attributes / dimensions"""
class WithAttributes(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["schematic_attributes"] = True
def generate_description(self, arg_index, index, templ_index=0):
description = self.node.args[arg_index].generate_description()
# shape_attributes isn't supported for CategoryObject Schematics
if "shape_attributes" in description:
shape_attributes = description["shape_attributes"]
return shape_attributes
return ""
"""This template object adds an abstract 'size' to Schematics"""
class SchematicSize(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["abstract_size"] = True
def generate_description(self, arg_index, index, templ_index=0):
description = self.node.args[arg_index].generate_description()
size = description["size"]
template = get_template_names(self, templ_index)
previous_template_name = template[index - 1]
# For Build: Build a huge archway / Build huge archway
if previous_template_name == "Build":
if pick_random():
return prepend_a_an(size)
return size
"""This template object adds an abstract 'color' to Schematics"""
class SchematicColour(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._schematics_args["colour"] = True
def generate_description(self, arg_index, index, templ_index=0):
description = self.node.args[arg_index].generate_description()
colour = description["colour"]
template = get_template_names(self, templ_index)
previous_template_name = template[index - 1]
# For Build: Build a red archway / Build red archway
if previous_template_name == "Build":
if pick_random():
return prepend_a_an(colour)
return colour
"""This template object represents one word shapes for Build commands.
'dome' -> Build dome"""
class BuildShape(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self._shape_type = random.choice(SCHEMATIC_TYPES)
self.node._schematics_args["schematic_type"] = self._shape_type
def generate_description(self, arg_index=0, index=0, templ_index=0):
description = self.node.args[arg_index].generate_description()
word = description["word"]
return word
class Use(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._no_children = False
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(["use", "make using", "build using", "do the construction using"])
return phrase
SCHEMATICS_TEMPLATES = [
UsingBlockType,
DescribingWord,
SchematicsDimensions,
WithAttributes,
NumBlocks,
SchematicSize,
SchematicColour,
BuildShape,
Use,
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/schematics.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with human-bot dialogues.
"""
from generate_utils import *
from tree_components import *
from .template_object import *
action_reference_object_map = {
"BUILD": "building",
"DESTROY": "destroying",
"SPAWN": "spawning",
"MOVE": "following",
"DIG": "digging",
"FILL": "filling",
}
class QueryBotCurrentAction(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._filters_args["temporal"] = "CURRENT"
self.node._filters_args["mem_type"] = "ACTION"
self.node.answer_type = "TAG"
self.node.tag_name = "action_name"
def generate_description(self, arg_index=0, index=0, templ_index=0):
question = random.choice(
[
"what are you doing",
"tell me what are you doing",
"what is your task",
"tell me your task",
"what are you up to",
]
)
return question
class QueryBot(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
curr_template = get_template_names(self, templ_index)
if "MoveTarget" in curr_template:
question = random.choice(["where are you", "tell me where you are"])
elif "See" in curr_template:
question = random.choice(
[
"what is",
"what are the labels associated with",
"what are the categories of",
"tell me the properties of",
]
)
elif "CurrentLocation" in curr_template:
question = random.choice(
[
"where are you",
"tell me where you are",
"i do n't see you",
"i ca n't find you",
"are you still around",
]
)
else:
question = random.choice(["what are you", "now what are you", "tell me what you are"])
return question
class CurrentLocation(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._filters_args["temporal"] = "CURRENT"
self.node._filters_args["mem_type"] = "AGENT"
self.node.answer_type = "TAG"
self.node.tag_name = "location"
class ActionReferenceObjectName(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._filters_args["temporal"] = "CURRENT"
self.node._filters_args["mem_type"] = "ACTION"
self.node._filters_args["action_type"] = random.choice(
list(action_reference_object_map.keys())
)
self.node.answer_type = "TAG"
self.node.tag_name = "action_reference_object_name"
def generate_description(self, arg_index=0, index=0, templ_index=0):
question = action_reference_object_map[self.node._filters_args["action_type"]]
return question
class MoveTarget(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._filters_args["temporal"] = "CURRENT"
self.node._filters_args["mem_type"] = "ACTION"
self.node.answer_type = "TAG"
self.node.tag_name = "move_target"
def generate_description(self, arg_index=0, index=0, templ_index=0):
question = random.choice(["heading", "off to", "going", "walking to", "heading over to"])
self.node._action_name = question
return question
class HumanReward(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._upsert_args["memory_type"] = "REWARD"
class PosReward(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._upsert_args["reward_value"] = "POSITIVE"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(
[
"good job",
"cool",
"that is really cool",
"that is awesome",
"awesome",
"that is amazing",
"that looks good",
"you did well",
"great",
"good",
"nice",
]
)
return phrase
class NegReward(TemplateObject):
def add_generate_args(self, index=0, templ_index=0):
self.node._upsert_args["reward_value"] = "NEGATIVE"
def generate_description(self, arg_index=0, index=0, templ_index=0):
phrase = random.choice(
[
"that is wrong",
"that was wrong",
"that was completely wrong",
"not that",
"that looks horrible",
"that is not what i asked",
"that is not what i told you to do",
"that is not what i asked for",
"not what i told you to do",
"you failed",
"failure",
"fail",
"not what i asked for",
]
)
return phrase
class BotThank(TemplateObject):
def generate_description(self, arg_index=0, index=0, templ_index=0):
reply = random.choice(["Thanks for letting me know."])
return reply
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/dialogue_human_bot.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file defines the TemplateObject class and other data structures used across
template objects.
"""
from generate_utils import *
from tree_components import *
SCHEMATIC_TYPES = [
RectanguloidShape,
HollowRectanguloidShape,
CubeShape,
HollowCubeShape,
SphereShape,
HollowSphereShape,
PyramidShape,
RectangleShape,
SquareShape,
TriangleShape,
CircleShape,
DiskShape,
EllipsoidShape,
DomeShape,
ArchShape,
TowerShape,
CategoryObject,
]
TAG_ADJECTIVES = [
"round",
"bright",
"crooked",
"steep",
"blurry",
"deep",
"flat",
"large",
"tall",
"broad",
"fuzzy",
"long",
"narrow",
"sleek",
"sharp",
"curved",
"wide",
"nice",
"pretty",
]
TAG_NAMES = (
[
"box",
"rectanguloid",
"cube",
"empty box",
"hollow box",
"hollow rectanguloid",
"cube",
"empty cube",
"hollow cube",
"ball",
"sphere",
"dome",
"empty sphere",
"empty ball",
"hollow ball",
"spherical shell",
"hollow sphere",
"pyramid",
"rectangle",
"square",
"triangle",
"circle",
"disk",
"ellipsoid",
"dome",
"arch",
"tower",
"wall",
]
+ MOBS
+ SUBCOMPONENT_LABELS
)
class TemplateObject:
def __init__(self, node, template_attr):
self.node = node
self.template_attr = template_attr
def generate_description(self, arg_index=0, index=0, templ_index=0):
return
def get_template_names(obj, templ_index=0):
return [type(temp_obj).__name__ for temp_obj in obj.node.template[templ_index]]
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/template_object.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file contains template objects associated with the Tag action
"""
import random
from generate_utils import *
from tree_components import *
from .template_object import *
#####################
### TAG TEMPLATES ###
#####################
tag_map = {"colour": COLOURS, "size": ABSTRACT_SIZE, "tag": TAG_ADJECTIVES}
class TagDesc(TemplateObject):
"""This template object has tags that can be used as adjectives.
eg : this red shape is bright.
"""
def add_generate_args(self, index=0, templ_index=0):
self.node._upsert_args["memory_type"] = "TRIPLE"
tag_name = random.choice(list(tag_map.keys()))
tag = random.choice(tag_map[tag_name])
# set the has_tag_name as the tag
self.node._upsert_args["has_" + tag_name] = tag
self._tag = tag
def generate_description(self, arg_index=0, index=0, templ_index=0):
return self._tag
class TagName(TemplateObject):
"""This template object repesents the name of a tag.
eg: spider or big spider"""
def add_generate_args(self, index=0, templ_index=0):
self.node._upsert_args["memory_type"] = "TRIPLE"
ALL_TAGS = ABSTRACT_SIZE + COLOURS + TAG_ADJECTIVES
names_desc = [" ".join([desc, name]) for name in TAG_NAMES for desc in ALL_TAGS]
names = random.choice([TAG_NAMES + names_desc])
self._tag = random.choice(names)
# add has_tag key
self.node._upsert_args["has_tag"] = self._tag
def generate_description(self, arg_index=0, index=0, templ_index=0):
return prepend_a_an(self._tag)
| craftassist-master | python/base_agent/ttad/generation_dialogues/template_objects/tag.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
Actions:
- GetMemory (filters, answer_type)
- PutMemory (filters, info_type)
Top-Level = {
"dialogue_type": {
`action_type`: {Action}
}
}
e.g. {
"get_memory" : {
"filters" : {
"type" : "action",
"temporal" : "current"
}
}
}
Action = {
{arg_type}: {arg_dict} # e.g. Move dict = {"Location": {Location}}
}
"""
from .action_node import *
from tree_components import *
class GetMemory(ActionNode):
"""The BotCurrentAction
__init__(): Pick a template from move_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("GetMemory", template, template_attr=template_attr)
self._is_dialogue = True
@classmethod
def generate(cls, template=None, template_attr={}):
get_mem_obj = GetMemory(template, template_attr)
template = get_mem_obj.template
get_mem_obj.ARG_TYPES = []
get_mem_obj._no_children = False # no ARG_TYPE if _no_children is True
get_mem_obj._block_obj_args = Arguments(
{
"block_object_type": Object,
"block_object_attributes": None,
"block_object_location": False,
"no_child": False,
"repeat_key": None,
"repeat_location": None,
"coref_type": None,
}
)
get_mem_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"repeat_key": None,
}
)
get_mem_obj._filters_args = Arguments(
{
"temporal": None,
"mem_type": None,
"action_type": None,
"block_object_attr": get_mem_obj._block_obj_args,
"location_attr": get_mem_obj._location_args,
}
)
get_mem_obj.answer_type = None
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
get_mem_obj.args = []
if get_mem_obj._no_children:
return get_mem_obj
if (
get_mem_obj._filters_args.values_updated
or get_mem_obj._block_obj_args.values_updated
or get_mem_obj._location_args.values_updated
):
if get_mem_obj._block_obj_args.values_updated:
get_mem_obj._filters_args["bo_updated"] = True
if get_mem_obj._location_args.values_updated:
get_mem_obj._filters_args["location_updated"] = True
get_mem_obj.ARG_TYPES.append(Filters)
get_mem_obj.args.append(Filters(**get_mem_obj._filters_args))
return get_mem_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
# get the text from template object
item = key.generate_description(arg_index=0, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class PutMemory(ActionNode):
"""The BotCurrentAction
__init__(): Pick a template from move_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("PutMemory", template, template_attr=template_attr)
self._is_dialogue = True
@classmethod
def generate(cls, template=None, template_attr={}):
put_mem_obj = PutMemory(template, template_attr)
template = put_mem_obj.template
put_mem_obj.ARG_TYPES = []
put_mem_obj._no_children = False # no ARG_TYPE if _no_children is True
put_mem_obj._arg_type = BlockObject
put_mem_obj._block_obj_args = Arguments(
{
"block_object_type": Object,
"block_object_attributes": None,
"block_object_location": False,
"no_child": False,
"repeat_key": None,
"repeat_location": None,
"coref_type": None,
}
)
put_mem_obj._mob_args = Arguments(
{"mob_location": None, "repeat_key": None, "repeat_location": None}
)
put_mem_obj._filters_args = Arguments(
{
"temporal": None,
"mem_type": None,
"action_type": None,
"block_object_attr": put_mem_obj._block_obj_args,
"mob_attr": put_mem_obj._mob_args,
}
)
put_mem_obj._upsert_args = Arguments(
{
"memory_type": None,
"reward_value": None,
"has_tag": None,
"has_size": None,
"has_colour": None,
}
)
put_mem_obj.info_type = None
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
put_mem_obj.args = []
if put_mem_obj._no_children:
return put_mem_obj
if put_mem_obj._arg_type == Mob:
put_mem_obj._filters_args["mob_updated"] = True
elif put_mem_obj._block_obj_args.values_updated:
put_mem_obj._filters_args["bo_updated"] = True
put_mem_obj.ARG_TYPES.append(Filters)
put_mem_obj.args.append(Filters(**put_mem_obj._filters_args))
if put_mem_obj._upsert_args.values_updated:
put_mem_obj.ARG_TYPES.append(Upsert)
put_mem_obj.args.append(Upsert(**put_mem_obj._upsert_args))
return put_mem_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
# get the text from template object
item = key.generate_description(arg_index=0, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_data/human_bot_dialogue.py |
# fmt: off
from .action_node import *
from .human_human_dialogue import *
from .human_bot_dialogue import *
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_data/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
Actions:
- Move (optional<Location>, optional<StopCondition>, optional<Repeat>)
- Build (optional<Schematic>, optional<Location>, optional<Repeat>)
- Destroy (optional<BlockObject>)
- Dig (optional<has_length>, optional<has_width>, optional<has_depth>,
optional<has_size>, optional<Location>, optional<StopCondition>,
optional<Repeat>)
- Copy (optional<BlockObject>, optional<Location>, optional<Repeat>)
- Undo (optional<target_action_type>)
- Fill (optional<Location>, optional<Repeat>)
- Spawn (Mob, optional<Repeat>)
- Freebuild (optional<BlockObject>, optional<Location>)
- Stop ()
- Resume ()
- Noop ()
Top-Level = {
"dialogue_type": {
"action_name" : {Action}
}
}
e.g. {
"human_give_command": {
"Move" : {"Location": {Location}}
}
}
Action = {
{arg_type}: {arg_dict} # e.g. Move dict = {"Location": {Location}}
}
"""
from collections import OrderedDict
from .action_node import *
from generate_utils import *
from template_objects import (
LOCATION_TEMPLATES,
CONDIITON_TEMPLATES,
REPEAT_KEY_TEMPLATES,
BLOCKOBJECT_TEMPLATES,
)
from tree_components import Location, Schematic, BlockObject, Object, Mob, StopCondition, Repeat
############
## ACTION ##
############
class Move(ActionNode):
"""The Move action is used to move/ walk to a certain location. The action
needs a Location to move to.
__init__(): Pick a template from move_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Move", template, template_attr=template_attr)
@classmethod
def generate(cls, template=None, template_attr={}):
move_obj = Move(template, template_attr)
template = move_obj.template
move_obj.ARG_TYPES = []
move_obj._no_children = False # no ARG_TYPE if _no_children is True
move_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"coref_resolve": None,
"relative_direction_value": None,
"bo_coref_resolve": None,
"template_attr": template_attr,
}
)
move_obj._condition_args = Arguments({"condition_type": None, "block_type": None})
# the number of repetitions for Action if any
move_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
move_obj.args = []
if move_obj._no_children:
return move_obj
move_obj.ARG_TYPES.append(Location)
move_obj.args.append(Location(**move_obj._location_args))
# StopCondition is optional, only add if the default arguments were changed.
if move_obj._condition_args.values_updated:
move_obj.ARG_TYPES.append(StopCondition)
move_obj.args.append(StopCondition(**move_obj._condition_args))
# Repeat is optional, only add if default values were updated
if move_obj._repeat_args.values_updated:
move_obj.ARG_TYPES.append(Repeat)
move_obj.args.append(Repeat(**move_obj._repeat_args))
return move_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
key_type = type(key)
arg_index = 0
# arg_index 1 for StopCondition
if (key_type in CONDIITON_TEMPLATES) and (len(self.args) > 1):
arg_index = 1
# get the text from template object
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Build(ActionNode):
"""The Build action is used to build something. The action needs a Schematic
and maybe a Location to build something.
__init__(): Pick a template from build_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Build", template, template_attr=template_attr)
@classmethod
def generate(cls, template=None, template_attr={}):
build_obj = Build(template, template_attr)
template = build_obj.template
build_obj.ARG_TYPES = []
build_obj._no_children = False # no ARG_TYPE if _no_children is True
build_obj._schematics_args = Arguments(
{
"only_block_type": False,
"block_type": False,
"schematic_attributes": False,
"schematic_type": None,
"abstract_size": None,
"colour": None,
"repeat_key": None,
"repeat_dir": None,
"template_attr": template_attr,
"multiple_schematics": False,
}
)
build_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"repeat_key": None,
"coref_resolve": None,
"template_attr": template_attr,
}
)
# the number of repetitions for Action if any
build_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
build_obj.args = []
if build_obj._schematics_args.values_updated or not build_obj._no_children:
build_obj.ARG_TYPES.append(Schematic)
build_obj.args.append(Schematic(**build_obj._schematics_args))
# Location is optional, only add if the default arguments were changed.
if build_obj._location_args.values_updated:
build_obj.ARG_TYPES.append(Location)
build_obj.args.append(Location(**build_obj._location_args))
# Repeat is optional, only add if default values were updated
if build_obj._repeat_args.values_updated:
build_obj.ARG_TYPES.append(Repeat)
build_obj.args.append(Repeat(**build_obj._repeat_args))
return build_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
item = None
key_type = type(key)
arg_index = 0
# arg_index 1 for Location
if ((key_type in LOCATION_TEMPLATES) or (key_type in BLOCKOBJECT_TEMPLATES)) and (
len(self.args) > 1
):
arg_index = 1
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
# shape_attributes can be a list
elif type(item) == list:
result.extend(item)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Copy(ActionNode):
"""The Copy action is used to make a copy of something. The action is just the
Build action with a BlockObject and maybe a Location to make the copy at.
__init__(): Pick a template from copy_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Copy", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
copy_obj = Copy(template, template_attr)
template = copy_obj.template
copy_obj.ARG_TYPES = []
copy_obj._no_children = False # no ARG_TYPE if _no_children is True
copy_obj._block_obj_args = Arguments(
{
"block_object_type": Object,
"block_object_attributes": None,
"block_object_location": False,
"no_child": False,
"repeat_key": None,
"repeat_location": None,
"coref_type": None,
"template_attr": template_attr,
}
)
copy_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"repeat_key": None,
"template_attr": template_attr,
}
)
# the number of repetitions for Action if any
copy_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
copy_obj.args = []
if copy_obj._no_children:
return copy_obj
if copy_obj._block_obj_args.values_updated:
copy_obj.ARG_TYPES.append(BlockObject)
copy_obj.args.append(BlockObject(**copy_obj._block_obj_args))
# Location is optional, only add if the default arguments were changed.
if copy_obj._location_args.values_updated:
copy_obj.ARG_TYPES.append(Location)
copy_obj.args.append(Location(**copy_obj._location_args))
# Repeat is optional, only add if default values were updated
if copy_obj._repeat_args.values_updated:
copy_obj.ARG_TYPES.append(Repeat)
copy_obj.args.append(Repeat(**copy_obj._repeat_args))
return copy_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
item = None
key_type = type(key)
arg_index = 0
# check template_objects.py for the list of template objects
if key_type in LOCATION_TEMPLATES:
if BlockObject in self.ARG_TYPES:
arg_index = 1
elif key_type in REPEAT_KEY_TEMPLATES:
if Repeat in self.ARG_TYPES:
if BlockObject in self.ARG_TYPES:
if Location in self.ARG_TYPES:
arg_index = 2
else:
arg_index = 1
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Dig(ActionNode):
"""The Dig action is used to dig something. The action needs a length, width
and depth and maybe a Location to dig something at.
__init__(): Pick a template from dig_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__(template_key="Dig", template=template, template_attr=template_attr)
def generate(template=None, template_attr={}):
dig_obj = Dig(template, template_attr)
template = dig_obj.template
dig_obj.ARG_TYPES = []
dig_obj._no_children = False # no ARG_TYPE if _no_children is True
dig_obj.schematic = {}
dig_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"repeat_key": None,
"coref_resolve": None,
"template_attr": template_attr,
}
)
dig_obj._condition_args = Arguments({"condition_type": None, "block_type": None})
# the number of repetitions for Action if any
dig_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
dig_obj.args = []
if dig_obj._no_children:
return dig_obj
# Location is optional, only add if the default arguments were changed.
if dig_obj._location_args.values_updated:
dig_obj.ARG_TYPES.append(Location)
dig_obj.args.append(Location(**dig_obj._location_args))
# StopCondition is optional, only add if the default arguments were changed.
if dig_obj._condition_args.values_updated:
dig_obj.ARG_TYPES.append(StopCondition)
dig_obj.args.append(StopCondition(**dig_obj._condition_args))
# Repeat is optional, only add if default values were updated
if dig_obj._repeat_args.values_updated:
dig_obj.ARG_TYPES.append(Repeat)
dig_obj.args.append(Repeat(**dig_obj._repeat_args))
return dig_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
item = None
key_type = type(key)
arg_index = 0
# arg_index 1 for StopCondition
if key_type in CONDIITON_TEMPLATES and Location in self.ARG_TYPES:
arg_index = 1
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Destroy(ActionNode):
"""The Destroy action is used to destroy something. The action needs a
BlockObject to destroy.
__init__(): Pick a template from destroy_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'block_object_type','block_object_attributes' etc. for BlockObject
_generate_description(): Generates the text description using the template objects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Destroy", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
destroy_obj = Destroy(template, template_attr)
template = destroy_obj.template
destroy_obj.ARG_TYPES = []
destroy_obj._no_children = False # no ARG_TYPE if _no_children is True
destroy_obj._block_obj_args = Arguments(
{
"block_object_type": Object,
"block_object_attributes": [],
"block_object_location": False,
"no_child": False,
"repeat_key": None,
"repeat_no_child": None,
"repeat_location": None,
"coref_type": None,
"template_attr": template_attr,
}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
destroy_obj.args = []
if destroy_obj._no_children:
return destroy_obj
if destroy_obj._block_obj_args.values_updated:
destroy_obj.ARG_TYPES.append(BlockObject)
destroy_obj.args.append(BlockObject(**destroy_obj._block_obj_args))
return destroy_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for key in templ:
key_type = type(key)
arg_index = 0
if key_type in CONDIITON_TEMPLATES and (len(self.args) > 1):
arg_index = 1
item = key.generate_description(arg_index=arg_index, templ_index=j)
if not item:
continue
# flatten if nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Undo(ActionNode):
"""Undo action is used to revert an action/ last action.
__init__(): Pick a template from undo_templates.py.
generate(): Instantiates the template_objects in the template.
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Undo", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
undo_obj = Undo(template, template_attr)
template = undo_obj.template
undo_obj.ARG_TYPES = []
undo_obj._no_children = False # no ARG_TYPE if _no_children is True
undo_obj.target_action_type = None # name of action to be undone
undo_obj.args = []
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
return undo_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
arg_index = 0
for i, key in enumerate(templ):
item = None
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Fill(ActionNode):
"""Fill action is used to fill up holes. This action may have
an optional location.
__init__(): Pick a template from fill_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of
'location_type','relative_direction' etc. for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Fill", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
fill_obj = Fill(template, template_attr)
template = fill_obj.template
fill_obj.ARG_TYPES = []
fill_obj._no_children = False # no ARG_TYPE if _no_children is True
fill_obj.has_block_type = None
fill_obj.reference_object = {}
fill_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"coref_resolve": None,
"template_attr": template_attr,
}
)
# the number of repetitions for Action if any
fill_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
fill_obj.args = []
if fill_obj._no_children:
return fill_obj
# Location is optional, only add if the default arguments were changed.
if fill_obj._location_args.values_updated:
fill_obj.ARG_TYPES.append(Location)
fill_obj.args.append(Location(**fill_obj._location_args))
# Repeat is optional, only add if default values were updated
if fill_obj._repeat_args.values_updated:
fill_obj.ARG_TYPES.append(Repeat)
fill_obj.args.append(Repeat(**fill_obj._repeat_args))
return fill_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
arg_index = 0
for i, key in enumerate(templ):
item = None
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Spawn(ActionNode):
"""The Spawn action spawns a mob in the environment. The class needs a Mob to spawn.
__init__(): Picks a template from templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of 'mob_location',
'repeat_location' etc for Mob
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Spawn", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
spawn_obj = Spawn(template, template_attr)
template = spawn_obj.template
spawn_obj.ARG_TYPES = [Mob]
spawn_obj._mob_args = Arguments(
{
"mob_location": None,
"repeat_key": None,
"repeat_location": None,
"template_attr": template_attr,
}
)
# the number of repetitions for Action if any
spawn_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
spawn_obj.args = [Mob(**spawn_obj._mob_args)]
# Repeat is optional, only add if default values were updated
if spawn_obj._repeat_args.values_updated:
spawn_obj.ARG_TYPES.append(Repeat)
spawn_obj.args.append(Repeat(**spawn_obj._repeat_args))
return spawn_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for key in templ:
# get the text form from template object.
item = key.generate_description(arg_index=0, templ_index=j)
if not item:
continue
# Flatten if nested dict.
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Freebuild(ActionNode):
"""The Freebuild action uses the model to finish a block object that is half finished.
The action takes a BlockObject.
__init__(): Picks a template from freebuild_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of 'block_object_type',
'block_object_attributes' etc for BlockObject
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Freebuild", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
freebuild_obj = Freebuild(template, template_attr)
template = freebuild_obj.template
freebuild_obj.ARG_TYPES = []
freebuild_obj._no_children = False
freebuild_obj._only_location = False # If the object only has location
freebuild_obj._block_obj_args = Arguments(
{
"block_object_type": Object,
"block_object_attributes": [],
"block_object_location": False,
"no_child": False,
"repeat_key": None,
"repeat_no_child": None,
"repeat_location": None,
"coref_type": None,
"template_attr": template_attr,
}
)
freebuild_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"coref_resolve": None,
"template_attr": template_attr,
}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
freebuild_obj.args = []
if not freebuild_obj._only_location:
freebuild_obj.ARG_TYPES.append(BlockObject)
freebuild_obj.args.append(BlockObject(**freebuild_obj._block_obj_args))
# Location is optional, only add if the default arguments were changed.
if freebuild_obj._location_args.values_updated:
freebuild_obj.ARG_TYPES.append(Location)
freebuild_obj.args.append(Location(**freebuild_obj._location_args))
return freebuild_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for key in templ:
arg_index = 0
item = key.generate_description(arg_index=arg_index, templ_index=j)
if not item:
continue
# flatten if nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Dance(ActionNode):
"""The Dance action represents dancing/ moving in a defined way.
The action takes an optional Location.
__init__(): Picks a template from dance_templates.py.
generate(): Instantiate the template_objects in the template that populate the
child arguments for classes in ARG_TYPES.
For example: the template objects populate values of 'location_type',
'relative_direction' etc for Location
_generate_description(): Generates the text description using the template ojects.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Dance", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
dance_obj = Dance(template, template_attr)
template = dance_obj.template
dance_obj.ARG_TYPES = []
dance_obj._no_children = False # no ARG_TYPE if _no_children is True
dance_obj._location_args = Arguments(
{
"location_type": "ANY",
"relative_direction": False,
"steps": None,
"coref_resolve": None,
"relative_direction_value": None,
"template_attr": template_attr,
}
)
dance_obj._condition_args = Arguments({"condition_type": None, "block_type": None})
# the number of repetitions for Action if any
dance_obj._repeat_args = Arguments(
{"repeat_key": None, "repeat_count": None, "repeat_dir": None}
)
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
# Append the ARG_TYPE object with arguments, to generate the action tree
dance_obj.args = []
if dance_obj._no_children:
return dance_obj
if dance_obj._location_args.values_updated:
dance_obj.ARG_TYPES.append(Location)
dance_obj.args.append(Location(**dance_obj._location_args))
# StopCondition is optional, only add if the default arguments were changed.
if dance_obj._condition_args.values_updated:
dance_obj.ARG_TYPES.append(StopCondition)
dance_obj.args.append(StopCondition(**dance_obj._condition_args))
# Repeat is optional, only add if default values were updated
if dance_obj._repeat_args.values_updated:
dance_obj.ARG_TYPES.append(Repeat)
dance_obj.args.append(Repeat(**dance_obj._repeat_args))
return dance_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):
key_type = type(key)
arg_index = 0
# arg_index 1 for StopCondition
if (key_type in CONDIITON_TEMPLATES) and (len(self.args) > 1):
arg_index = 1
# get the text from template object
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Stop(ActionNode):
"""Stop action takes no arguments, and only has a description.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Stop", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
stop_obj = Stop(template, template_attr)
template = stop_obj.template
stop_obj.ARG_TYPES = []
stop_obj._no_children = False # no ARG_TYPE if _no_children is True
stop_obj.target_action_type = None # name of action to be undone
stop_obj.args = []
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
return stop_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
arg_index = 0
for i, key in enumerate(templ):
item = None
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Resume(ActionNode):
"""Resume action takes no arguments and only has a description.
"""
def __init__(self, template=None, template_attr={}):
super().__init__("Resume", template, template_attr=template_attr)
def generate(template=None, template_attr={}):
resume_obj = Resume(template, template_attr)
template = resume_obj.template
resume_obj.ARG_TYPES = []
resume_obj._no_children = False # no ARG_TYPE if _no_children is True
resume_obj.target_action_type = None # name of action to be undone
resume_obj.args = []
# change default arguments for ARG_TYPE classes using the template_objects.
for j, templ in enumerate(template):
for i, t in enumerate(templ):
if type(t) != str:
if callable(getattr(t, "add_generate_args", None)):
t.add_generate_args(index=i, templ_index=j)
return resume_obj
def _generate_description(self):
"""get the text form from template object"""
generations = []
for j, templ in enumerate(self.template):
result = []
arg_index = 0
for i, key in enumerate(templ):
item = None
item = key.generate_description(arg_index=arg_index, index=i, templ_index=j)
if not item:
continue
# flatten nested dict
if type(item) in [OrderedDict, dict]:
val_list = list(values_of_nested_dict(item))
result.extend(val_list)
else:
result.append(item)
generations.append(" ".join(result))
return generations
class Noop(ActionNode):
"""Incoming messages which do not correspond to any action are mapped to Noop.
"""
CHATS = ["hello there", "how are you", "great"]
def __init__(self, template_attr={}):
super().__init__("Noop", template_attr=template_attr)
self._is_dialogue = True
def _generate_description(self):
self._word = random.choice(self.CHATS)
return [self._word] # ["human: " + self._word]
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_data/human_human_dialogue.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import random
from generate_utils import *
from templates.templates import get_template
class ActionNode:
"""This class is an Action Node that represents the "Action" in the action_tree.
A node can have a list of child nodes (ARG_TYPES) or a list of node types, it can be.
(CHOICES).
generate() : is responsible for initializing the ARG_TYPES and CHOICES.
generate_description() : Generates the natural language description.
to_dict() : Generates the action tree recursively using the children.
"""
ARG_TYPES = None # a list of child node types that need to be generated
CHOICES = None # a list of node types that can be substituted for this node
def __init__(self, template_key, template=None, template_attr={}):
self.args = None # populated by self.generate()
self.description = None # populated by self.generate_description()
if template_key != "Noop":
self.template = get_template(template_key, self, template, template_attr)
self._dialogue_type = "human_give_command"
self._replace = None
self._is_dialogue = False
self._d = {}
def generate_description(self):
if self.description is None:
self.description = self._generate_description()
return self.description
@classmethod
def generate(cls, action_type=None, template_attr={}):
if cls.ARG_TYPES:
x = cls(template_attr=template_attr)
x.args = []
for arg in cls.ARG_TYPES:
x.args.append(arg.generate())
return x
if cls.CHOICES:
c = random.choice(action_type) if type(action_type) is list else action_type
return c.generate(template_attr=template_attr)
return cls(template_attr=template_attr)
def __repr__(self):
if self.args:
return "<{} ({})>".format(type(self).__name__, ", ".join(map(str, self.args)))
else:
return "<{}>".format(type(self).__name__)
def to_dict(self):
"""Generates the action dictionary for the sentence"""
action_dict = {}
action_description_split = [x.split() for x in self.description]
if self.args:
# update the tree recursively.
for arg_type, arg in zip(self.ARG_TYPES, self.args):
# Update the action_description for children to compute spans later
arg._action_description = action_description_split
arg_name = arg_type.__name__
key = to_snake_case(arg_name) # key name in dictionary is snake case
# BlockObject and Mob are "reference_object" in the tree
if arg_name in ["BlockObject", "Mob"]:
key = "reference_object"
action_dict.update({key: arg.to_dict()})
def substitute_with_spans(action_description_split, d):
new_d = {}
for k, v in d.items():
if k.startswith("has"):
new_d[k] = find_span(action_description_split, v)
else:
new_d[k] = v
return new_d
# Prune out unnecessary keys from the tree
for attr, val in self.__dict__.items():
if (
not attr.startswith("_")
and val not in (None, "", {})
and attr not in ["args", "description", "template", "ARG_TYPES"]
):
action_dict[attr] = val
# for schematic key in Dig and reference_object in Fill
if attr in ["schematic", "reference_object"]:
updated_val = substitute_with_spans(action_description_split, val)
action_dict[attr] = updated_val
# Spans for keys : 'has_*' and repeat_count
if (attr.startswith("has_")) or (
attr in ["repeat_count", "dance_type_name", "target_action_type"]
):
span = find_span(action_description_split, val)
action_dict[attr] = span
if attr == "dance_type_name":
action_dict["dance_type"] = {attr: action_dict[attr]}
action_dict.pop(attr)
action_name = type(self).__name__
# For single word commands, add a blank block_object for Copy's tree
if (action_name == "Copy") and ("reference_object" not in action_dict):
action_dict["reference_object"] = {}
# Copy is represented as a 'Build' action in the tree
if action_name == "Copy":
action_name = "Build"
# Assign dialogue_type for classes that are dialogues
if self._is_dialogue:
self._dialogue_type = action_name
# Assign replace key
if self._replace:
action_dict["replace"] = True
self._d["dialogue_type"] = to_snake_case(self._dialogue_type, case="upper")
# put action as a key for all actions
if self._dialogue_type in ["human_give_command"]:
action_dict["action_type"] = to_snake_case(action_name, case="upper")
# move location inside reference_object for Fill action
if action_name == "Fill":
if "location" in action_dict:
if "reference_object" not in action_dict:
action_dict["reference_object"] = {}
action_dict["reference_object"]["location"] = action_dict["location"]
action_dict.pop("location")
# fix reference object at action level
if "reference_object" in action_dict:
new_dict = {}
val = action_dict["reference_object"]
if "repeat" in val:
new_dict["repeat"] = val["repeat"]
val.pop("repeat")
if "special_reference" in val:
new_dict["special_reference"] = val["special_reference"]
val.pop("special_reference")
new_dict["filters"] = val
action_dict["reference_object"] = new_dict
if "action_sequence" in self._d:
self._d["action_sequence"].append(action_dict)
else:
self._d["action_sequence"] = [action_dict]
else:
self._d.update(action_dict)
return self._d
| craftassist-master | python/base_agent/ttad/generation_dialogues/generate_data/action_node.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Undo templates are written for an action name and represents the intent
for the action: Undo. This action represents reverting something that has been
done before.
Examples:
[Human, Undo]
- undo last action
- undo what you just did
[Human, Undo, UndoActionBuild]
- undo what you just built
- undo the build action
'''
from template_objects import *
UNDO_TEMPLATES = [
[Human, Undo],
## Undo action name ##
[Human, Undo, ActionBuild],
[Human, Undo, ActionDestroy],
[Human, ActionTag],
[Human, Undo, ActionFill],
[Human, Undo, ActionDig]
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/undo_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Stop templates are written for an action name and represents the intent
for the action: Stop. This action represents stopping an action
Examples:
[Human, StopSingle]
- Stop
- pause
[Human, Stop, ActionBuild]
- Stop building
'''
from template_objects import *
STOP_TEMPLATES = [
[Human, StopSingle],
## Stop action name ##
[Human, Stop, ActionBuild],
[Human, Stop, ActionDestroy],
[Human, Stop, ActionTag],
[Human, Stop, ActionFill],
[Human, Stop, ActionDig],
[Human, Stop, ActionMove],
## Dont do action ##
[Human, Dont, ActionBuild],
[Human, Dont, ActionDestroy],
[Human, Dont, ActionTag],
[Human, Dont, ActionFill],
[Human, Dont, ActionDig],
[Human, Dont, ActionMove],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/stop_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Spawn templates are written for a MobName and represent the intent
for the action: Spawn.
Examples:
[Human, Spawn, MobName]
- spawn a pig.
- spawn sheep
[Human, Spawn, RepeatCount, MobName]
- Spawn five pigs
- Spawn a few sheep
etc
'''
from template_objects import *
SPAWN_TEMPLATES = [
## Spawn mob ##
[Human, Spawn, MobName],
## Spawn mob on the ground ##
[Human, Spawn, MobName, OnGround],
## Spawn n mobs ##
[Human, Spawn, RepeatCount, MobName],
## Spawn mob n times ##
[Human, Spawn, MobName, NTimes]
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/spawn_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Fill templates are written for a Location and represents the intent
for the action: Fill. This action intends to fill a hole or a negative shape
at a certain location.
Examples:
[Human, Fill, The, FillShape]
- fill the hole
- cover up the mine
[Human, Fill, The, FillShape, At, LocationWord, CoordinatesTemplate]
- fill up the hole at location: 2, 3, 4
- cover up the tunnel at: 2, 3, 4
'''
from template_objects import *
FILL_WITH_CORRECTION = [
## Single word command ##
[[Human, Fill],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill],
[HumanReplace, UseFill, FillBlockType]],
## Fill up the shape ##
[[Human, Fill, The, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape, Up],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, The, FillShape, Up],
[HumanReplace, UseFill, FillBlockType]],
## Fill shape X at location Y ##
[[Human, Fill, FillObjectThis, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape, ThereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape, HereTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape, HereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, The, FillShape, YouTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, FillObjectThis, RepeatCount, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatCount, FillShape, ThereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatCount, FillShape, HereTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatCount, FillShape, HereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatCount, FillShape, YouTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatAll, FillShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatAll, FillShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatAll, FillShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Fill, RepeatAll, FillShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
## Fill with X ##
[[Human, Fill, FillObjectThis, FillShape],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, The, FillShape, ThereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, The, FillShape, HereTemplate],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, The, FillShape, HereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, The, FillShape, YouTemplate],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, FillObjectThis, RepeatCount, FillShape],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatCount, FillShape, ThereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatCount, FillShape, HereTemplate],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatCount, FillShape, HereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatCount, FillShape, YouTemplate],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatAll, FillShape, ThereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatAll, FillShape, HereTemplate],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatAll, FillShape, HereTemplateCoref],
[HumanReplace, UseFill, FillBlockType]],
[[Human, Fill, RepeatAll, FillShape, YouTemplate],
[HumanReplace, UseFill, FillBlockType]],
## All rel_dir to BlockObject templates ##
## Single word command ##
[[Human, Fill],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat, Please]],
## Fill up the shape ##
[[Human, Fill, The, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, The, FillShape, Up],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
## Fill shape X at location Y ##
[[Human, Fill, FillObjectThis, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, The, FillShape, ThereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, The, FillShape, HereTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, The, FillShape, HereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, The, FillShape, YouTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, FillObjectThis, RepeatCount, FillShape],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatCount, FillShape, ThereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatCount, FillShape, HereTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatCount, FillShape, HereTemplateCoref],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatCount, FillShape, YouTemplate],
[HumanReplace, The, One, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatAll, FillShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatAll, FillShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatAll, FillShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat, Please]],
[[Human, Fill, RepeatAll, FillShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat, Please]],
]
FILL_TEMPLATES = [
## Single word command ##
[Human, Fill],
[Human, Fill, Using, FillBlockType],
## Fill up the shape ##
[Human, Fill, The, FillShape],
[Human, Fill, The, FillShape, Up],
[Human, Fill, The, FillShape, Using, FillBlockType],
[Human, Fill, The, FillShape, Up, Using, FillBlockType],
## Fill shape X at location Y ##
[Human, Fill, FillObjectThis, FillShape],
[Human, Fill, The, FillShape, At, LocationWord, CoordinatesTemplate],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, The, FillShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Fill, The, FillShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Fill, The, FillShape, ThereTemplate],
[Human, Fill, The, FillShape, ThereTemplateCoref],
[Human, Fill, The, FillShape, HereTemplate],
[Human, Fill, The, FillShape, HereTemplateCoref],
[Human, Fill, The, FillShape, YouTemplate],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, FillObjectThis, FillShape, Using, FillBlockType],
[Human, Fill, The, FillShape, At, LocationWord, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ThereTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ThereTemplateCoref, Using, FillBlockType],
[Human, Fill, The, FillShape, HereTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, HereTemplateCoref, Using, FillBlockType],
[Human, Fill, The, FillShape, YouTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
## Fill n holes ##
[Human, Fill, FillObjectThis, RepeatCount, FillShape],
[Human, Fill, RepeatCount, FillShape, At, LocationWord, CoordinatesTemplate],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, RepeatCount, FillShape, ThereTemplate],
[Human, Fill, RepeatCount, FillShape, ThereTemplateCoref],
[Human, Fill, RepeatCount, FillShape, HereTemplate],
[Human, Fill, RepeatCount, FillShape, HereTemplateCoref],
[Human, Fill, RepeatCount, FillShape, YouTemplate],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, FillObjectThis, RepeatCount, FillShape, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, At, LocationWord, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ThereTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ThereTemplateCoref, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, HereTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, HereTemplateCoref, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, YouTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
## Fill a hole near every location X ##
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation, Using, FillBlockType],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation, Using, FillBlockType],
## Fill a hole near n locations X ##
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation, Using, FillBlockType],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation, Using, FillBlockType],
## Fill all holes ##
[Human, Fill, RepeatAll, FillShape, At, LocationWord, CoordinatesTemplate],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, RepeatAll, FillShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Fill, RepeatAll, FillShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Fill, RepeatAll, FillShape, ThereTemplate],
[Human, Fill, RepeatAll, FillShape],
[Human, Fill, RepeatAll, FillShape, ThereTemplateCoref],
[Human, Fill, RepeatAll, FillShape, HereTemplate],
[Human, Fill, RepeatAll, FillShape, HereTemplateCoref],
[Human, Fill, RepeatAll, FillShape, YouTemplate],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Fill, RepeatAll, FillShape, At, LocationWord, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ThereTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ThereTemplateCoref, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, HereTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, HereTemplateCoref, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, YouTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, YouTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, Using, FillBlockType],
## Fill n holes near m locations X ##
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation, Using, FillBlockType],
## Fill all holes near n locations X ##
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation, Using, FillBlockType],
## Fill n holes near every location X ##
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation, Using, FillBlockType],
# ## All rel_dir to BlockObjectThat templates ##
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, The, FillShape, Between, BlockObjectThese],
[Human, Fill, The, FillShape, Between, BlockObjectThose],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
[Human, Fill, The, FillShape, Between, BlockObjectThese, Using, FillBlockType],
[Human, Fill, The, FillShape, Between, BlockObjectThose, Using, FillBlockType],
[Human, Fill, The, FillShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
[Human, Fill, The, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
## Fill n holes ##
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
[Human, Fill, RepeatCount, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
## Fill a hole near every location X ##
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation, Using, FillBlockType],
## Fill a hole near n locations X ##
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Fill, The, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation, Using, FillBlockType],
## Fill all holes ##
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, RepeatAll, FillShape, Between, BlockObjectThese],
[Human, Fill, RepeatAll, FillShape, Between, BlockObjectThose],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, Between, BlockObjectThese, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, Between, BlockObjectThose, Using, FillBlockType],
[Human, Fill, RepeatAll, FillShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, Using, FillBlockType],
## Fill n holes near m locations X ##
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation, Using, FillBlockType],
## Fill all holes near n locations X ##
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Fill, RepeatAll, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation, Using, FillBlockType],
## Fill n holes near every location X ##
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Fill, RepeatCount, FillShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation, Using, FillBlockType]
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/fill_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Resume templates are written for an action name and represents the intent
for the action: Resume. This action represents resuming a given or last action.
Examples:
[Human, ResumeSingle]
- resume
- start again
[Human, Resume, ActionBuild]
- resume building
- continue the build action
'''
from template_objects import *
RESUME_TEMPLATES = [
[Human, ResumeSingle],
## Resume action name ##
[Human, Resume, ActionBuild],
[Human, Resume, ActionDestroy],
[Human, Resume, ActionTag],
[Human, Resume, ActionFill],
[Human, Resume, ActionDig],
[Human, Resume, ActionMove],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/resume_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Destroy templates are written only for BlockObject and represent the intent
for the action: Destroy. This action destroys a physical block object.
Examples:
[Human, Destroy, The, Colour, AbstractDescription, BlockObjectLocation]
- destroy the red structure to the left of that grey shape.
- destroy the blue thing at location: 2 , 3, 4
- remove the blue shape there
[Human, Destroy, BlockObjectThat, Size, Colour, AbstractDescription]
- remove that huge red structure
- dig that tiny blue thing
'''
from template_objects import *
DESTROY_WITH_CORRECTION = [
## Destroy this / that X ##
[[Human, Destroy, BlockObjectThat],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectIt],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThat, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThat, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## Destroy the X ##
[[Human, Destroy, The, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, The, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## Destroy this / that colour X ##
[[Human, Destroy, BlockObjectThat, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, The, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThat, Colour, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, Colour, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, The, Colour, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
# ## Destroy this / that size X ##
[[Human, Destroy, BlockObjectThat, Size, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, Size, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, The, Size, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThat, Size, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, BlockObjectThis, Size, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Destroy, The, Size, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
]
DESTROY_TEMPLATES = [
## Single word destroy commands ##
[Human, DestroySingle],
## Destroy everything ##
[Human, DestroySingle, RepeatAll],
## Destroy what you built ##
# NOTE: this is only in destroy right now, but can be extended.
[Human, Destroy, BlockObjectCoref],
## Destroy this / that X ##
[Human, Destroy, BlockObjectThat],
[Human, Destroy, BlockObjectThis],
[Human, Destroy, BlockObjectIt],
[Human, Destroy, BlockObjectThat, AbstractDescription],
[Human, Destroy, BlockObjectThis, AbstractDescription],
[Human, Destroy, BlockObjectThat, ConcreteDescription],
[Human, Destroy, BlockObjectThis, ConcreteDescription],
## Destroy the X ##
[Human, Destroy, The, AbstractDescription],
[Human, Destroy, The, ConcreteDescription],
[Human, Destroy, AbstractDescription],
[Human, Destroy, ConcreteDescription],
## Destroy the X at location Y ##
[Human, Destroy, The, AbstractDescription, BlockObjectLocation],
[Human, Destroy, The, ConcreteDescription, BlockObjectLocation],
## Destroy this / that colour X ##
[Human, Destroy, BlockObjectThat, Colour, AbstractDescription],
[Human, Destroy, BlockObjectThis, Colour, AbstractDescription],
[Human, Destroy, The, Colour, AbstractDescription],
[Human, Destroy, BlockObjectThat, Colour, ConcreteDescription],
[Human, Destroy, BlockObjectThis, Colour, ConcreteDescription],
[Human, Destroy, The, Colour, ConcreteDescription],
## Destroy this / that colour X ##
[Human, Destroy, BlockObjectThat, Size, AbstractDescription],
[Human, Destroy, BlockObjectThis, Size, AbstractDescription],
[Human, Destroy, The, Size, AbstractDescription],
[Human, Destroy, BlockObjectThat, Size, ConcreteDescription],
[Human, Destroy, BlockObjectThis, Size, ConcreteDescription],
[Human, Destroy, The, Size, ConcreteDescription],
## Destroy the size X at location Y ##
[Human, Destroy, The, Size, AbstractDescription, BlockObjectLocation],
[Human, Destroy, The, Size, ConcreteDescription, BlockObjectLocation],
## Destroy the colour X at location Y ##
[Human, Destroy, The, Colour, AbstractDescription, BlockObjectLocation],
[Human, Destroy, The, Colour, ConcreteDescription, BlockObjectLocation],
## Destroy the size colour X ##
[Human, Destroy, BlockObjectThat, Size, Colour, AbstractDescription],
[Human, Destroy, BlockObjectThis, Size, Colour, AbstractDescription],
[Human, Destroy, The, Size, Colour, AbstractDescription],
[Human, Destroy, BlockObjectThat, Size, Colour, ConcreteDescription],
[Human, Destroy, BlockObjectThis, Size, Colour, ConcreteDescription],
[Human, Destroy, The, Size, Colour, ConcreteDescription],
## Destroy the size colour X at location Y ##
[Human, Destroy, The, Size, Colour, AbstractDescription, BlockObjectLocation],
[Human, Destroy, The, Size, Colour, ConcreteDescription, BlockObjectLocation],
## Destroy num X ##
[Human, Destroy, RepeatCount, AbstractDescription],
[Human, Destroy, RepeatCount, ConcreteDescription],
## Destroy num colour X ##
[Human, Destroy, RepeatCount, Colour, AbstractDescription],
[Human, Destroy, RepeatCount, Colour, ConcreteDescription],
## Destroy num size X ##
[Human, Destroy, RepeatCount, Size, AbstractDescription],
[Human, Destroy, RepeatCount, Size, ConcreteDescription],
## Destroy num size colour X ##
[Human, Destroy, RepeatCount, Size, Colour, AbstractDescription],
[Human, Destroy, RepeatCount, Size, Colour, ConcreteDescription],
## Destroy num size X at location Y ##
[Human, Destroy, RepeatCount, Size, AbstractDescription, BlockObjectLocation],
[Human, Destroy, RepeatCount, Size, ConcreteDescription, BlockObjectLocation],
## Destroy num colour X at location Y ##
[Human, Destroy, RepeatCount, Colour, AbstractDescription, BlockObjectLocation],
[Human, Destroy, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation],
## Destroy num size colour X at location Y ##
[Human, Destroy, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation],
[Human, Destroy, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation],
### Destroy X at locations Y ###
[Human, Destroy, The, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, The, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
### Destroy num X at locations Y ###
[Human, Destroy, RepeatCount, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation],
[Human, Destroy, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation],
### Destroy all X at location Y ###
[Human, Destroy, All, AbstractDescription, RepeatAll],
[Human, Destroy, Every, AbstractDescription, RepeatAll],
[Human, Destroy, All, ConcreteDescription, RepeatAll],
[Human, Destroy, Every, ConcreteDescription, RepeatAll],
[Human, Destroy, All, Colour, ConcreteDescription, RepeatAll],
[Human, Destroy, Every, Colour, ConcreteDescription, RepeatAll],
[Human, Destroy, All, Colour, AbstractDescription, RepeatAll],
[Human, Destroy, Every, Colour, AbstractDescription, RepeatAll],
[Human, Destroy, All, Size, AbstractDescription, RepeatAll],
[Human, Destroy, Every, Size, AbstractDescription, RepeatAll],
[Human, Destroy, All, Size, ConcreteDescription, RepeatAll],
[Human, Destroy, Every, Size, ConcreteDescription, RepeatAll],
[Human, Destroy, All, Size, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, All, Size, ConcreteDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Size, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, All, Colour, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, AbstractDescription, RepeatAll],
[Human, Destroy, Every, Size, Colour, AbstractDescription, RepeatAll],
[Human, Destroy, All, Size, Colour, ConcreteDescription, RepeatAll],
[Human, Destroy, Every, Size, Colour, ConcreteDescription, RepeatAll],
[Human, Destroy, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll],
## Destroy X at every location Y ##
[Human, Destroy, The, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, The, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
### Destroy all X at every location Y ###
[Human, Destroy, All, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll],
### Destroy all X at locations Ys ###
[Human, Destroy, All, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
[Human, Destroy, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll],
### Destroy n X at every location Y ###
[Human, Destroy, RepeatCount, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation],
[Human, Destroy, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/destroy_templates.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file picks a template for a given action, at random.
The templates use template_objects as their children to help construct a sentence
and the dictionary.
TemplateObject is defined in template_objects.py
Each template captures how to phrase the intent. The intent is defined by the action
type.
"""
import copy
import random
from template_objects import *
from build_templates import *
from move_templates import *
from dig_templates import *
from destroy_templates import *
from copy_templates import *
from undo_templates import *
from fill_templates import *
from spawn_templates import *
from freebuild_templates import *
from dance_templates import *
from get_memory_templates import *
from put_memory_templates import *
from stop_templates import *
from resume_templates import *
template_map = {
"Move": [MOVE_TEMPLATES, MOVE_WITH_CORRECTION],
"Build": [BUILD_TEMPLATES, BUILD_WITH_CORRECTION, BUILD_INBUILT_COMPOSITE],
"Destroy": [DESTROY_TEMPLATES, DESTROY_WITH_CORRECTION],
"Dig": [DIG_TEMPLATES, DIG_WITH_CORRECTION],
"Copy": [COPY_TEMPLATES, COPY_WITH_CORRECTION],
"Undo": [UNDO_TEMPLATES],
"Fill": [FILL_TEMPLATES, FILL_WITH_CORRECTION],
"Spawn": [SPAWN_TEMPLATES],
"Freebuild": [FREEBUILD_TEMPLATES, FREEBUILD_WITH_CORRECTION],
"Dance": [DANCE_TEMPLATES, DANCE_WITH_CORRECTION],
"GetMemory": [GET_MEMORY_TEMPLATES, ANSWER_WITH_CORRECTION],
"PutMemory": [PUT_MEMORY_TEMPLATES, TAG_WITH_CORRECTION],
"Stop": [STOP_TEMPLATES],
"Resume": [RESUME_TEMPLATES],
}
def get_template(template_key, node, template=None, template_attr={}):
"""Pick a random template, given the action."""
template_name = template_map[template_key] # this will be a list right now
if template_attr.get("dialogue_len", 0) == 1:
template_name = template_name[0]
elif template_attr.get("no_inbuilt_composites", False) == True and len(template_name) == 3:
templates = []
template_name = template_name[:2]
for template_type in template_name:
templates += template_type
template_name = templates
else:
templates = []
for template_type in template_name:
templates += template_type
template_name = templates
if template is None:
template = random.choice(template_name)
template = copy.deepcopy(template)
if not any(isinstance(i, list) for i in template):
template = [template]
for i, t in enumerate(template):
for j, templ in enumerate(t):
if type(templ) != str:
template[i][j] = templ(node=node, template_attr=template_attr)
return template
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
"""
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Build templates are written for Schematics and may have a Location,
and represent the intent for the action: Build.
This action builds a known Schematic (a shape or CategoryObject).
Examples:
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate]
- out of acacia build a cube at location 3, 2, 1
- out of acacia wood construct a cube of size 5 at location 5 6 7
- make a cube of size 10 at location ( 1 , 2, 3 )
[Human, Near, LocationMobTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType]
- near the spider build a dome of radius 4 using gravel.
- near the spider make a dome.
- near the spider assemble a dome using gravel.
"""
from template_objects import *
BUILD_INBUILT_COMPOSITE = [
[Human, Build, DescribingWord, AndBuild],
]
BUILD_WITH_CORRECTION = [
## Single word Build command ##
[[Human, BuildSingle],
[HumanReplace, Use, UsingBlockType]],
## Build at location X ##
[[Human, BuildSingle, At, LocationWord, CoordinatesTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, RelativeDirectionTemplate, CoordinatesTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, ThereTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, ThereTemplateCoref],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, HereTemplate],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, HereTemplateCoref],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, YouTemplate],
[HumanReplace, Use, UsingBlockType]],
## Build using block type X at location Y ##
[[Human, BuildSingle, MadeOutOf, UsingBlockType],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplateCoref],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, YouTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
## Build at every location Y ##
[[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[HumanReplace, Use, UsingBlockType]],
## Build at n locations Y ##
[[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[HumanReplace, Use, UsingBlockType]],
[[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[HumanReplace, Use, UsingBlockType]],
## Stack N blocks at location Y ##
[[Human, Stack, RepeatCount, DescribingWord],
[HumanReplace, Use, UsingBlockType]],
[[Human, Stack, RepeatCount, DescribingWord],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Place, RepeatCount, DescribingWord, InARow],
[HumanReplace, Use, UsingBlockType]],
[[Human, Place, RepeatCount, DescribingWord, InARow],
[HumanReplace, Build, RelativeDirectionTemplate, LocationMobTemplate]],
## templates for rel_dir of BlockObjectThat ##
[[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat],
[HumanReplace, Use, UsingBlockType]],
## Build using block type X at location Y ##
[[Human, BuildSingle, MadeOutOf, UsingBlockType],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplateCoref],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, BuildSingle, MadeOutOf, UsingBlockType, YouTemplate],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
## Build at every location Y ##
[[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[HumanReplace, Use, UsingBlockType]],
## Build at n locations Y ##
[[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[HumanReplace, Use, UsingBlockType]],
## Stack N blocks at location Y ##
[[Human, Stack, RepeatCount, DescribingWord],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Place, RepeatCount, DescribingWord, InARow],
[HumanReplace, Build, RelativeDirectionTemplate, BlockObjectThat]],
]
BUILD_TEMPLATES = [
## Single word Build command ##
[Human, BuildSingle],
## Build at location X ##
[Human, BuildSingle, At, LocationWord, CoordinatesTemplate],
[Human, BuildSingle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, BuildSingle, ThereTemplate],
[Human, BuildSingle, ThereTemplateCoref],
[Human, BuildSingle, HereTemplateCoref],
[Human, BuildSingle, HereTemplate],
[Human, BuildSingle, YouTemplate],
## Build using block type X at location Y ##
[Human, BuildSingle, MadeOutOf, UsingBlockType],
[Human, BuildSingle, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, BuildSingle, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplate],
[Human, BuildSingle, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, BuildSingle, MadeOutOf, UsingBlockType, YouTemplate],
## Build at every location Y ##
[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build at n locations Y ##
[Human, BuildSingle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, BuildSingle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
## Single word shape name for Build ##
[Human, BuildShape],
## Surround X with Y ##
[Human, Surround, LocationBlockObjectTemplate, SurroundWith, DescribingWord],
[Human, Surround, LocationMobTemplate, SurroundWith, DescribingWord],
[Human, Surround, BlockObjectThat, SurroundWith, DescribingWord],
## Stack N blocks at location Y ##
[Human, Stack, RepeatCount, DescribingWord],
[Human, Stack, RepeatCount, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Stack, RepeatCount, DescribingWord, ThereTemplate],
[Human, Stack, RepeatCount, DescribingWord, ThereTemplateCoref],
[Human, Stack, RepeatCount, DescribingWord, HereTemplateCoref],
[Human, Stack, RepeatCount, DescribingWord, HereTemplate],
[Human, Stack, RepeatCount, DescribingWord, YouTemplate],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Stack N blocks at every location Y ##
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Stack N blocks at M locations Y ##
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
## Place N blocks in a row at location Y ##
[Human, Place, RepeatCount, DescribingWord, InARow],
[Human, Place, RepeatCount, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, ThereTemplate],
[Human, Place, RepeatCount, DescribingWord, ThereTemplateCoref],
[Human, Place, RepeatCount, DescribingWord, HereTemplateCoref],
[Human, Place, RepeatCount, DescribingWord, HereTemplate],
[Human, Place, RepeatCount, DescribingWord, YouTemplate],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Place N blocks at every location Y ##
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Place N blocks in a row at location Y ##
[Human, Place, RepeatCount, DescribingWord, InARow, At, LocationWord, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, At, LocationWord, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ThereTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ThereTemplateCoref],
[Human, Place, RepeatCount, DescribingWord, InARow, HereTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, HereTemplateCoref],
[Human, Place, RepeatCount, DescribingWord, InARow, YouTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Place N blocks in a row at every location Y ##
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X out of Y with size ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
## Build N X out of Y with size ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
## Build n by m X with other size attributes like thickness etc ##
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
## Build wall X blocks long and Y blocks high ##
[Human, Build, Wall, NumBlocks, Squares, Long, And, NumBlocks, Squares, High],
[Human, Build, Wall, NumBlocks, Squares, High, And, NumBlocks, Squares, Long],
[Human, Build, Wall, NumBlocks, Squares, Long, NumBlocks, Squares, High],
[Human, Build, Wall, NumBlocks, Squares, High, NumBlocks, Squares, Long],
## Build N walls X blocks long and Y blocks high ##
[Human, Build, RepeatCount, Wall, NumBlocks, Squares, Long, And, NumBlocks, Squares, High],
[Human, Build, RepeatCount, Wall, NumBlocks, Squares, High, And, NumBlocks, Squares, Long],
[Human, Build, RepeatCount, Wall, NumBlocks, Squares, Long, NumBlocks, Squares, High],
[Human, Build, RepeatCount, Wall, NumBlocks, Squares, High, NumBlocks, Squares, Long],
## Build X blocks long and Y blocks high wall ##
[Human, Build, NumBlocks, Squares, Long, And, NumBlocks, Squares, High, Wall],
[Human, Build, NumBlocks, Squares, High, And, NumBlocks, Squares, Long, Wall],
[Human, Build, NumBlocks, Squares, Long, NumBlocks, Squares, High, Wall],
[Human, Build, NumBlocks, Squares, High, NumBlocks, Squares, Long, Wall],
## Build n by m X using block type Y with size attributes ##
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
## Build N n by m Xs using block type Y with size attributes ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
## Build X of size Y using block type Z ##
[Human, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## Build n by m of size Y using block type Z ##
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## out of X build Y ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord],
[Human, MadeOutOf, UsingBlockType, Build, SchematicSize, DescribingWord],
## Build X out of block type Y ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType],
## Build n Xs with size Y out of block type Z ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## Out of X build n Ys ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicSize, DescribingWord],
## Build N Xs out of Y ##
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType],
## Build X with size Y ##
[Human, Build, DescribingWord, WithAttributes],
[Human, Build, SchematicColour, DescribingWord, WithAttributes],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Build, SchematicsDimensions, SchematicColour, DescribingWord, WithAttributes],
## Build X n times ###
[Human, Build, DescribingWord, NTimes],
[Human, Build, SchematicSize, DescribingWord, NTimes],
[Human, Build, SchematicColour, DescribingWord, NTimes],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, NTimes],
# Build size colour X ##
[Human, Build, DescribingWord],
[Human, Build, SchematicSize, DescribingWord],
[Human, Build, SchematicColour, DescribingWord],
[Human, Build, SchematicSize, SchematicColour, DescribingWord],
## Build a block type X Y ##
[Human, Build, UsingBlockType, DescribingWord],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord],
## Build N X of size Y ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Build, RepeatCount, SchematicsDimensions, SchematicColour, DescribingWord, WithAttributes],
## Build N X ##
[Human, Build, RepeatCount, DescribingWord],
[Human, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
## Build N block type X Y ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
## Out of X build Y with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of X build Y with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Out of C build a by b X with size Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of C build a by b X with size Y at every location Z ##
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Out of X build N Ys with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of X build N Ys with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Out of X build N a by b Ys with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of X build N a by b Ys with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Out of X build Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicSize, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
## Build X of size Y at location Z ##
[Human, Build, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicColour, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, SchematicColour, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
## Build X at location Y ##
[Human, Build, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicColour, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
## Out of X build N Ys at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicSize, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of X build Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ThereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ThereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, HereTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, HereTemplateCoref],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Out of X build Y at every location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build N Ys with size X at location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, SchematicColour, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
## Build N Y with size X at every location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X with size Y at every location Z ##
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X with size Y at location Z ##
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, DescribingWord, ThereTemplate],
[Human, Build, SchematicSize, DescribingWord, ThereTemplate],
[Human, Build, SchematicColour, DescribingWord, ThereTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ThereTemplate],
[Human, Build, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, DescribingWord, ThereTemplateCoref],
[Human, Build, SchematicSize, DescribingWord, ThereTemplateCoref],
[Human, Build, SchematicColour, DescribingWord, ThereTemplateCoref],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ThereTemplateCoref],
[Human, Build, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, DescribingWord, HereTemplate],
[Human, Build, SchematicSize, DescribingWord, HereTemplate],
[Human, Build, SchematicColour, DescribingWord, HereTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, HereTemplate],
[Human, Build, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, DescribingWord, HereTemplateCoref],
[Human, Build, SchematicSize, DescribingWord, HereTemplateCoref],
[Human, Build, SchematicColour, DescribingWord, HereTemplateCoref],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, HereTemplateCoref],
[Human, Build, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, DescribingWord, YouTemplate],
[Human, Build, SchematicSize, DescribingWord, YouTemplate],
[Human, Build, SchematicColour, DescribingWord, YouTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, YouTemplate],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Build N X with size Y at location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
## Build N X with size Y at every location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## At location Y build X using block type A with size Z ##
[Human, At, LocationWord, CoordinatesTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, At, LocationWord, CoordinatesTemplate, Build, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicSize, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicColour, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
## At location X build Y Z with size A ##
[Human, At, LocationWord, CoordinatesTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, UsingBlockType, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
## At location Y build N Xs using block type A with size Z ##
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
## At every location Y build N Xs out of Z with size A ##
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
## At location X build Y out of Z with size A ##
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
## At location X build N Ys out of Z with size A ##
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
## At every location X build N Ys out of Z with size A ##
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
## At every location X build Y out of Z with size A ##
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
## Build X out of Y with size Z at location A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplateCoref],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplateCoref],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, HereTemplateCoref],
## Build n Xs out of Y with size Z at location A ##
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## Build n Xs out of Y with size Z at every location A ##
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X out of Y with size Z at every location A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X out Y with size Z at location A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, YouTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, YouTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## build X Y with size Z at location A ##
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, UsingBlockType, DescribingWord, ThereTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ThereTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, UsingBlockType, DescribingWord, ThereTemplateCoref],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ThereTemplateCoref],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, UsingBlockType, DescribingWord, HereTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, HereTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, UsingBlockType, DescribingWord, HereTemplateCoref],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, HereTemplateCoref],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, UsingBlockType, DescribingWord, YouTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, YouTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## At location A build N X Y with size Z ##
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
## At every location X build X Y with size Z ##
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
## At every location X build n X Ys with size Z ##
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
## Build N X Y with size Z at location A ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
## Build X Y with size Z at every location A ##
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
## Build N X Y with size Z at location A ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ThereTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ThereTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ThereTemplateCoref],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ThereTemplateCoref],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, HereTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, HereTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, HereTemplateCoref],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, HereTemplateCoref],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, YouTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, YouTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## Build N X Y with size Z at every location A ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## At location X Build X with size Y out of Z ##
[Human, At, LocationWord, CoordinatesTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, At, LocationWord, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## At location X Build n Xs with size Y out of Z ##
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, At, LocationWord, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, CoordinatesTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## At every location X build n Xs with size Y out of Z ##
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
## Build X with size Y out of Z at location A ##
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## Build n Xs with size Y out of Z at location A ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, At, LocationWord, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ThereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, HereTemplateCoref],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
## Build n Xs with size Y out of Z at every location A ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Build X with size Y out of Z at every location A ##
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
## Place N blocks at n locations X ##
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
## Out of X build Y with size Z at M locations A (same templates as above with N locations) ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, SchematicColour, DescribingWord, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicSize, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicSize, UsingBlockType, DescribingWord, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, RelativeDirectionTemplate, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
# Build N X Around Y ##
[Human, Build, RepeatCount, DescribingWord, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, Around, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Around, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, Around, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, Around, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Around, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, Around, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, BlockObjectThat],
## Build Xs around Y ##
[Human, Build, RepeatAll, DescribingWord, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatAll, DescribingWord, MadeOutOf, UsingBlockType, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, LocationBlockObjectTemplate],
[Human, Build, RepeatAll, DescribingWord, Around, LocationMobTemplate],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, Around, LocationMobTemplate],
[Human, Build, RepeatAll, DescribingWord, MadeOutOf, UsingBlockType, Around, LocationMobTemplate],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, LocationMobTemplate],
[Human, Build, RepeatAll, DescribingWord, Around, BlockObjectThat],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, Around, BlockObjectThat],
[Human, Build, RepeatAll, DescribingWord, MadeOutOf, UsingBlockType, Around, BlockObjectThat],
[Human, Build, RepeatAll, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Around, BlockObjectThat],
## Templates for rel_dir of BlockObjectThat ##
[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat],
[Human, BuildSingle, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
# Build at n locations Y ##
[Human, BuildSingle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Stack N blocks at every location Y ##
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Stack N blocks at M locations Y ##
[Human, Stack, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Stack, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Place N blocks in a row at location Y ##
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Place N blocks at every location Y ##
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Place N blocks in a row at location Y ##
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, BlockObjectThat],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Place N blocks in a row at every location Y ##
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of X build Y with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Out of X build Y with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of C build a by b X with size Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Out of C build a by b X with size Y at every location Z ##
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of X build N Ys with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Out of X build N Ys with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of X build N a by b Ys with size Z at location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Out of X build N a by b Ys with size Z at every location A ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of X build Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
## Build X of size Y at location Z ##
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
## Build X at location Y ##
[Human, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
## Out of X build N Ys at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Out of X build Y at location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Out of X build Y at every location Z ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
## Build N Y with size X at every location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X with size Y at every location Z ##
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X with size Y at location Z ##
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Build N X with size Y at location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Build N X with size Y at every location Z ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## At location Y build X using block type A with size Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, UsingBlockType, DescribingWord],
## At location Y build N Xs using block type A with size Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
## At every location Y build N Xs out of Z with size A ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicColour, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, SchematicColour, DescribingWord, RepeatAllLocation],
## At location X build N Ys out of Z with size A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Build n Xs out of Y with size Z at every location A ##
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X out of Y with size Z at every location A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X out Y with size Z at location A ##
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## At location A build N X Y with size Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
## At every location X build X Y with size Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
## At every location X build n X Ys with size Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X Y with size Z at every location A ##
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build N X Y with size Z at location A ##
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## At location X Build X with size Y out of Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## At location X Build n Xs with size Y out of Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
## At every location X build n Xs with size Y out of Z ##
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, RelativeDirectionTemplate, BlockObjectThat, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X with size Y out of Z at location A ##
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Build n Xs with size Y out of Z at location A ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Build n Xs with size Y out of Z at every location A ##
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Build X with size Y out of Z at every location A ##
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Place N blocks at n locations X ##
[Human, Place, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Place, RepeatCount, DescribingWord, InARow, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Out of X build Y with size Z at M locations A (same templates as above with N locations) ##
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
# Between templates
[Human, BuildSingle, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, BuildSingle, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Stack, RepeatCount, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, UsingBlockType, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicSize, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicColour, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, UsingBlockType, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, BuildSingle, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, BuildSingle, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Stack, RepeatCount, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Place, RepeatCount, DescribingWord, InARow, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, RepeatCount, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, MadeOutOf, UsingBlockType, Build, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, WithAttributes, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicColour, DescribingWord, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, SchematicColour, DescribingWord, StepsTemplate, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, UsingBlockType, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicSize, UsingBlockType, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicSize, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicColour, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicSize, SchematicColour, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicSize, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicColour, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicSize, SchematicColour, DescribingWord],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, MadeOutOf, UsingBlockType, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, DescribingWord, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, UsingBlockType, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicSize, UsingBlockType, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, UsingBlockType, DescribingWord],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, UsingBlockType, DescribingWord, WithAttributes, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, UsingBlockType, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicSize, UsingBlockType, DescribingWord, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType],
[Human, Build, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Build, RepeatCount, SchematicsDimensions, DescribingWord, WithAttributes, MadeOutOf, UsingBlockType, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/build_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Move templates are written with respect to a Location and represent the intent
for the action: Move. This action specifies the location to which the
agent is expected to move to.
Things to note:
- RelativeDirectionTemplate when not followed by something signifies that RelativeDirection
is with respect to the agent / person who you are speaking to.
Examples:
[Move, ALittle, RelativeDirectionTemplate]
- move a bit to your left.
- move a little to the right.
- walk a little to the front.
[Move, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate]
- walk 5 steps to the right of that grey thing
- move fifty two steps to the left of the orange structure
'''
from template_objects import *
MOVE_WITH_CORRECTION = [
# TODO: add between for BlockObjectThese and BlockObjectThose these as well
## Go there, to the rel_dir of the mob ##
[[Human, Move, ThereTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Move, ThereTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Move, ThereTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, Move, ThereTemplateCoref],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Move, ThereTemplateCoref],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Move, ThereTemplateCoref],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, MoveSingle],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, MoveSingle],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, MoveSingle],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, MoveHere],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, MoveHere],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, MoveHere],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, MoveHereCoref],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, MoveHereCoref],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, MoveHereCoref],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, Move, RelativeDirectionTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, ConditionTypeAdjacentBlockType]],
[[Human, Move, ALittle, RelativeDirectionTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, ConditionTypeAdjacentBlockType]],
[[Human, Move, To, LocationBlockObjectTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, LocationBlockObjectTemplate]],
[[Human, Move, To, BlockObjectThat],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Move, To, BlockObjectThis],
[HumanReplace, Move, RelativeDirectionTemplate, BlockObjectThis]],
[[Human, Move, To, LocationMobTemplate],
[HumanReplace, Move, RelativeDirectionTemplate, LocationMobTemplate]],
]
MOVE_TEMPLATES = [
## One word command for Move ##
[Human, MoveSingle],
# Move with Location ##
[Human, MoveHere],
[Human, MoveHereCoref],
[Human, MoveHere, ConditionTypeNever],
[Human, Move, ThereTemplate],
[Human, Move, ThereTemplateCoref],
[Human, Move, Between, BlockObjectThose],
[Human, Move, Between, BlockObjectThese],
[Human, Move, Between, BlockObjectThose, And, BlockObjectThese],
[Human, Move, Between, BlockObjectThis, And, BlockObjectThat],
[Human, Move, Between, LocationBlockObjectTemplate],
[Human, Move, Between, LocationMobTemplate],
[Human, Move, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Move, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Stand, LocationBlockObjectTemplate],
[Human, Stand, BlockObjectThat],
[Human, Stand, BlockObjectThis],
[Human, Stand, LocationMobTemplate],
[Human, Down, LocationBlockObjectTemplate],
[Human, Down, BlockObjectThat],
[Human, Down, BlockObjectThis],
[Human, Down, LocationMobTemplate],
[Human, Down, ThereTemplateCoref],
[Human, Move, RelativeDirectionTemplate],
[Human, Move, RelativeDirectionTemplate, BlockObjectThat],
[Human, Move, RelativeDirectionTemplate, BlockObjectThis],
[Human, Move, RelativeDirectionTemplate, StepsTemplate],
[Human, Move, RelativeDirectionTemplate, ConditionTypeAdjacentBlockType],
[Human, Move, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Move, ALittle, RelativeDirectionTemplate],
[Human, Move, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Move, ALittle, RelativeDirectionTemplate, BlockObjectThis],
[Human, Move, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Move, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Move, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Move, To, CoordinatesTemplate],
[Human, Move, To, LocationWord, CoordinatesTemplate],
[Human, Move, Between, LocationBlockObjectTemplate],
[Human, Move, Between, LocationMobTemplate],
[Human, Move, To, LocationBlockObjectTemplate],
[Human, Move, To, LocationMobTemplate],
[Human, Move, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Move, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Move, RelativeDirectionTemplate, LocationMobTemplate],
## Other ways of saying Move ##
[Human, Find, LocationMobTemplate],
[Human, Move, To, Where, LocationMobTemplate, Is],
## Follow Mob ##
[Human, Move, LocationMobTemplate, ConditionTypeNever],
[Human, Move, BlockObjectIt, ConditionTypeNever],
[Human, Move, BlockObjectThat, ConditionTypeNever],
[Human, Move, ThisTemplate, LocationMobTemplate, ConditionTypeNever],
## Move n steps m times ##
[Human, Move, StepsTemplate, NTimes],
[Human, Move, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Move, StepsTemplate, RelativeDirectionTemplate, BlockObjectThis],
[Human, Move, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Move, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Move, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
## Climb to the top of X ##
[Human, Move, ClimbDirectionTemplate, LocationBlockObjectTemplate],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/move_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
"""
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
PutMemory templates are written for filters and have an answer_type
They represent the action of writing to the memory using the filters.
Examples:
[[HumanMemory, HumanPosReward],
[Bot, BotThank]],
- human: good job
bot: thanks for letting me know
"""
from template_objects import *
TAG_WITH_CORRECTION = [
## Add location ##
## X is adjective ##
[[Human, BlockObjectThat, Is, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectThat, Is, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectThat, Is, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, BlockObjectThis, Is, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectThis, Is, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectThis, Is, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, BlockObjectIt, Is, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectIt, Is, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectIt, Is, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, Tag, BlockObjectThat, With, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, Tag, BlockObjectThat, With, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, Tag, BlockObjectThat, With, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, Tag, BlockObjectThis, With, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, Tag, BlockObjectThis, With, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, Tag, BlockObjectThis, With, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, Tag, BlockObjectIt, With, TagDesc],
[HumanReplace, The, Size, Thing]],
[[Human, Tag, BlockObjectIt, With, TagDesc],
[HumanReplace, The, Colour, Thing]],
[[Human, Tag, BlockObjectIt, With, TagDesc],
[HumanReplace, The, Size, Colour, Thing]],
# ## X is name ##
[[Human, BlockObjectThat, Is, TagName],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectThat, Is, TagName],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectThat, Is, TagName],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, BlockObjectThis, Is, TagName],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectThis, Is, TagName],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectThis, Is, TagName],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, BlockObjectIt, Is, TagName],
[HumanReplace, The, Size, Thing]],
[[Human, BlockObjectIt, Is, TagName],
[HumanReplace, The, Colour, Thing]],
[[Human, BlockObjectIt, Is, TagName],
[HumanReplace, The, Size, Colour, Thing]],
[[Human, BlockObjectThat, Is, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, BlockObjectThis, Is, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, BlockObjectIt, Is, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Tag, BlockObjectThat, With, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Tag, BlockObjectThis, With, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Tag, BlockObjectIt, With, TagDesc],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## X is name ##
[[Human, BlockObjectThat, Is, TagName],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, BlockObjectThis, Is, TagName],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, BlockObjectIt, Is, TagName],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
]
TAG_TEMPLATES = [
# X is adjective ##
[Human, BlockObjectThat, Is, TagDesc],
[Human, BlockObjectThis, Is, TagDesc],
[Human, BlockObjectIt, Is, TagDesc],
[Human, Tag, BlockObjectThat, With, TagDesc],
[Human, Tag, BlockObjectThis, With, TagDesc],
[Human, Tag, BlockObjectIt, With, TagDesc],
## X is name ##
[Human, BlockObjectThat, Is, TagName],
[Human, BlockObjectThis, Is, TagName],
[Human, BlockObjectIt, Is, TagName],
## The X at Y is adjective ##
[Human, The, AbstractDescription, BlockObjectLocation, Is, TagDesc],
[Human, BlockObjectThat, AbstractDescription, Is, TagDesc],
[Human, BlockObjectThis, AbstractDescription, Is, TagDesc],
[Human, The, ConcreteDescription, BlockObjectLocation, Is, TagDesc],
[Human, BlockObjectThat, ConcreteDescription, Is, TagDesc],
[Human, BlockObjectThis, ConcreteDescription, Is, TagDesc],
## The size X is adjective ##
[Human, BlockObjectThat, Size, AbstractDescription, Is, TagDesc],
[Human, BlockObjectThis, Size, AbstractDescription, Is, TagDesc],
[Human, The, Size, AbstractDescription, BlockObjectLocation, Is, TagDesc],
[Human, BlockObjectThat, Size, ConcreteDescription, Is, TagDesc],
[Human, BlockObjectThis, Size, ConcreteDescription, Is, TagDesc],
[Human, The, Size, ConcreteDescription, BlockObjectLocation, Is, TagDesc],
## The colour X is adjective ##
[Human, BlockObjectThat, Colour, AbstractDescription, Is, TagDesc],
[Human, BlockObjectThis, Colour, AbstractDescription, Is, TagDesc],
[Human, The, Colour, AbstractDescription, BlockObjectLocation, Is, TagDesc],
[Human, BlockObjectThat, Colour, ConcreteDescription, Is, TagDesc],
[Human, BlockObjectThis, Colour, ConcreteDescription, Is, TagDesc],
[Human, The, Colour, ConcreteDescription, BlockObjectLocation, Is, TagDesc],
## The size colour X is adjective ##
[Human, BlockObjectThat, Size, Colour, AbstractDescription, Is, TagDesc],
[Human, BlockObjectThis, Size, Colour, AbstractDescription, Is, TagDesc],
[Human, The, Size, Colour, AbstractDescription, BlockObjectLocation, Is, TagDesc],
[Human, BlockObjectThat, Size, Colour, ConcreteDescription, Is, TagDesc],
[Human, BlockObjectThis, Size, Colour, ConcreteDescription, Is, TagDesc],
[Human, The, Size, Colour, ConcreteDescription, BlockObjectLocation, Is, TagDesc],
# Tag X with adjective ##
[Human, Tag, BlockObjectThat, AbstractDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, AbstractDescription, With, TagDesc],
[Human, Tag,The, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, BlockObjectThat, ConcreteDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, ConcreteDescription, With, TagDesc],
[Human, Tag,The, ConcreteDescription, BlockObjectLocation, With, TagDesc],
## Tag size X with adjective ##
[Human, Tag, BlockObjectThat, Size, AbstractDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Size, AbstractDescription, With, TagDesc],
[Human, Tag, The, Size, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, BlockObjectThat, Size, ConcreteDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Size, ConcreteDescription, With, TagDesc],
[Human, Tag, The, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc],
## Tag colour X with adjective ##
[Human, Tag, BlockObjectThat, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, The, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, BlockObjectThat, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, The, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc],
## Tag size colour X with adjective ##
[Human, Tag, BlockObjectThat, Size, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Size, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, The, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, BlockObjectThat, Size, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, BlockObjectThis, Size, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, The, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc],
## The mob is/ looks adjective ##
[Human, The, MobName, Is, TagDesc],
[Human, MobThis, MobName, Is, TagDesc],
[Human, MobThat, MobName, Is, TagDesc],
[Human, The, MobName, MobLocation, Is, TagDesc],
## Tag mob with adjective ##
[Human, Tag, The, MobName, With, TagDesc],
[Human, Tag, The, MobName, MobLocation, With, TagDesc],
[Human, Tag, MobThis, MobName, With, TagDesc],
[Human, Tag, MobThat, MobName, With, TagDesc],
## The X is/ looks like a name ##
[Human, The, AbstractDescription, BlockObjectLocation, Is, TagName],
[Human, BlockObjectThat, AbstractDescription, Is, TagName],
[Human, BlockObjectThis, AbstractDescription, Is, TagName],
[Human, The, ConcreteDescription, BlockObjectLocation, Is, TagName],
[Human, BlockObjectThat, ConcreteDescription, Is, TagName],
[Human, BlockObjectThis, ConcreteDescription, Is, TagName],
## The size X is/ looks like a name ##
[Human, BlockObjectThat, Size, AbstractDescription, Is, TagName],
[Human, BlockObjectThis, Size, AbstractDescription, Is, TagName],
[Human, The, Size, AbstractDescription, BlockObjectLocation, Is, TagName],
[Human, BlockObjectThat, Size, ConcreteDescription, Is, TagName],
[Human, BlockObjectThis, Size, ConcreteDescription, Is, TagName],
[Human, The, Size, ConcreteDescription, BlockObjectLocation, Is, TagName],
## The colour X is/ looks like a name ##
[Human, BlockObjectThat, Colour, AbstractDescription, Is, TagName],
[Human, BlockObjectThis, Colour, AbstractDescription, Is, TagName],
[Human, The, Colour, AbstractDescription, BlockObjectLocation, Is, TagName],
[Human, BlockObjectThat, Colour, ConcreteDescription, Is, TagName],
[Human, BlockObjectThis, Colour, ConcreteDescription, Is, TagName],
[Human, The, Colour, ConcreteDescription, BlockObjectLocation, Is, TagName],
## The size colour X is/ looks like a name ##
[Human, BlockObjectThat, Size, Colour, AbstractDescription, Is, TagName],
[Human, BlockObjectThis, Size, Colour, AbstractDescription, Is, TagName],
[Human, The, Size, Colour, AbstractDescription, BlockObjectLocation, Is, TagName],
[Human, BlockObjectThat, Size, Colour, ConcreteDescription, Is, TagName],
[Human, BlockObjectThis, Size, Colour, ConcreteDescription, Is, TagName],
[Human, The, Size, Colour, ConcreteDescription, BlockObjectLocation, Is, TagName],
## The mob is / looks like a name ##
[Human, The, MobName, Is, TagName],
[Human, MobThis, MobName, Is, TagName],
[Human, MobThat, MobName, Is, TagName],
[Human, The, MobName, MobLocation, Is, TagName],
### Tag all X as Y ###
[Human, Tag, Everything, With, TagDesc, RepeatAll],
[Human, Tag, All, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Colour, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Colour, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Colour, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Colour, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, Colour, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, Colour, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, Colour, AbstractDescription, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, Colour, ConcreteDescription, With, TagDesc, RepeatAll],
[Human, Tag, MobName, With, TagDesc, RepeatAll],
### Tag all X at location Y as Z ###
[Human, Tag, Everything, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, All, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAll],
[Human, Tag, MobName, MobLocation, With, TagDesc, RepeatAll],
## Tag X at all Y as Z ##
[Human, Tag, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, MobName, MobLocation, With, TagDesc, RepeatAllLocation],
## Tag all X at all Y as Z ##
[Human, Tag, All, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, All, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
[Human, Tag, MobName, MobLocation, With, TagDesc, RepeatAllLocation, RepeatAll],
### Tag num X as Y ###
[Human, Tag, RepeatCount, AbstractDescription, With, TagDesc],
[Human, Tag, RepeatCount, ConcreteDescription, With, TagDesc],
[Human, Tag, RepeatCount, Size, AbstractDescription, With, TagDesc],
[Human, Tag, RepeatCount, Size, ConcreteDescription, With, TagDesc],
[Human, Tag, RepeatCount, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, RepeatCount, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, RepeatCount, Size, Colour, AbstractDescription, With, TagDesc],
[Human, Tag, RepeatCount, Size, Colour, ConcreteDescription, With, TagDesc],
[Human, Tag, RepeatCount, MobName, With, TagDesc],
## Tag num X at location Y as Z ##
[Human, Tag, RepeatCount, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, ConcreteDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Size, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc],
[Human, Tag, RepeatCount, MobName, MobLocation, With, TagDesc],
## Tag X at num Y as Z ##
[Human, Tag, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, MobName, MobLocation, With, TagDesc, RepeatCountLocation],
## Tag num X at num Y as Z ##
[Human, Tag, RepeatCount, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation],
[Human, Tag, RepeatCount, MobName, MobLocation, With, TagDesc, RepeatCountLocation],
## Tag all X at num Y as Z ##
[Human, Tag, All, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, All, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
[Human, Tag, MobName, MobLocation, With, TagDesc, RepeatCountLocation, RepeatAll],
## Tag num X at all Y as Z ##
[Human, Tag, RepeatCount, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Size, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, With, TagDesc, RepeatAllLocation],
[Human, Tag, RepeatCount, MobName, MobLocation, With, TagDesc, RepeatAllLocation]
]
PUT_MEMORY_TEMPLATES = [
## Give positive reward ##
[Human, HumanReward, PosReward],
## Give negative reward ##
[Human, HumanReward, NegReward],
] + TAG_TEMPLATES
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/put_memory_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
"""
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
GetMemory templates are written for filters and have an answer_type
They represent the action of fetching from the memory using the filters.
Examples:
[Human, QueryBotCurrentAction],
- human: what are you doing
- human: what are you up to
[Human, QueryBot, MoveTarget],
- human: where you going
- human: where are you heading
"""
from template_objects import *
ANSWER_WITH_CORRECTION = [
## what is this + the thing at location ##
[[Human, What, Is, BlockObjectThis],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, What, Is, BlockObjectThis, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, What, Is, BlockObjectThat],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, What, Is, BlockObjectThat, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## what size is X + the thing at location ##
[[Human, AskSize, BlockObjectThis],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskSize, BlockObjectThis, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskSize, BlockObjectThis, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskSize, BlockObjectThat],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskSize, BlockObjectThat, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskSize, BlockObjectThat, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## what color is X + the thing at location ##
[[Human, AskColour, BlockObjectThis],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskColour, BlockObjectThis, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskColour, BlockObjectThis, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskColour, BlockObjectThat],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskColour, BlockObjectThat, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskColour, BlockObjectThat, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
# Is X Y ##
[[Human, AskIs, BlockObjectThis, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, AbstractDescription, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, ConcreteDescription, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, AbstractDescription, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, ConcreteDescription, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, The, AbstractDescription, BlockObjectLocation, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, The, ConcreteDescription, BlockObjectLocation, Size],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, AbstractDescription, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, ConcreteDescription, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, AbstractDescription, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, ConcreteDescription, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, The, AbstractDescription, BlockObjectLocation, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, The, ConcreteDescription, BlockObjectLocation, Colour],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
## Is X a Y ##
[[Human, AskIs, BlockObjectThis, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThis, AbstractDescription, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, AskIs, BlockObjectThat, AbstractDescription, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
]
ANSWER_TEMPLATES = [
# 1
## What is X ##
[Human, What, Is, BlockObjectThis],
[Human, What, Is, BlockObjectThis, AbstractDescription],
[Human, What, Is, BlockObjectThat],
[Human, What, Is, BlockObjectThat, AbstractDescription],
# 2
## What is at X ##
[Human, What, Is, BlockObjectLocation],
[Human, What, Is, The, AbstractDescription, BlockObjectLocation],
## What do you see at X ##
[Human, WhatSee, BlockObjectLocation],
# 3
# What size is X ##
[Human, AskSize, BlockObjectThis],
[Human, AskSize, BlockObjectThis, AbstractDescription],
[Human, AskSize, BlockObjectThis, ConcreteDescription],
[Human, AskSize, BlockObjectThat],
[Human, AskSize, BlockObjectThat, AbstractDescription],
[Human, AskSize, BlockObjectThat, ConcreteDescription],
# 4
## what size is X at Y ##
[Human, AskSize, The, AbstractDescription, BlockObjectLocation],
[Human, AskSize, The, ConcreteDescription, BlockObjectLocation],
# 5
# What colour is X ##
[Human, AskColour, BlockObjectThis],
[Human, AskColour, BlockObjectThis, AbstractDescription],
[Human, AskColour, BlockObjectThis, ConcreteDescription],
[Human, AskColour, BlockObjectThat],
[Human, AskColour, BlockObjectThat, AbstractDescription],
[Human, AskColour, BlockObjectThat, ConcreteDescription],
# 6
## what colour is X at Y ##
[Human, AskColour, The, AbstractDescription, BlockObjectLocation],
[Human, AskColour, The, ConcreteDescription, BlockObjectLocation],
# 7
## Is X Y ##
[Human, AskIs, BlockObjectThis, Size],
[Human, AskIs, BlockObjectThis, AbstractDescription, Size],
[Human, AskIs, BlockObjectThis, ConcreteDescription, Size],
[Human, AskIs, BlockObjectThat, Size],
[Human, AskIs, BlockObjectThat, AbstractDescription, Size],
[Human, AskIs, BlockObjectThat, ConcreteDescription, Size],
[Human, AskIs, The, AbstractDescription, BlockObjectLocation, Size],
[Human, AskIs, The, ConcreteDescription, BlockObjectLocation, Size],
[Human, AskIs, BlockObjectThis, Colour],
[Human, AskIs, BlockObjectThis, AbstractDescription, Colour],
[Human, AskIs, BlockObjectThis, ConcreteDescription, Colour],
[Human, AskIs, BlockObjectThat, Colour],
[Human, AskIs, BlockObjectThat, AbstractDescription, Colour],
[Human, AskIs, BlockObjectThat, ConcreteDescription, Colour],
[Human, AskIs, The, AbstractDescription, BlockObjectLocation, Colour],
[Human, AskIs, The, ConcreteDescription, BlockObjectLocation, Colour],
# 8
## Is X a Y ##
[Human, AskIs, BlockObjectThis, ConcreteDescription],
[Human, AskIs, BlockObjectThis, AbstractDescription, ConcreteDescription],
[Human, AskIs, BlockObjectThat, ConcreteDescription],
[Human, AskIs, BlockObjectThat, AbstractDescription, ConcreteDescription],
# 9
## IS X at Y Z ##
[Human, AskIs, The, AbstractDescription, BlockObjectLocation, ConcreteDescription],
]
GET_MEMORY_TEMPLATES = [
## What are you Doing (Action name) ##
[Human, QueryBotCurrentAction],
## What are you Building (Action reference object name) ##
[Human, QueryBot, ActionReferenceObjectName],
## Where are you heading (Move target) ##
[Human, QueryBot, MoveTarget],
## Where are you (Bot location) ##
[Human, QueryBot, CurrentLocation],
] + ANSWER_TEMPLATES
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/get_memory_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Dig templates are written for a Location and represent the intent
for the action: Dig. This action intends to dig a hole at a certain location.
Examples:
[Human, Dig, DigSomeShape, ThereTemplate]
- dig a hole there
- make a tunnel there
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate]
- dig a hole a little to the right of the sheep
- make a tunnel a bit in front of the pig
'''
from template_objects import *
DIG_WITH_CORRECTION = [
## General pattern : dig + new location specification
## Dig X N times, add location ##
[[Human, Dig, DigSomeShape, NTimes],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, NTimes],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigAbstractSize, DigSomeShape, NTimes],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, NTimes],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, NTimes],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, ThereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, ThereTemplateCoref, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, HereTemplate, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, HereTemplateCoref, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, YouTemplate, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DownTo, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, DownTo, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, DownTo, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, ThereTemplate, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, ThereTemplateCoref, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, HereTemplate, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, HereTemplateCoref, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, YouTemplate, ConditionTypeAdjacentBlockType],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
## Dig an X by Y ##
[[Human, Dig, DigDimensions],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
## Dig X of dimensions Y ##
[[Human, Dig, DigSomeShape, OfDimensionsPhrase, DigDimensions],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigDimensions, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigAbstractSize, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigAbstractSize, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigAbstractSize, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigAbstractSize, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
## Dig X Y blocks long / wide / deep ##
[[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, NumBlocks, Squares, Long],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
[[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate, Please]],
]
DIG_TEMPLATES = [
## Single word Dig command ##
[Human, DigSingle],
## Dig at location X (optional) ##
[Human, Dig, Under],
[Human, Dig, Under, YouTemplate],
[Human, Dig, YouTemplate],
[Human, Dig, HereTemplate],
[Human, Dig, HereTemplateCoref],
[Human, Dig, ThereTemplate],
[Human, Dig, ThereTemplateCoref],
[Human, Dig, At, LocationWord, CoordinatesTemplate],
[Human, Dig, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Dig X N times ##
[Human, Dig, DigSomeShape, NTimes],
[Human, Dig, DigDimensions, DigSomeShape, NTimes],
[Human, Dig, DigAbstractSize, DigSomeShape, NTimes],
[Human, Dig, DigDimensions, NTimes],
[Human, Dig, DigDimensions, DigSomeShape, NTimes],
## Dig X at location Y (optional) ##
[Human, Dig, DigSomeShape],
[Human, Dig, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, DigSomeShape, ThereTemplate],
[Human, Dig, DigSomeShape, ThereTemplateCoref],
[Human, Dig, DigSomeShape, HereTemplate],
[Human, Dig, DigSomeShape, HereTemplateCoref],
[Human, Dig, DigSomeShape, YouTemplate],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Dig at location X (optional) until condition Y ##
[Human, Dig, ConditionTypeAdjacentBlockType],
[Human, Dig, At, LocationWord, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ThereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ThereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, HereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, HereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ALittle, RelativeDirectionTemplate, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ALittle, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
## Dig down to block type X ##
[Human, Dig, DownTo, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, DownTo, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, DownTo, ConditionTypeAdjacentBlockType],
## Dig X at location Y (optional) until condition Z ##
[Human, Dig, DigSomeShape, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, At, LocationWord, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ThereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ThereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, HereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, HereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
## Dig an X by Y ##
[Human, Dig, DigDimensions],
## Dig X of dimensions Y ##
[Human, Dig, DigSomeShape, OfDimensionsPhrase, DigDimensions],
## Dig a dimension X shape Y at location Z (optional) ##
[Human, Dig, DigDimensions, DigSomeShape],
[Human, Dig, DigDimensions, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigDimensions, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, DigDimensions, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ThereTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ThereTemplateCoref],
[Human, Dig, DigDimensions, DigSomeShape, HereTemplate],
[Human, Dig, DigDimensions, DigSomeShape, HereTemplateCoref],
[Human, Dig, DigDimensions, DigSomeShape, YouTemplate],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Dig a size X shape Y at location Z (optional) ##
[Human, Dig, DigAbstractSize, DigSomeShape],
[Human, Dig, DigAbstractSize, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigAbstractSize, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ThereTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ThereTemplateCoref],
[Human, Dig, DigAbstractSize, DigSomeShape, HereTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, HereTemplateCoref],
[Human, Dig, DigAbstractSize, DigSomeShape, YouTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Dig X Y blocks long / wide / deep ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep],
## Dig X Y blocks long and Z blocks deep ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
## Dig X Y blocks long Z blocks deep ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long],
## Dig X Y blocks long and Z blocks deep and Z blocks wide ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
## Dig X Y blocks long Z blocks deep Z and blocks wide ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
## Dig X Y blocks long Z blocks deep Z blocks wide ##
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long, NumBlocks, Squares, Deep],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide, NumBlocks, Squares, Long],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide],
[Human, Dig, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep],
##Dig at every location X ##
[Human, Dig, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig X at every location Y ##
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig dimension X shape Y at every location Z ##
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig size X shape Y at every location Z ##
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, RepeatAllLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig N Holes at location Y (optional) ##
[Human, Dig, RepeatCount, DigSomeShape],
[Human, Dig, RepeatCount, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ThereTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ThereTemplateCoref],
[Human, Dig, RepeatCount, DigSomeShape, HereTemplate],
[Human, Dig, RepeatCount, DigSomeShape, HereTemplateCoref],
[Human, Dig, RepeatCount, DigSomeShape, YouTemplate],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Dig N holes at location Y until condition Z ##
[Human, Dig, RepeatCount, DigSomeShape, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, At, LocationWord, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ThereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ThereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, HereTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, HereTemplateCoref, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, ConditionTypeAdjacentBlockType],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, ConditionTypeAdjacentBlockType],
## Dig N holes of dimension Y at location Z ##
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape],
[Human, Dig, RepeatCount, DigSomeShape, OfDimensionsPhrase, DigDimensions],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ThereTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ThereTemplateCoref],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, HereTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, HereTemplateCoref],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, YouTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Dig N holes of size Y at location Z ##
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, At, LocationWord, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ThereTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ThereTemplateCoref],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, HereTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, HereTemplateCoref],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, YouTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## Dig N holes X blocks wide ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep],
## Dig N holes X blocks wide and Y blocks long ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
## Dig N holes X blocks wide Y blocks long ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long],
## Dig N holes X blocks wide and Y blocks long and Z blocks deep ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
## Dig N holes X blocks wide Y blocks long and Z blocks deep ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long, And, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep, And, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide, And, NumBlocks, Squares, Deep],
## Dig N holes X blocks wide Y blocks long Z blocks deep ##
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Wide, NumBlocks, Squares, Long, NumBlocks, Squares, Deep],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide, NumBlocks, Squares, Long],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Deep, NumBlocks, Squares, Long, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Deep, NumBlocks, Squares, Wide],
[Human, Dig, RepeatCount, DigSomeShape, NumBlocks, Squares, Long, NumBlocks, Squares, Wide, NumBlocks, Squares, Deep],
## Dig N X at every location Y ###
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig N dimension X Y at every location Z ##
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig N size X Y at every location Z ##
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, RepeatAllLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatAllLocation],
## Dig at locations X ##
[Human, Dig, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig X at locations Y ##
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig dimension X Y at locations Z ##
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig size X Y at locations Z ##
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, RepeatCountLocation],
[Human, Dig, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig N X at locations Y ##
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig N dimension X Y at locations Z ##
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigDimensions, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
## Dig N size X Y at locations Z ##
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, LocationMobTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, CoordinatesTemplate, RepeatCountLocation],
[Human, Dig, RepeatCount, DigAbstractSize, DigSomeShape, ALittle, RelativeDirectionTemplate, BlockObjectThat, RepeatCountLocation],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/dig_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Copy templates are written for a BlockObject and may have a Location,
and represent the intent for the action: Copy.
This action builds a copy of a physical block object that already exists in the
environment.
Examples:
[Human, Copy, The, Colour, AbstractDescription, NTimes]
- make a copy of the red thing 4 times
- copy the blue structure 2 times
[Human, Copy, RepeatCount, AbstractDescription]
- copy 4 shapes
- make a copy of 4 structures
'''
from template_objects import *
COPY_WITH_CORRECTION = [
## Single word Copy command ##
[[Human, CopySingle],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
## Copy X n times ##
# Abstract #
[[Human, Copy, The, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, The, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, The, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Colour, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Size, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Colour, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Size, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectIt, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectIt, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
## Concrete ##
[[Human, Copy, The, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, The, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, The, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, The, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThose, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThese, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThose, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThese, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Size, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Size, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThis, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
## Copy n of X ##
# Abstract #
[[Human, Copy, RepeatCount, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, RepeatCount, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, RepeatCount, Size, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, RepeatCount, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Size, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
# Concrete #
[[Human, Copy, RepeatCount, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Size, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThose, RepeatCount],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThese, RepeatCount],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription],
[HumanReplace, The, AbstractDescription, BlockObjectLocation]],
[[Human, Copy, BlockObjectThose, RepeatCount],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThese, RepeatCount],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, LocationMobTemplate]],
## Adding rel_dir of BlockObjectThat templates ##
## Single word Copy command ##
[[Human, CopySingle],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
## Copy X n times ##
## Abstract #
[[Human, Copy, The, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, The, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, The, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Size, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectIt, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
## Concrete ##
[[Human, Copy, The, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, The, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, The, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, The, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThose, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThese, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Size, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, NTimes],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Size, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
## Concrete #
[[Human, Copy, RepeatCount, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Size, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThose, RepeatCount],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThese, RepeatCount],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription],
[HumanReplace, Copy, RelativeDirectionTemplate, BlockObjectThat]],
]
COPY_TEMPLATES = [
## Copy X n times ##
# Abstract #
[Human, Copy, The, Colour, AbstractDescription, NTimes],
[Human, Copy, The, Size, AbstractDescription, NTimes],
[Human, Copy, The, Size, Colour, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThat, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThis, NTimes],
[Human, Copy, BlockObjectThis, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, NTimes],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, NTimes],
[Human, Copy, BlockObjectIt, NTimes],
# Concrete #
[Human, Copy, The, ConcreteDescription, NTimes],
[Human, Copy, The, Colour, ConcreteDescription, NTimes],
[Human, Copy, The, Size, ConcreteDescription, NTimes],
[Human, Copy, The, Size, Colour, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThat, NTimes],
[Human, Copy, BlockObjectThose, NTimes],
[Human, Copy, BlockObjectThese, NTimes],
[Human, Copy, BlockObjectThat, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThis, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, NTimes],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, NTimes],
## Copy n of X ##
# Abstract #
[Human, Copy, RepeatCount, AbstractDescription],
[Human, Copy, RepeatCount, Colour, AbstractDescription],
[Human, Copy, RepeatCount, Size, AbstractDescription],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription],
# Concrete #
[Human, Copy, RepeatCount, ConcreteDescription],
[Human, Copy, RepeatCount, Colour, ConcreteDescription],
[Human, Copy, RepeatCount, Size, ConcreteDescription],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription],
[Human, Copy, BlockObjectThose, RepeatCount],
[Human, Copy, BlockObjectThese, RepeatCount],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription],
# Copy n of X at Location ##
# Abstract #
[Human, Copy, RepeatCount, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatCount, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatCount, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, AbstractDescription, HereTemplate],
[Human, Copy, RepeatCount, Colour, AbstractDescription, HereTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, HereTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, HereTemplate],
[Human, Copy, RepeatCount, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Size, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, AbstractDescription, YouTemplate],
[Human, Copy, RepeatCount, Colour, AbstractDescription, YouTemplate],
[Human, Copy, RepeatCount, Size, AbstractDescription, YouTemplate],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThose, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThese, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThose, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThese, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ThereTemplate],
[Human, Copy, BlockObjectThose, ThereTemplate],
[Human, Copy, BlockObjectThese, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, ThereTemplateCoref],
[Human, Copy, BlockObjectThose, ThereTemplateCoref],
[Human, Copy, BlockObjectThese, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, YouTemplate],
[Human, Copy, BlockObjectThese, YouTemplate],
[Human, Copy, BlockObjectThose, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, YouTemplate],
# Concrete #
[Human, Copy, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatCount, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Size, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatCount, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, YouTemplate],
## Copy all X ##
# Abstract #
[Human, Copy, RepeatAll, AbstractDescription],
[Human, Copy, RepeatAll, Colour, AbstractDescription],
[Human, Copy, RepeatAll, Size, AbstractDescription],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription],
[Human, Copy, RepeatAll, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThose],
[Human, Copy, RepeatAll, BlockObjectThese],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription],
# Concrete #
[Human, Copy, RepeatAll, ConcreteDescription],
[Human, Copy, RepeatAll, Colour, ConcreteDescription],
[Human, Copy, RepeatAll, Size, ConcreteDescription],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription],
# Copy all X at Location ##
# Abstract #
[Human, Copy, RepeatAll, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, AbstractDescription, HereTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, HereTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, HereTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, HereTemplate],
[Human, Copy, RepeatAll, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Size, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThose, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThese, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, YouTemplate],
# Concrete #
[Human, Copy, RepeatAll, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Size, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, RepeatAll, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, YouTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, YouTemplate],
## Make n copies of X ##
# Abstract #
[Human, CopyMultiple, The, AbstractDescription],
[Human, CopyMultiple, The, Colour, AbstractDescription],
[Human, CopyMultiple, The, Size, AbstractDescription],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription],
[Human, CopyMultiple, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThese],
[Human, CopyMultiple, BlockObjectThose],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription],
[Human, CopyMultiple, BlockObjectThis],
[Human, CopyMultiple, BlockObjectIt],
[Human, CopyMultiple, BlockObjectThis, AbstractDescription],
[Human, CopyMultiple, BlockObjectThis, Colour, AbstractDescription],
[Human, CopyMultiple, BlockObjectThis, Size, AbstractDescription],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, AbstractDescription],
# Concrete #
[Human, CopyMultiple, The, ConcreteDescription],
[Human, CopyMultiple, The, Colour, ConcreteDescription],
[Human, CopyMultiple, The, Size, ConcreteDescription],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThis, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThis, Colour, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThis, Size, ConcreteDescription],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, ConcreteDescription],
# Make n copies of X at location ##
# Abstract #
[Human, CopyMultiple, The, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, The, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Colour, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Size, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, AbstractDescription, HereTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, HereTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, HereTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, HereTemplate],
[Human, CopyMultiple, The, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Colour, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Size, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, The, AbstractDescription, YouTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, YouTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, YouTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThese, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThose, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThese, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThose, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, ThereTemplate],
[Human, CopyMultiple, BlockObjectThose, ThereTemplate],
[Human, CopyMultiple, BlockObjectThese, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThose, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThese, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, AbstractDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Colour, AbstractDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Size, AbstractDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, AbstractDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Colour, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Size, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, YouTemplate],
[Human, CopyMultiple, BlockObjectThose, YouTemplate],
[Human, CopyMultiple, BlockObjectThese, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, YouTemplate],
# Concrete #
[Human, CopyMultiple, The, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, The, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, The, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Size, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, The, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, The, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Colour, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Size, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, The, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Colour, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Size, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, ConcreteDescription, HereTemplate],
[Human, CopyMultiple, BlockObjectThis, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Colour, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Size, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThis, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, YouTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, YouTemplate],
## Single word copy command ##
[Human, CopySingle],
## Copy X ##
[Human, Copy, BlockObjectThat],
[Human, Copy, BlockObjectThese],
[Human, Copy, BlockObjectThose],
[Human, Copy, BlockObjectThis],
[Human, Copy, BlockObjectIt],
[Human, Copy, BlockObjectThat, AbstractDescription],
[Human, Copy, BlockObjectThis, AbstractDescription],
[Human, Copy, BlockObjectThat, ConcreteDescription],
[Human, Copy, BlockObjectThis, ConcreteDescription],
[Human, Copy, The, AbstractDescription],
[Human, Copy, The, ConcreteDescription],
[Human, Copy, ConcreteDescription],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription],
[Human, Copy, The, Colour, AbstractDescription],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription],
[Human, Copy, The, Colour, ConcreteDescription],
[Human, Copy, BlockObjectThat, AbstractDescription],
[Human, Copy, BlockObjectThis, AbstractDescription],
[Human, Copy, BlockObjectThat, ConcreteDescription],
[Human, Copy, BlockObjectThis, ConcreteDescription],
[Human, Copy, BlockObjectThat, Size, AbstractDescription],
[Human, Copy, BlockObjectThis, Size, AbstractDescription],
[Human, Copy, The, Size, AbstractDescription],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription],
[Human, Copy, The, Size, ConcreteDescription],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription],
[Human, Copy, The, Size, Colour, AbstractDescription],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription],
[Human, Copy, The, Size, Colour, ConcreteDescription],
## Copy X to location Y ##
[Human, Copy, BlockObjectThat, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectIt, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Size, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Size, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, At, LocationWord, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectIt, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectIt, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectIt, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ThereTemplate],
[Human, Copy, BlockObjectIt, ThereTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ThereTemplate],
[Human, Copy, The, AbstractDescription, ThereTemplate],
[Human, Copy, The, ConcreteDescription, ThereTemplate],
[Human, Copy, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, The, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, The, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ThereTemplate],
[Human, Copy, The, Size, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, The, Size, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, ThereTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, ThereTemplate],
[Human, Copy, BlockObjectThis, ThereTemplateCoref],
[Human, Copy, BlockObjectIt, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, The, AbstractDescription, ThereTemplateCoref],
[Human, Copy, The, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, The, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, The, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, The, Size, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, The, Size, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, The, Size, Colour, AbstractDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, The, Size, Colour, ConcreteDescription, ThereTemplateCoref],
[Human, Copy, BlockObjectThat, HereTemplate],
[Human, Copy, BlockObjectThis, HereTemplate],
[Human, Copy, BlockObjectIt, HereTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, HereTemplate],
[Human, Copy, The, AbstractDescription, HereTemplate],
[Human, Copy, The, ConcreteDescription, HereTemplate],
[Human, Copy, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, HereTemplate],
[Human, Copy, The, Colour, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, The, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, HereTemplate],
[Human, Copy, The, Size, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, HereTemplate],
[Human, Copy, The, Size, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, HereTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, HereTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, HereTemplate],
[Human, Copy, BlockObjectThat, HereTemplateCoref],
[Human, Copy, BlockObjectThis, HereTemplateCoref],
[Human, Copy, BlockObjectIt, HereTemplateCoref],
[Human, Copy, BlockObjectThat, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, ConcreteDescription, HereTemplateCoref],
[Human, Copy, The, AbstractDescription, HereTemplateCoref],
[Human, Copy, The, ConcreteDescription, HereTemplateCoref],
[Human, Copy, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, The, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, The, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, HereTemplateCoref],
[Human, Copy, The, Size, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, HereTemplateCoref],
[Human, Copy, The, Size, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, The, Size, Colour, AbstractDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, The, Size, Colour, ConcreteDescription, HereTemplateCoref],
[Human, Copy, BlockObjectThis, YouTemplate],
[Human, Copy, BlockObjectIt, YouTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, YouTemplate],
[Human, Copy, The, AbstractDescription, YouTemplate],
[Human, Copy, The, ConcreteDescription, YouTemplate],
[Human, Copy, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, YouTemplate],
[Human, Copy, The, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, The, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, YouTemplate],
[Human, Copy, The, Size, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, YouTemplate],
[Human, Copy, The, Size, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, YouTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, YouTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, YouTemplate],
[Human, Copy, BlockObjectThat, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectIt, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectIt, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectIt, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectIt, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, Copy, BlockObjectThat, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectIt, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectIt, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectIt, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
## rel_dir of BlockObjectThat templates ##
[Human, Copy, RepeatCount, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThose, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThese, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThese, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThose, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectIt, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, AbstractDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, ConcreteDescription, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectIt, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, AbstractDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, ConcreteDescription, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectIt, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, AbstractDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
[Human, Copy, The, Size, Colour, ConcreteDescription, ALittle, RelativeDirectionTemplate, BlockObjectThat],
# between templates
[Human, Copy, BlockObjectThat, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThose, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThese, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThese, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThose, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectIt, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Size, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Size, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, Copy, BlockObjectThat, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThose, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThese, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatCount, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, RepeatCount, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThose, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThese, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, RepeatAll, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThese, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThose, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, The, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, CopyMultiple, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectIt, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Size, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Size, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Size, Colour, AbstractDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThat, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, BlockObjectThis, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, Copy, The, Size, Colour, ConcreteDescription, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/copy_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Freebuild templates are written for :
- either a BlockObject or a Location.
and represents the intent for the action: Freebuild.
This action intends for a generation model to complete or finish something that
is half-built.
Examples:
[Human, Freebuild, The, Colour, AbstractDescription, BlockObjectLocation]
- complete the red structure to the left of that grey shape.
- finish the blue thing at location: 2 , 3, 4 for me
[Human, Freebuild, BlockObjectThat, Size, Colour, AbstractDescription]
- complete that huge red structure
- finish that tiny blue thing for me please
etc
'''
from template_objects import *
FREEBUILD_WITH_CORRECTION = [
[[Human, FreebuildLocation, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, FreebuildLocation, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, FreebuildLocation, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, FreebuildLocation, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, LocationMobTemplate]],
[[Human, FreebuildLocation, ThereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, FreebuildLocation, HereTemplate],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, FreebuildLocation, HereTemplateCoref],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, FreebuildLocation, YouTemplate],
[HumanReplace, RelativeDirectionTemplate, BlockObjectThat]],
[[Human, Freebuild, BlockObjectThat, ForMe],
[HumanReplace, The, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectThat, ForMe],
[HumanReplace, The, Size, AbstractDescription]],
[[Human, Freebuild, BlockObjectThat, ForMe],
[HumanReplace, The, Size, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectThis, ForMe],
[HumanReplace, The, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectThis, ForMe],
[HumanReplace, The, Size, AbstractDescription]],
[[Human, Freebuild, BlockObjectThis, ForMe],
[HumanReplace, The, Size, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectIt, ForMe],
[HumanReplace, The, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectIt, ForMe],
[HumanReplace, The, Size, AbstractDescription]],
[[Human, Freebuild, BlockObjectIt, ForMe],
[HumanReplace, The, Size, Colour, AbstractDescription]],
[[Human, Freebuild, BlockObjectThat, Colour, AbstractDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThis, Colour, AbstractDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, The, Colour, AbstractDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThat, Colour, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThis, Colour, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, The, Colour, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThat, AbstractDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThat, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThat, AbstractDescription, ForMe],
[HumanReplace, The, Size, Colour, One]],
[[Human, Freebuild, BlockObjectThis, AbstractDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThis, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThis, AbstractDescription, ForMe],
[HumanReplace, The, Size, Colour, One]],
[[Human, Freebuild, BlockObjectThat, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThat, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThat, ConcreteDescription, ForMe],
[HumanReplace, The, Size, Colour, One]],
[[Human, Freebuild, BlockObjectThis, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, BlockObjectThis, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThis, ConcreteDescription, ForMe],
[HumanReplace, The, Size, Colour, One]],
[[Human, Freebuild, BlockObjectThat, Size, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThis, Size, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, The, Size, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThat, Size, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, BlockObjectThis, Size, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, The, Size, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, The, Size, AbstractDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, The, Size, ConcreteDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, RepeatCount, ConcreteDescription, ForMe],
[HumanReplace, The, Size, Colour, One]],
[[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, RepeatCount, Size, AbstractDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, Size, ConcreteDescription, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, Size, AbstractDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Colour, One]],
[[Human, Freebuild, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Size, One]],
[[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, ForMe],
[HumanReplace, The, Size, One]],
]
FREEBUILD_TEMPLATES = [
## Freebuild with only Location ##
[Human, FreebuildLocation, At, LocationWord, CoordinatesTemplate],
[Human, FreebuildLocation, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, FreebuildLocation, Between, LocationBlockObjectTemplate, And, LocationMobTemplate],
[Human, FreebuildLocation, Between, LocationMobTemplate, And, LocationBlockObjectTemplate],
[Human, FreebuildLocation, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, FreebuildLocation, RelativeDirectionTemplate, LocationMobTemplate],
[Human, FreebuildLocation, RelativeDirectionTemplate, BlockObjectThat],
[Human, FreebuildLocation, ThereTemplate],
[Human, FreebuildLocation, ThereTemplateCoref],
[Human, FreebuildLocation, HereTemplate],
[Human, FreebuildLocation, HereTemplateCoref],
[Human, FreebuildLocation, YouTemplate],
[Human, FreebuildLocation, StepsTemplate, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, FreebuildLocation, StepsTemplate, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, FreebuildLocation, StepsTemplate, RelativeDirectionTemplate, LocationMobTemplate],
[Human, FreebuildLocation, StepsTemplate, RelativeDirectionTemplate, BlockObjectThat],
[Human, FreebuildLocation, ALittle, RelativeDirectionTemplate, YouTemplate],
[Human, FreebuildLocation, ALittle, RelativeDirectionTemplate, LocationBlockObjectTemplate],
[Human, FreebuildLocation, ALittle, RelativeDirectionTemplate, LocationMobTemplate],
[Human, FreebuildLocation, ALittle, RelativeDirectionTemplate, CoordinatesTemplate],
[Human, FreebuildLocation, ALittle, RelativeDirectionTemplate, BlockObjectThat],
## Freebuild with only BlockObject ##
[Human, Freebuild, BlockObjectThat, ForMe],
[Human, Freebuild, BlockObjectThis, ForMe],
[Human, Freebuild, BlockObjectIt, ForMe],
[Human, Freebuild, BlockObjectThat, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThis, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThat, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThis, ConcreteDescription, ForMe],
[Human, Freebuild, The, ConcreteDescription, ForMe],
[Human, Freebuild, ConcreteDescription, ForMe],
[Human, Freebuild, The, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, The, ConcreteDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, BlockObjectThat, Colour, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Colour, AbstractDescription, ForMe],
[Human, Freebuild, The, Colour, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThat, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, The, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThat, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThis, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThat, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThis, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThat, Size, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Size, AbstractDescription, ForMe],
[Human, Freebuild, The, Size, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThat, Size, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Size, ConcreteDescription, ForMe],
[Human, Freebuild, The, Size, ConcreteDescription, ForMe],
[Human, Freebuild, The, Size, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, The, Size, ConcreteDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, The, Colour, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, The, Colour, ConcreteDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, BlockObjectThat, Size, Colour, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Size, Colour, AbstractDescription, ForMe],
[Human, Freebuild, The, Size, Colour, AbstractDescription, ForMe],
[Human, Freebuild, BlockObjectThat, Size, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, BlockObjectThis, Size, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, The, Size, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, The, Size, Colour, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, The, Size, Colour, ConcreteDescription, BlockObjectLocation, ForMe],
### Freebuild num X ###
[Human, Freebuild, RepeatCount, ConcreteDescription, ForMe],
[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, RepeatCount, Size, AbstractDescription, ForMe],
[Human, Freebuild, RepeatCount, Size, ConcreteDescription, ForMe],
[Human, Freebuild, RepeatCount, Size, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, AbstractDescription, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, ConcreteDescription, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, ForMe],
### Freebuild X in front of num Y ###
[Human, Freebuild, The, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, The, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, The, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, The, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, The, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, The, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
### Freebuild num X in front of num Y ###
[Human, Freebuild, RepeatCount, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, ForMe],
### Freebuild All X in front of Y ###
[Human, Freebuild, All, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Size, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Size, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Size, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, AbstractDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, ConcreteDescription, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAll, ForMe],
### Freebuild X in front of all Ys ###
[Human, Freebuild, The, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, The, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
### Freebuild all X in front of all Ys ###
[Human, Freebuild, All, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, RepeatAll, ForMe],
### Freebuild all X in front of n Ys ###
[Human, Freebuild, All, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, All, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
[Human, Freebuild, Every, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatCountLocation, RepeatAll, ForMe],
### Freebuild n X in front of all Ys ###
[Human, Freebuild, RepeatCount, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, AbstractDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
[Human, Freebuild, RepeatCount, Size, Colour, ConcreteDescription, BlockObjectLocation, RepeatAllLocation, ForMe],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/freebuild_templates.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
'''
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
Dance templates are written with an optional location and stop condition.
Examples:
[Human, DanceSingle]
- do a dance
- dance
[Human, DanceSingle, ConditionTypeNever],
- keep dancing
- dance until I tell you to stop
'''
from template_objects import *
DANCE_WITH_CORRECTION = [
[[Human, Dance],
[HumanReplace, Dance, AroundString]],
[[Human, Jump],
[HumanReplace, Jump, AroundString]],
[[Human, Fly],
[HumanReplace, Fly, AroundString]],
[[Human, Hop],
[HumanReplace, Hop, AroundString]],
]
DANCE_TEMPLATES = [
## Dance single word ##
[Human, Dance],
[Human, Dance, ConditionTypeNever],
[Human, Fly],
[Human, Fly, ConditionTypeNever],
[Human, Jump],
[Human, Jump, ConditionTypeNever],
[Human, Hop],
[Human, Hop, ConditionTypeNever],
## Walk around X ##
[Human, Fly, AroundString, LocationBlockObjectTemplate],
[Human, Jump, AroundString, LocationBlockObjectTemplate],
[Human, Hop, AroundString, LocationBlockObjectTemplate],
[Human, Dance, AroundString, LocationBlockObjectTemplate],
[Human, Walk, AroundString, LocationBlockObjectTemplate],
## Move around X clockwise / anticlockwise ##
[Human, Fly, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate],
[Human, Jump, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate],
[Human, Hop, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate],
[Human, Dance, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate],
[Human, Walk, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate],
## move around X clockwise/anticlockwise n times ##
[Human, Dance, NTimes],
[Human, Fly, NTimes],
[Human, Jump, NTimes],
[Human, Hop, NTimes],
[Human, Fly, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate, NTimes],
[Human, Jump, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate, NTimes],
[Human, Hop, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate, NTimes],
[Human, Dance, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate, NTimes],
[Human, Walk, AroundString, LocationBlockObjectTemplate, RelativeDirectionTemplate, NTimes],
]
| craftassist-master | python/base_agent/ttad/generation_dialogues/templates/dance_templates.py |
import torch
from dataset import *
from huggingface_modeling_gpt2 import *
from transformer import *
def compute_accuracy(outputs, y, tokenizer):
"""Compute model accuracy given predictions and targets. Used in validation.
"""
# Do not include [CLS] token
target_tokens = y[:, 1:]
predicted_tokens = outputs.max(dim=-1)[1][:, :-1]
acc = (predicted_tokens == target_tokens).sum(dim=1) == target_tokens.shape[-1]
return acc
def validate(model, dataset, tokenizer):
valid_loader = torch.utils.data.DataLoader(dataset=dataset, batch_size=1, shuffle=False)
tot_acc = 0.0
tot_loss = 0.0
steps = 0
with torch.no_grad():
for i, batch in enumerate(valid_loader):
trees, text = batch
text_idx_ls = [tokenizer.encode(cmd) for cmd in text]
tree_idx_ls = [tokenizer.encode(tree) for tree in trees]
x, x_mask, y, y_mask = collate(tree_idx_ls, text_idx_ls, tokenizer)
out = model(x, x_mask, y, y_mask)
loss, predictions = out[:2]
lm_acc = compute_accuracy(predictions, y, tokenizer)
acc = lm_acc.sum().item() / lm_acc.shape[0]
tot_acc += acc
tot_loss += loss.item()
steps += 1
print("Valid accuracy: {} Loss: {}".format(tot_acc / steps, tot_loss / steps))
| craftassist-master | python/base_agent/ttad/back_translation/train_utils.py |
from transformers import GPT2Tokenizer, BertTokenizer
from dataset import *
# from transformers.modeling_gpt2 import *
from huggingface_modeling_gpt2 import *
from transformer import *
import argparse
import numpy as np
import torch.nn.functional as F
# make sure GPT2 appends EOS in begin and end
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
outputs = [self.bos_token_id] + token_ids_0 + [self.eos_token_id]
return outputs
class QueryModel:
def __init__(self, model, encoder_tokenizer, decoder_tokenizer):
self.model = model
self.encoder_tokenizer = encoder_tokenizer
self.decoder_tokenizer = decoder_tokenizer
def top_k_sampling(self, y, y_mask, x_reps, x_mask, ntok):
orig_mask = y_mask
for _ in range(ntok):
out = self.model.decoder(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
# use_lm=True,
)[0]
logits = out[:, -1, :]
indices_to_remove = logits < torch.topk(logits, 10)[0][..., -1, None]
logits[indices_to_remove] = np.NINF
next_tok = torch.multinomial(nn.Softmax(dim=-1)(logits), num_samples=1).squeeze(1)
y = torch.cat([y, next_tok.unsqueeze(-1)], dim=-1)
y_mask = F.pad(orig_mask, pad=(0, y.shape[-1] - 1), mode="constant", value=1)
if next_tok == self.decoder_tokenizer.eos_token_id:
return y
return y
def generate(self, tree_input, top_k=0, beam_size=0):
model_device = self.model.encoder.device
text_idx_ls = [[self.decoder_tokenizer.eos_token_id]]
tree_idx_ls = [self.encoder_tokenizer.encode(tree_input, add_special_tokens=True)]
batch = collate(tree_idx_ls, text_idx_ls, self.encoder_tokenizer, self.decoder_tokenizer)
batch = [torch.tensor(t) for t in batch[:4]]
batch = [t.to(model_device) for t in batch[:4]]
x, x_mask, y, y_mask = batch
x_reps = self.model.encoder(input_ids=x, attention_mask=x_mask)[0].detach()
if top_k > 0:
out = self.top_k_sampling(y, y_mask, x_reps, x_mask, top_k)
return self.decoder_tokenizer.decode(out[0])
if beam_size > 1:
# NOTE: beam search is WIP
x_mask = x_mask.expand(beam_size, -1)
x_reps = x_reps.expand(beam_size, -1, -1)
y = torch.LongTensor(
[[self.decoder_tokenizer.eos_token_id] for _ in range(beam_size)]
).to(model_device)
beam_scores = torch.Tensor([-1e9 for _ in range(beam_size)]).to(model_device) # B
beam_scores[0] = 0
finished = [False for _ in range(beam_size)]
else:
# defaults to greedy
y = torch.LongTensor([[self.decoder_tokenizer.eos_token_id]]).to(model_device)
beam_scores = torch.Tensor([-1e9]).to(model_device)
beam_scores[0] = 0
preds = [
[self.decoder_tokenizer._convert_id_to_token(self.decoder_tokenizer.eos_token_id)]
]
finished = [False]
pad_scores = torch.Tensor([-1e9] * self.decoder_tokenizer.vocab_size).to(model_device)
for i in range(20):
outputs = self.model.decoder(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
# use_lm=True,
)[0]
predicted_scores = outputs[:, -1, :]
for i, fshed in enumerate(finished):
if fshed:
predicted_scores[i] = pad_scores
total_scores = predicted_scores + beam_scores[:, None]
linearized_scores = total_scores.view(-1)
sorted_scores, sorted_ids = linearized_scores.sort(dim=-1, descending=True)
# all 0 for now
seq_ids = sorted_ids // total_scores.shape[-1]
s_word_ids = sorted_ids % total_scores.shape[-1]
# just taking first and only element for now
beam_scores = sorted_scores[:1]
# beam size of 1
beam_ids = seq_ids[:1]
word_ids = s_word_ids[:1]
words = [self.decoder_tokenizer.decode(word_ids)]
# add next token
y = torch.cat([y[beam_ids], word_ids[:, None]], dim=1)
# find out whether sequence is finished; currently only one sequence
pre_finished = [finished[b_id.item()] for b_id in beam_ids]
new_finished = [
w_id.item() == self.decoder_tokenizer.eos_token_id for w_id in word_ids
]
finished = [p or n for p, n in zip(pre_finished, new_finished)]
n_mask = 1 - torch.Tensor(finished).type_as(y_mask)
y_mask = torch.cat([y_mask[beam_ids], n_mask[:, None]], dim=1)
preds = [preds[0] + [(words[0])]]
# check whether sequence has reached EOS; currently only one sequence
if finished[0]:
break
return " ".join(preds[0])
parser = argparse.ArgumentParser()
parser.add_argument(
"--pretrained_encoder_path",
default="python/craftassist/models/backtranslation/encoder/",
type=str,
help="path to binarized model and config of saved encoder",
)
parser.add_argument(
"--pretrained_decoder_path",
default="python/craftassist/models/backtranslation/decoder/",
type=str,
help="path to binarized model and config of saved decoder",
)
args = parser.parse_args()
bert_tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
bert_tokenizer.bos_token = bert_tokenizer.cls_token
bert_tokenizer.eos_token = bert_tokenizer.sep_token
gpt2_tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
gpt2_tokenizer.pad_token = gpt2_tokenizer.unk_token
GPT2Tokenizer.build_inputs_with_special_tokens = build_inputs_with_special_tokens
enc_model = BertModel.from_pretrained(args.pretrained_encoder_path)
dec_model = GPT2LMHeadModel.from_pretrained(args.pretrained_decoder_path)
encoder_decoder = EncoderDecoder(enc_model, dec_model)
generator = QueryModel(encoder_decoder, bert_tokenizer, gpt2_tokenizer)
| craftassist-master | python/base_agent/ttad/back_translation/generate.py |
from transformers import AutoConfig, AutoTokenizer
from dataset import *
from modeling_gpt2 import *
from transformer import *
from torch.utils.data import DataLoader
import argparse
from os.path import join as pjoin
import torch
from train_utils import *
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="/checkpoint/rebeccaqian/datasets/fairseq/08_04/",
type=str,
help="train/valid/test data",
)
parser.add_argument(
"--output_dir",
default="/checkpoint/rebeccaqian/backtranslation/{}/models/".format(str(date.today())),
type=str,
help="directory to save checkpoint models",
)
parser.add_argument("--lr", default=0.0001, type=float, help="learning rate")
parser.add_argument("--batch_size", default=1, type=int, help="batch size")
parser.add_argument("--num_epochs", default=20, type=int, help="number of epochs")
args = parser.parse_args()
config_decoder = AutoConfig.from_pretrained("gpt2", is_decoder=True)
config_encoder = AutoConfig.from_pretrained("gpt2", is_decoder=False)
tokenizer = AutoTokenizer.from_pretrained("gpt2")
enc_model = GPT2Model(config=config_encoder)
dec_model = GPT2LMHeadModel.from_pretrained("gpt2", config=config_decoder)
encoder_decoder = EncoderDecoder(enc_model, dec_model)
# freeze decoder weights
decoder_params = dec_model.named_parameters()
for name, param in decoder_params:
param.requires_grad = False
train_prog_data, train_chat_data = load_paired_dataset(args.data_dir, "train")
train_dataset = Tree2TextDataset(train_prog_data, train_chat_data)
train_loader = DataLoader(dataset=train_dataset, batch_size=1, shuffle=True)
valid_prog_data, valid_chat_data = load_paired_dataset(args.data_dir, "valid")
valid_dataset = Tree2TextDataset(valid_prog_data, valid_chat_data)
optimizer = torch.optim.Adam(encoder_decoder.parameters(), lr=args.lr)
for epoch in range(args.num_epochs):
print("Epoch: {}".format(epoch))
enc_model.train()
dec_model.train()
for i, batch in enumerate(train_loader):
trees, text = batch
optimizer.zero_grad()
text_idx_ls = [tokenizer.encode(cmd) for cmd in text]
tree_idx_ls = [tokenizer.encode(tree) for tree in trees]
x, x_mask, y, y_mask = collate(tree_idx_ls, text_idx_ls, tokenizer)
outputs = encoder_decoder(x, x_mask, y, y_mask)
loss, predictions = outputs[:2]
# Taking the first row in the batch as logging example
predicted_example = predictions.max(dim=-1)[1][:, :-1]
predicted_sentence = tokenizer.decode(predicted_example[0])
print(
"sample predictions:\n X: {} Y: {} predicted: {}".format(
trees[0], text[0], predicted_sentence
)
)
loss.backward()
optimizer.step()
print("Iteration: {} Loss: {}".format(i, loss))
torch.save(
encoder_decoder.state_dict(),
pjoin("{}encoder|(ep=={}).pth".format(args.output_dir, epoch)),
)
# Evaluating model
encoder_decoder.eval()
print("Evaluating model")
validate(encoder_decoder, valid_dataset, tokenizer)
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/back_translation/train_custom_gpt2.py |
# coding=utf-8
# Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""PyTorch OpenAI GPT-2 model."""
import logging
import os
import warnings
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from transformers.modeling_gpt2 import PreTrainedModel, GPT2Config
from transformers.modeling_outputs import (
BaseModelOutputWithPast,
CausalLMOutputWithPast,
GPT2DoubleHeadsModelOutput,
)
from transformers.activations import ACT2FN
from transformers.modeling_utils import (
Conv1D,
prune_conv1d_layer,
SequenceSummary,
find_pruneable_heads_and_indices,
)
logger = logging.getLogger(__name__)
_CONFIG_FOR_DOC = "GPT2Config"
_TOKENIZER_FOR_DOC = "GPT2Tokenizer"
GPT2_PRETRAINED_MODEL_ARCHIVE_LIST = [
"gpt2",
"gpt2-medium",
"gpt2-large",
"gpt2-xl",
"distilgpt2",
# See all GPT-2 models at https://huggingface.co/models?filter=gpt2
]
def load_tf_weights_in_gpt2(model, config, gpt2_checkpoint_path):
""" Load tf checkpoints in a pytorch model
"""
try:
import re
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow model in PyTorch, requires TensorFlow to be installed. Please see "
"https://www.tensorflow.org/install/ for installation instructions."
)
raise
tf_path = os.path.abspath(gpt2_checkpoint_path)
logger.info("Converting TensorFlow checkpoint from {}".format(tf_path))
# Load weights from TF model
init_vars = tf.train.list_variables(tf_path)
names = []
arrays = []
for name, shape in init_vars:
logger.info("Loading TF weight {} with shape {}".format(name, shape))
array = tf.train.load_variable(tf_path, name)
names.append(name)
arrays.append(array.squeeze())
for name, array in zip(names, arrays):
name = name[6:] # skip "model/"
name = name.split("/")
pointer = model
for m_name in name:
if re.fullmatch(r"[A-Za-z]+\d+", m_name):
scope_names = re.split(r"(\d+)", m_name)
else:
scope_names = [m_name]
if scope_names[0] == "w" or scope_names[0] == "g":
pointer = getattr(pointer, "weight")
elif scope_names[0] == "b":
pointer = getattr(pointer, "bias")
elif scope_names[0] == "wpe" or scope_names[0] == "wte":
pointer = getattr(pointer, scope_names[0])
pointer = getattr(pointer, "weight")
else:
pointer = getattr(pointer, scope_names[0])
if len(scope_names) >= 2:
num = int(scope_names[1])
pointer = pointer[num]
try:
assert (
pointer.shape == array.shape
), f"Pointer shape {pointer.shape} and array shape {array.shape} mismatched"
except AssertionError as e:
e.args += (pointer.shape, array.shape)
raise
logger.info("Initialize PyTorch weight {}".format(name))
pointer.data = torch.from_numpy(array)
return model
class Attention(nn.Module):
def __init__(self, nx, n_ctx, config, scale=False):
super().__init__()
n_state = nx # in Attention: n_state=768 (nx=n_embd)
# [switch nx => n_state from Block to Attention to keep identical to TF implem]
assert n_state % config.n_head == 0
self.register_buffer(
"bias",
torch.tril(torch.ones((n_ctx, n_ctx), dtype=torch.uint8)).view(1, 1, n_ctx, n_ctx),
)
self.register_buffer("masked_bias", torch.tensor(-1e4))
self.n_head = config.n_head
self.split_size = n_state
self.scale = scale
self.c_attn = Conv1D(n_state * 3, nx)
# TODO: check config.hidden_size
self.query = nn.Linear(n_state, nx)
self.key = nn.Linear(n_state, nx)
self.value = nn.Linear(n_state, nx)
self.c_proj = Conv1D(n_state, nx)
self.attn_dropout = nn.Dropout(config.attn_pdrop)
self.resid_dropout = nn.Dropout(config.resid_pdrop)
self.pruned_heads = set()
self.config = config
def prune_heads(self, heads):
if len(heads) == 0:
return
heads, index = find_pruneable_heads_and_indices(
heads, self.n_head, self.split_size // self.n_head, self.pruned_heads
)
index_attn = torch.cat([index, index + self.split_size, index + (2 * self.split_size)])
# Prune conv1d layers
self.c_attn = prune_conv1d_layer(self.c_attn, index_attn, dim=1)
self.c_proj = prune_conv1d_layer(self.c_proj, index, dim=0)
# Update hyper params
self.split_size = (self.split_size // self.n_head) * (self.n_head - len(heads))
self.n_head = self.n_head - len(heads)
self.pruned_heads = self.pruned_heads.union(heads)
def _attn(self, q, k, v, attention_mask=None, head_mask=None, output_attentions=False):
w = torch.matmul(q, k)
if self.scale:
w = w / (float(v.size(-1)) ** 0.5)
nd, ns = w.size(-2), w.size(-1)
mask = self.bias[:, :, ns - nd : ns, :ns]
w = torch.where(mask.bool(), w, self.masked_bias.to(w.dtype))
if attention_mask is not None:
# Apply the attention mask
w = w + attention_mask
w = nn.Softmax(dim=-1)(w)
w = self.attn_dropout(w)
# Mask heads if we want to
if head_mask is not None:
w = w * head_mask
outputs = [torch.matmul(w, v)]
if output_attentions:
outputs.append(w)
return outputs
def merge_heads(self, x):
x = x.permute(0, 2, 1, 3).contiguous()
new_x_shape = x.size()[:-2] + (x.size(-2) * x.size(-1),)
return x.view(*new_x_shape) # in Tensorflow implem: fct merge_states
def split_heads(self, x, k=False):
new_x_shape = x.size()[:-1] + (self.n_head, x.size(-1) // self.n_head)
x = x.view(*new_x_shape) # in Tensorflow implem: fct split_states
if k:
return x.permute(0, 2, 3, 1) # (batch, head, head_features, seq_length)
else:
return x.permute(0, 2, 1, 3) # (batch, head, seq_length, head_features)
def forward(
self,
x,
layer_past=None,
attention_mask=None,
head_mask=None,
use_cache=False,
output_attentions=False,
encoder_hidden_states=None,
encoder_attention_mask=None,
):
if self.config.is_decoder:
assert encoder_hidden_states is not None
key = self.key(encoder_hidden_states)
value = self.value(encoder_hidden_states)
query = self.query(x)
else:
x = self.c_attn(x)
query, key, value = x.split(self.split_size, dim=2)
query = self.split_heads(query)
key = self.split_heads(key, k=True)
value = self.split_heads(value)
if layer_past is not None:
past_key, past_value = (
layer_past[0].transpose(-2, -1),
layer_past[1],
) # transpose back cf below
key = torch.cat((past_key, key), dim=-1)
value = torch.cat((past_value, value), dim=-2)
if use_cache is True:
present = torch.stack(
(key.transpose(-2, -1), value)
) # transpose to have same shapes for stacking
else:
present = (None,)
if self.config.is_decoder:
attn_outputs = self._attn(
query, key, value, encoder_attention_mask, head_mask, output_attentions
)
else:
attn_outputs = self._attn(
query, key, value, attention_mask, head_mask, output_attentions
)
at = attn_outputs[0]
at = self.merge_heads(at)
at = self.c_proj(at)
at = self.resid_dropout(at)
outputs = [at, present] + attn_outputs[1:]
return outputs # a, present, (attentions)
class MLP(nn.Module):
def __init__(self, n_state, config): # in MLP: n_state=3072 (4 * n_embd)
super().__init__()
nx = config.n_embd
self.c_fc = Conv1D(n_state, nx)
self.c_proj = Conv1D(nx, n_state)
self.act = ACT2FN[config.activation_function]
self.dropout = nn.Dropout(config.resid_pdrop)
def forward(self, x):
h = self.act(self.c_fc(x))
h2 = self.c_proj(h)
return self.dropout(h2)
class Block(nn.Module):
def __init__(self, n_ctx, config, scale=False):
super().__init__()
nx = config.n_embd
inner_dim = config.n_inner if config.n_inner is not None else 4 * nx
self.ln_1 = nn.LayerNorm(nx, eps=config.layer_norm_epsilon)
self.attn = Attention(nx, n_ctx, config, scale)
self.ln_2 = nn.LayerNorm(nx, eps=config.layer_norm_epsilon)
self.mlp = MLP(inner_dim, config)
self.config = config
"""
TODO: add another self attention layer?
"""
def forward(
self,
x,
layer_past=None,
attention_mask=None,
head_mask=None,
use_cache=False,
output_attentions=False,
encoder_hidden_states=None,
encoder_attention_mask=None,
):
output_attn = self.attn(
self.ln_1(x),
layer_past=layer_past,
attention_mask=attention_mask,
head_mask=head_mask,
use_cache=use_cache,
output_attentions=output_attentions,
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
)
a = output_attn[0] # output_attn: a, present, (attentions)
x = x + a
m = self.mlp(self.ln_2(x))
x = x + m
outputs = [x] + output_attn[1:]
return outputs # x, present, (attentions)
class GPT2PreTrainedModel(PreTrainedModel):
""" An abstract class to handle weights initialization and
a simple interface for downloading and loading pretrained models.
"""
config_class = GPT2Config
load_tf_weights = load_tf_weights_in_gpt2
base_model_prefix = "transformer"
def __init__(self, *inputs, **kwargs):
super().__init__(*inputs, **kwargs)
def _init_weights(self, module):
""" Initialize the weights.
"""
if isinstance(module, (nn.Linear, nn.Embedding, Conv1D)):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
if isinstance(module, (nn.Linear, Conv1D)) and module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.LayerNorm):
module.bias.data.zero_()
module.weight.data.fill_(1.0)
class GPT2Model(GPT2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.wte = nn.Embedding(config.vocab_size, config.n_embd)
self.wpe = nn.Embedding(config.n_positions, config.n_embd)
self.drop = nn.Dropout(config.embd_pdrop)
self.h = nn.ModuleList(
[Block(config.n_ctx, config, scale=True) for _ in range(config.n_layer)]
)
self.ln_f = nn.LayerNorm(config.n_embd, eps=config.layer_norm_epsilon)
self.init_weights()
def get_input_embeddings(self):
return self.wte
def set_input_embeddings(self, new_embeddings):
self.wte = new_embeddings
def _prune_heads(self, heads_to_prune):
""" Prunes heads of the model.
heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
"""
for layer, heads in heads_to_prune.items():
self.h[layer].attn.prune_heads(heads)
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
use_cache=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
**kwargs,
):
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
output_attentions = (
output_attentions if output_attentions is not None else self.config.output_attentions
)
output_hidden_states = (
output_hidden_states
if output_hidden_states is not None
else self.config.output_hidden_states
)
use_cache = use_cache if use_cache is not None else self.config.use_cache
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
if input_ids is not None and inputs_embeds is not None:
raise ValueError(
"You cannot specify both input_ids and inputs_embeds at the same time"
)
elif input_ids is not None:
input_shape = input_ids.size()
input_ids = input_ids.view(-1, input_shape[-1])
batch_size = input_ids.shape[0]
elif inputs_embeds is not None:
input_shape = inputs_embeds.size()[:-1]
batch_size = inputs_embeds.shape[0]
else:
raise ValueError("You have to specify either input_ids or inputs_embeds")
if token_type_ids is not None:
token_type_ids = token_type_ids.view(-1, input_shape[-1])
if position_ids is not None:
position_ids = position_ids.view(-1, input_shape[-1])
if past_key_values is None:
past_length = 0
past_key_values = [None] * len(self.h)
else:
past_length = past_key_values[0][0].size(-2)
if position_ids is None:
device = input_ids.device if input_ids is not None else inputs_embeds.device
position_ids = torch.arange(
past_length, input_shape[-1] + past_length, dtype=torch.long, device=device
)
position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])
# Attention mask.
if attention_mask is not None:
assert batch_size > 0, "batch_size has to be defined and > 0"
attention_mask = attention_mask.view(batch_size, -1)
# We create a 3D attention mask from a 2D tensor mask.
# Sizes are [batch_size, 1, 1, to_seq_length]
# So we can broadcast to [batch_size, num_heads, from_seq_length, to_seq_length]
# this attention mask is more simple than the triangular masking of causal attention
# used in OpenAI GPT, we just need to prepare the broadcast dimension here.
attention_mask = attention_mask.unsqueeze(1).unsqueeze(2)
# Since attention_mask is 1.0 for positions we want to attend and 0.0 for
# masked positions, this operation will create a tensor which is 0.0 for
# positions we want to attend and -10000.0 for masked positions.
# Since we are adding it to the raw scores before the softmax, this is
# effectively the same as removing these entirely.
attention_mask = attention_mask.to(
dtype=next(self.parameters()).dtype
) # fp16 compatibility
attention_mask = (1.0 - attention_mask) * -10000.0
# Prepare head mask if needed
# 1.0 in head_mask indicate we keep the head
# attention_probs has shape bsz x n_heads x N x N
# head_mask has shape n_layer x batch x n_heads x N x N
head_mask = self.get_head_mask(head_mask, self.config.n_layer)
if self.config.is_decoder and encoder_hidden_states is not None:
encoder_batch_size, encoder_sequence_length, _ = encoder_hidden_states.size()
encoder_hidden_shape = (encoder_batch_size, encoder_sequence_length)
if encoder_attention_mask is None:
encoder_attention_mask = torch.ones(encoder_hidden_shape)
if inputs_embeds is None:
inputs_embeds = self.wte(input_ids)
position_embeds = self.wpe(position_ids)
if token_type_ids is not None:
token_type_embeds = self.wte(token_type_ids)
else:
token_type_embeds = 0
hidden_states = inputs_embeds + position_embeds + token_type_embeds
hidden_states = self.drop(hidden_states)
output_shape = input_shape + (hidden_states.size(-1),)
presents = () if use_cache else None
all_attentions = () if output_attentions else None
all_hidden_states = () if output_hidden_states else None
for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
if output_hidden_states:
all_hidden_states = all_hidden_states + (hidden_states.view(*output_shape),)
outputs = block(
hidden_states,
layer_past=layer_past,
attention_mask=attention_mask,
head_mask=head_mask[i],
use_cache=use_cache,
output_attentions=output_attentions,
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
)
hidden_states, present = outputs[:2]
if use_cache is True:
presents = presents + (present,)
if output_attentions:
all_attentions = all_attentions + (outputs[2],)
hidden_states = self.ln_f(hidden_states)
hidden_states = hidden_states.view(*output_shape)
# Add last hidden state
if output_hidden_states:
all_hidden_states = all_hidden_states + (hidden_states,)
if not return_dict:
return tuple(
v
for v in [hidden_states, presents, all_hidden_states, all_attentions]
if v is not None
)
return BaseModelOutputWithPast(
last_hidden_state=hidden_states,
past_key_values=presents,
hidden_states=all_hidden_states,
attentions=all_attentions,
)
class GPT2LMHeadModel(GPT2PreTrainedModel):
authorized_missing_keys = [r"h\.\d+\.attn\.masked_bias", r"lm_head\.weight"]
def __init__(self, config):
super().__init__(config)
self.transformer = GPT2Model(config)
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
self.init_weights()
def get_output_embeddings(self):
return self.lm_head
def prepare_inputs_for_generation(self, input_ids, past, **kwargs):
# only last token for inputs_ids if past is defined in kwargs
if past:
input_ids = input_ids[:, -1].unsqueeze(-1)
return {"input_ids": input_ids, "past_key_values": past, "use_cache": kwargs["use_cache"]}
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
labels=None,
use_cache=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
**kwargs,
):
r"""
labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`, defaults to :obj:`None`):
Labels for language modeling.
Note that the labels **are shifted** inside the model, i.e. you can set ``labels = input_ids``
Indices are selected in ``[-100, 0, ..., config.vocab_size]``
All labels set to ``-100`` are ignored (masked), the loss is only
computed for labels in ``[0, ..., config.vocab_size]``
"""
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
transformer_outputs = self.transformer(
input_ids,
past_key_values=past_key_values,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
position_ids=position_ids,
head_mask=head_mask,
inputs_embeds=inputs_embeds,
use_cache=use_cache,
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
output_attentions=output_attentions,
output_hidden_states=output_hidden_states,
return_dict=return_dict,
)
hidden_states = transformer_outputs[0]
lm_logits = self.lm_head(hidden_states)
loss = None
if labels is not None:
# Shift so that tokens < n predict n
shift_logits = lm_logits[..., :-1, :].contiguous()
shift_labels = labels[..., 1:].contiguous()
# Flatten the tokens
loss_fct = CrossEntropyLoss()
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
if not return_dict:
output = (lm_logits,) + transformer_outputs[1:]
return ((loss,) + output) if loss is not None else output
return CausalLMOutputWithPast(
loss=loss,
logits=lm_logits,
past_key_values=transformer_outputs.past_key_values,
hidden_states=transformer_outputs.hidden_states,
attentions=transformer_outputs.attentions,
)
class GPT2DoubleHeadsModel(GPT2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
config.num_labels = 1
self.transformer = GPT2Model(config)
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
self.multiple_choice_head = SequenceSummary(config)
self.init_weights()
def get_output_embeddings(self):
return self.lm_head
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
mc_token_ids=None,
labels=None,
mc_labels=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
**kwargs,
):
r"""
mc_token_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
Index of the classification token in each input sequence.
Selected in the range ``[0, input_ids.size(-1) - 1[``.
labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`, defaults to :obj:`None`)
Labels for language modeling.
Note that the labels **are shifted** inside the model, i.e. you can set ``labels = input_ids``
Indices are selected in ``[-1, 0, ..., config.vocab_size]``
All labels set to ``-100`` are ignored (masked), the loss is only
computed for labels in ``[0, ..., config.vocab_size]``
mc_labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size)`, `optional`, defaults to :obj:`None`)
Labels for computing the multiple choice classification loss.
Indices should be in ``[0, ..., num_choices]`` where `num_choices` is the size of the second dimension
of the input tensors. (see `input_ids` above)
kwargs (:obj:`Dict[str, any]`, optional, defaults to `{}`):
Used to hide legacy arguments that have been deprecated.
Return:
Examples::
>>> import torch
>>> from transformers import GPT2Tokenizer, GPT2DoubleHeadsModel
>>> tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
>>> model = GPT2DoubleHeadsModel.from_pretrained('gpt2, return_dict=True)
>>> # Add a [CLS] to the vocabulary (we should train it also!)
>>> num_added_tokens = tokenizer.add_special_tokens({'cls_token': '[CLS]'})
>>> embedding_layer = model.resize_token_embeddings(len(tokenizer)) # Update the model embeddings with the new vocabulary size
>>> choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
>>> encoded_choices = [tokenizer.encode(s) for s in choices]
>>> cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]
>>> input_ids = torch.tensor(encoded_choices).unsqueeze(0) # Batch size: 1, number of choices: 2
>>> mc_token_ids = torch.tensor([cls_token_location]) # Batch size: 1
>>> outputs = model(input_ids, mc_token_ids=mc_token_ids)
>>> lm_logits = outputs.lm_logits
>>> mc_logits = outputs.mc_logits
"""
if "lm_labels" in kwargs:
warnings.warn(
"The `lm_labels` argument is deprecated and will be removed in a future version, use `labels` instead.",
FutureWarning,
)
labels = kwargs.pop("lm_labels")
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
transformer_outputs = self.transformer(
input_ids,
past_key_values=past_key_values,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
position_ids=position_ids,
head_mask=head_mask,
inputs_embeds=inputs_embeds,
use_cache=use_cache,
output_attentions=output_attentions,
output_hidden_states=output_hidden_states,
return_dict=return_dict,
)
hidden_states = transformer_outputs[0]
lm_logits = self.lm_head(hidden_states)
mc_logits = self.multiple_choice_head(hidden_states, mc_token_ids).squeeze(-1)
mc_loss = None
if mc_labels is not None:
loss_fct = CrossEntropyLoss()
mc_loss = loss_fct(mc_logits.view(-1, mc_logits.size(-1)), mc_labels.view(-1))
lm_loss = None
if labels is not None:
shift_logits = lm_logits[..., :-1, :].contiguous()
shift_labels = labels[..., 1:].contiguous()
loss_fct = CrossEntropyLoss()
lm_loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
if not return_dict:
output = (lm_logits, mc_logits) + transformer_outputs[1:]
if mc_loss is not None:
output = (mc_loss,) + output
return ((lm_loss,) + output) if lm_loss is not None else output
return GPT2DoubleHeadsModelOutput(
lm_loss=lm_loss,
mc_loss=mc_loss,
lm_logits=lm_logits,
mc_logits=mc_logits,
past_key_values=transformer_outputs.past_key_values,
hidden_states=transformer_outputs.hidden_states,
attentions=transformer_outputs.attentions,
)
| craftassist-master | python/base_agent/ttad/back_translation/modeling_gpt2.py |
craftassist-master | python/base_agent/ttad/back_translation/__init__.py |
|
import torch
import argparse
import random
class Tree2TextDataset(torch.utils.data.Dataset):
"""Dataset class extending pytorch Dataset definition.
"""
def __init__(self, prog, chat):
"""Initialize paired data, tokenizer, dictionaries.
"""
assert len(prog) == len(chat)
self.prog = prog
self.chat = chat
def __len__(self):
"""Returns total number of samples.
"""
return len(self.prog)
def __getitem__(self, index):
"""Generates one sample of data.
"""
X = self.prog[index]
Y = self.chat[index]
return (X, Y)
def load_paired_dataset(data_dir, prefix):
chat_data = []
prog_data = []
with open(data_dir + "{}.chat".format(prefix)) as fd:
chat_data = fd.read().splitlines()
with open(data_dir + "{}.prog".format(prefix)) as fd:
prog_data = fd.read().splitlines()
return (prog_data, chat_data)
def collate(tree, text, tree_tokenizer, text_tokenizer):
"""Pad and tensorize data.
"""
# Longest tree
max_x_len = max([len(x) for x in tree])
x_mask = [[1] * len(x) + [0] * (max_x_len - len(x)) for x in tree]
batch_x_with_pad = [x + [tree_tokenizer.pad_token_id] * (max_x_len - len(x)) for x in tree]
# Longest text command
max_y_len = max([len(y) for y in text])
y_mask = [[1] * len(y) + [0] * (max_y_len - len(y)) for y in text]
batch_y_with_pad = [y + [text_tokenizer.pad_token_id] * (max_y_len - len(y)) for y in text]
# Convert padded data to tensors
x = batch_x_with_pad
x_mask = x_mask
y = batch_y_with_pad
y_mask = y_mask
return (x, x_mask, y, y_mask)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="/checkpoint/rebeccaqian/datasets/fairseq/07_25/",
type=str,
help="train/valid/test data",
)
parser.add_argument(
"--prefix", default="train", type=str, help="partition to load eg. train, valid"
)
# Load dataset and print some meta stats.
args = parser.parse_args()
train_prog_data, train_chat_data = load_paired_dataset(args.data_dir, args.prefix)
train_dataset = Tree2TextDataset(train_prog_data, train_chat_data)
length = train_dataset.__len__()
print("Size of data: {}".format(length))
# Randomly generate some samples.
for i in range(5):
rand = random.uniform(0, 1)
idx = round(rand * length)
example = train_dataset.__getitem__(idx)
print("Example:\n X: {}\n Y: {}".format(example[0], example[1]))
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/back_translation/dataset.py |
from transformers.modeling_bert import BertModel
import torch.nn as nn
class TransformerEncoder(nn.Module):
"""Transformer Encoder class.
"""
def __init__(self, config, tokenizer):
super(TransformerEncoder, self).__init__()
# Initializes transformer architecture with BERT structure
self.bert = BertModel(config)
def forward(self, input_ids, attention_mask):
bert_model = self.bert(input_ids=input_ids, attention_mask=attention_mask)
hidden_out = bert_model[0]
return hidden_out
class EncoderDecoder(nn.Module):
"""Encoder decoder architecture used for back translation.
"""
def __init__(self, encoder, decoder):
super(EncoderDecoder, self).__init__()
self.encoder = encoder
self.decoder = decoder
def forward(self, x, x_mask, y, y_mask, labels, use_lm=False):
hidden_out = self.encoder(input_ids=x, attention_mask=x_mask)[0]
dec_out = self.decoder(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=hidden_out,
encoder_attention_mask=x_mask,
use_lm=use_lm,
labels=labels,
)
return dec_out
def step(self, x_reps, x_mask, y, y_mask, use_lm=False):
"""No loss, used during inference.
"""
dec_out = self.decoder(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
use_lm=use_lm,
)
return dec_out
| craftassist-master | python/base_agent/ttad/back_translation/transformer.py |
from transformers import AutoConfig, GPT2Tokenizer, BertTokenizer
from os.path import isdir
from dataset import *
from transformer import *
from torch.utils.data import DataLoader
from datetime import date
import argparse
import os
import sys
from time import time
from huggingface_modeling_gpt2 import *
import logging
import logging.handlers
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "../..")
sys.path.append(BASE_AGENT_ROOT)
# make sure GPT2 appends EOS in begin and end
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
outputs = [self.bos_token_id] + token_ids_0 + [self.eos_token_id]
return outputs
def compute_accuracy(outputs, y, tokenizer):
"""Compute model accuracy given predictions and targets. Used in validation.
"""
# Do not include BOS token
target_tokens = y[:, 1:]
predicted_tokens = outputs.max(dim=-1)[1][:, :-1]
acc = (predicted_tokens == target_tokens).sum(dim=1) == target_tokens.shape[-1]
return acc
def validate(model, dataset, text_tokenizer, tree_tokenizer, args):
valid_loader = torch.utils.data.DataLoader(dataset=dataset, batch_size=10, shuffle=False)
tot_acc = 0.0
tot_loss = 0.0
steps = 0
with torch.no_grad():
for i, batch in enumerate(valid_loader):
trees, text = batch
text_idx_ls = [
text_tokenizer.encode(cmd.strip(), add_special_tokens=True) for cmd in text
]
tree_idx_ls = [tree_tokenizer.encode(tree, add_special_tokens=True) for tree in trees]
x, x_mask, y, y_mask = collate(
tree_idx_ls, text_idx_ls, tree_tokenizer, text_tokenizer
)
y_copy = y.copy()
y_mask_copy = y_mask.copy()
labels = [
[-100 if mask == 0 else token for mask, token in mask_and_tokens]
for mask_and_tokens in [
zip(mask, label) for mask, label in zip(y_mask_copy, y_copy)
]
]
labels = torch.tensor(labels)
x = torch.tensor(x)
x_mask = torch.tensor(x_mask)
y = torch.tensor(y)
y_mask = torch.tensor(y_mask)
out = model(x, x_mask, y, y_mask, labels, args.use_lm)
loss, predictions = out[:2]
# Taking the first row in the batch as logging example
predicted_example = predictions.max(dim=-1)[1][:, :-1]
predicted_sentence = text_tokenizer.decode(predicted_example[0])
logging.info(
"sample predictions:\n X: {} \n Y: {} \n predicted: {}".format(
trees[0], text[0], predicted_sentence
)
)
print(
"sample predictions:\n X: {} \n Y: {} \n predicted: {}".format(
trees[0], text[0], predicted_sentence
)
)
lm_acc = compute_accuracy(predictions, y, text_tokenizer)
acc = lm_acc.sum().item() / lm_acc.shape[0]
tot_acc += acc
tot_loss += loss.item()
steps += 1
logging.info("Valid accuracy: {} Loss: {}".format(tot_acc / steps, tot_loss / steps))
print("Valid accuracy: {} Loss: {}".format(tot_acc / steps, tot_loss / steps))
def generate_model_name(args):
# unix time in seconds, used as a unique identifier
time_now = round(time())
name = ""
args_keys = {
"batch_size": "batch",
"lr": "lr",
"train_decoder": "finetune",
"encoder_size": "size",
}
for k, v in vars(args).items():
if k in args_keys:
name += "{param}={value}|".format(param=args_keys[k], value=v)
# In case we want additional identification for the model, eg. test run
name += "{time}|".format(time=time_now)
name += args.model_identifier
return name
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="/checkpoint/rebeccaqian/datasets/backtranslation/09_11/mixed_spans/",
type=str,
help="train/valid/test data",
)
parser.add_argument(
"--output_dir",
default="/checkpoint/rebeccaqian/backtranslation/{}/".format(str(date.today())),
type=str,
help="directory to save checkpoint models",
)
parser.add_argument(
"--train_decoder",
default=False,
action="store_true",
help="whether to finetune the decoder",
)
parser.add_argument(
"--model_identifier",
default="ttad_bert2gpt2",
type=str,
help="optional identifier string used in filenames",
)
parser.add_argument("--encoder_size", default="medium", type=str, help="size of encoder")
parser.add_argument(
"--num_hidden_layers",
default=12,
type=int,
help="number of hidden layers in BERT Transformer",
)
parser.add_argument(
"--hidden_dropout_prob",
default=0.1,
type=int,
help="dropout probabilitiy for all fully connected encoder layers",
)
parser.add_argument(
"--data_type", default="annotated", type=str, help="name of dataset to load from"
)
parser.add_argument(
"--use_lm", default=False, action="store_true", help="whether to use decoder as lm"
)
parser.add_argument("--lr", default=0.00001, type=float, help="learning rate")
parser.add_argument("--batch_size", default=48, type=int, help="batch size")
parser.add_argument("--num_epochs", default=30, type=int, help="number of epochs")
args = parser.parse_args()
model_identifier = generate_model_name(args)
l_handler = logging.handlers.WatchedFileHandler(
"{}/{}.log".format(args.output_dir, model_identifier)
)
l_format = logging.Formatter(fmt="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S")
l_handler.setFormatter(l_format)
l_root = logging.getLogger()
l_root.setLevel(os.environ.get("LOGLEVEL", "INFO"))
l_root.addHandler(l_handler)
logging.info(args)
print(args)
if args.encoder_size == "large":
encoder_name = "bert-large-uncased"
decoder_name = "gpt2-medium"
else:
encoder_name = "bert-base-uncased"
decoder_name = "gpt2"
if args.use_lm:
config_decoder = AutoConfig.from_pretrained(decoder_name, is_decoder=False)
config_decoder.add_cross_attention = False
else:
config_decoder = AutoConfig.from_pretrained(decoder_name, is_decoder=True)
config_decoder.add_cross_attention = True
config_encoder = AutoConfig.from_pretrained(encoder_name, is_decoder=False)
bert_tokenizer = BertTokenizer.from_pretrained(encoder_name)
# CLS token will work as BOS token
bert_tokenizer.bos_token = bert_tokenizer.cls_token
# SEP token will work as EOS token
bert_tokenizer.eos_token = bert_tokenizer.sep_token
tokenizer = GPT2Tokenizer.from_pretrained(decoder_name)
tokenizer.pad_token = tokenizer.unk_token
GPT2Tokenizer.build_inputs_with_special_tokens = build_inputs_with_special_tokens
enc_model = BertModel(config=config_encoder)
dec_model = GPT2LMHeadModel.from_pretrained(decoder_name, config=config_decoder)
dec_model.config.decoder_start_token_id = tokenizer.bos_token_id
dec_model.config.eos_token_id = tokenizer.eos_token_id
dec_model.resize_token_embeddings(len(tokenizer))
decoder_params = dec_model.named_parameters()
if not args.train_decoder:
# enumerate all decoder params, 244
decoder_params = dec_model.named_parameters()
for name, param in decoder_params:
# train decoder attention weights, 94
if "cross_attn" in name or "crossattention" in name:
param.requires_grad = True
else:
# freeze other layer weights
param.requires_grad = False
train_prog_data, train_chat_data = load_paired_dataset(args.data_dir, "train")
train_dataset = Tree2TextDataset(train_prog_data, train_chat_data)
train_loader = DataLoader(dataset=train_dataset, batch_size=args.batch_size, shuffle=True)
valid_prog_data, valid_chat_data = load_paired_dataset(args.data_dir, "valid")
valid_dataset = Tree2TextDataset(valid_prog_data, valid_chat_data)
encoder_decoder = EncoderDecoder(enc_model, dec_model)
optimizer = torch.optim.Adam(encoder_decoder.parameters(), lr=args.lr)
for epoch in range(args.num_epochs):
logging.info("Epoch: {}".format(epoch))
print("Epoch: {}".format(epoch))
encoder_decoder.train()
for i, batch in enumerate(train_loader):
trees, text = batch
optimizer.zero_grad()
text_idx_ls = [tokenizer.encode(cmd.strip(), add_special_tokens=True) for cmd in text]
tree_idx_ls = [bert_tokenizer.encode(tree, add_special_tokens=True) for tree in trees]
x, x_mask, y, y_mask = collate(tree_idx_ls, text_idx_ls, bert_tokenizer, tokenizer)
y_copy = y.copy()
y_mask_copy = y_mask.copy()
labels = [
[-100 if mask == 0 else token for mask, token in mask_and_tokens]
for mask_and_tokens in [
zip(mask, label) for mask, label in zip(y_mask_copy, y_copy)
]
]
labels = torch.tensor(labels)
y = torch.tensor(y)
y_mask = torch.tensor(y_mask)
x = torch.tensor(x)
x_mask = torch.tensor(x_mask)
outputs = encoder_decoder(x, x_mask, y, y_mask, labels, args.use_lm)
loss, predictions = outputs[:2]
# Taking the first row in the batch as logging example
predicted_example = predictions.max(dim=-1)[1][:, :-1]
predicted_sentence = tokenizer.decode(predicted_example[0])
loss.backward()
optimizer.step()
if i % 20 == 0:
logging.info(
"sample predictions:\n X: {} \n Y: {} \n predicted: {}".format(
trees[0], text[0], predicted_sentence
)
)
print(
"sample predictions:\n X: {} \n Y: {} \n predicted: {}".format(
trees[0], text[0], predicted_sentence
)
)
logging.info("Iteration: {} Loss: {}".format(i, loss))
print("Iteration: {} Loss: {}".format(i, loss))
enc_dirpath = "{}encoder/".format(args.output_dir)
if not isdir(enc_dirpath):
os.mkdir(enc_dirpath)
enc_checkpoint_path = enc_dirpath + "{}(ep=={})/".format(model_identifier, epoch)
if not isdir(enc_checkpoint_path):
os.mkdir(enc_checkpoint_path)
dec_dirpath = "{}decoder/".format(args.output_dir)
if not isdir(dec_dirpath):
os.mkdir(dec_dirpath)
dec_checkpoint_path = dec_dirpath + "{}(ep=={})/".format(model_identifier, epoch)
if not isdir(dec_checkpoint_path):
os.mkdir(dec_checkpoint_path)
enc_model.save_pretrained(enc_checkpoint_path)
dec_model.save_pretrained(dec_checkpoint_path)
# Evaluating model
encoder_decoder.eval()
logging.info("Evaluating model")
validate(encoder_decoder, valid_dataset, tokenizer, bert_tokenizer, args)
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/back_translation/train.py |
# coding=utf-8
# Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""PyTorch OpenAI GPT-2 model."""
import os
import warnings
from dataclasses import dataclass
from typing import List, Optional, Tuple
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from transformers.activations import ACT2FN
from transformers.configuration_gpt2 import GPT2Config
from transformers.file_utils import (
ModelOutput,
add_code_sample_docstrings,
add_start_docstrings,
add_start_docstrings_to_callable,
replace_return_docstrings,
)
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from transformers.modeling_utils import (
Conv1D,
PreTrainedModel,
SequenceSummary,
find_pruneable_heads_and_indices,
prune_conv1d_layer,
)
from transformers.utils import logging
logger = logging.get_logger(__name__)
_CONFIG_FOR_DOC = "GPT2Config"
_TOKENIZER_FOR_DOC = "GPT2Tokenizer"
GPT2_PRETRAINED_MODEL_ARCHIVE_LIST = [
"gpt2",
"gpt2-medium",
"gpt2-large",
"gpt2-xl",
"distilgpt2",
# See all GPT-2 models at https://huggingface.co/models?filter=gpt2
]
def load_tf_weights_in_gpt2(model, config, gpt2_checkpoint_path):
"""Load tf checkpoints in a pytorch model"""
try:
import re
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow model in PyTorch, requires TensorFlow to be installed. Please see "
"https://www.tensorflow.org/install/ for installation instructions."
)
raise
tf_path = os.path.abspath(gpt2_checkpoint_path)
logger.info("Converting TensorFlow checkpoint from {}".format(tf_path))
# Load weights from TF model
init_vars = tf.train.list_variables(tf_path)
names = []
arrays = []
for name, shape in init_vars:
logger.info("Loading TF weight {} with shape {}".format(name, shape))
array = tf.train.load_variable(tf_path, name)
names.append(name)
arrays.append(array.squeeze())
for name, array in zip(names, arrays):
name = name[6:] # skip "model/"
name = name.split("/")
pointer = model
for m_name in name:
if re.fullmatch(r"[A-Za-z]+\d+", m_name):
scope_names = re.split(r"(\d+)", m_name)
else:
scope_names = [m_name]
if scope_names[0] == "w" or scope_names[0] == "g":
pointer = getattr(pointer, "weight")
elif scope_names[0] == "b":
pointer = getattr(pointer, "bias")
elif scope_names[0] == "wpe" or scope_names[0] == "wte":
pointer = getattr(pointer, scope_names[0])
pointer = getattr(pointer, "weight")
else:
pointer = getattr(pointer, scope_names[0])
if len(scope_names) >= 2:
num = int(scope_names[1])
pointer = pointer[num]
try:
assert (
pointer.shape == array.shape
), f"Pointer shape {pointer.shape} and array shape {array.shape} mismatched"
except AssertionError as e:
e.args += (pointer.shape, array.shape)
raise
logger.info("Initialize PyTorch weight {}".format(name))
pointer.data = torch.from_numpy(array)
return model
class Attention(nn.Module):
def __init__(self, nx, n_ctx, config, scale=False, is_cross_attention=False):
super().__init__()
n_state = nx # in Attention: n_state=768 (nx=n_embd)
# [switch nx => n_state from Block to Attention to keep identical to TF implem]
assert n_state % config.n_head == 0
self.register_buffer(
"bias",
torch.tril(torch.ones((n_ctx, n_ctx), dtype=torch.uint8)).view(1, 1, n_ctx, n_ctx),
)
self.register_buffer("masked_bias", torch.tensor(-1e4))
self.n_head = config.n_head
self.split_size = n_state
self.scale = scale
self.is_cross_attention = is_cross_attention
if self.is_cross_attention:
self.c_attn = Conv1D(2 * n_state, nx)
self.q_attn = Conv1D(n_state, nx)
else:
self.c_attn = Conv1D(3 * n_state, nx)
self.c_proj = Conv1D(n_state, nx)
self.attn_dropout = nn.Dropout(config.attn_pdrop)
self.resid_dropout = nn.Dropout(config.resid_pdrop)
self.pruned_heads = set()
def prune_heads(self, heads):
if len(heads) == 0:
return
heads, index = find_pruneable_heads_and_indices(
heads, self.n_head, self.split_size // self.n_head, self.pruned_heads
)
index_attn = torch.cat([index, index + self.split_size, index + (2 * self.split_size)])
# Prune conv1d layers
self.c_attn = prune_conv1d_layer(self.c_attn, index_attn, dim=1)
self.c_proj = prune_conv1d_layer(self.c_proj, index, dim=0)
# Update hyper params
self.split_size = (self.split_size // self.n_head) * (self.n_head - len(heads))
self.n_head = self.n_head - len(heads)
self.pruned_heads = self.pruned_heads.union(heads)
def _attn(
self,
q,
k,
v,
attention_mask=None,
head_mask=None,
output_attentions=False,
decoder_input_length=None,
):
w = torch.matmul(q, k)
if self.scale:
w = w / (float(v.size(-1)) ** 0.5)
nd, ns = w.size(-2), w.size(-1)
if not self.is_cross_attention:
if decoder_input_length is not None:
# if only "normal" attention layer implements causal mask
x_len = attention_mask.shape[-1] - decoder_input_length
y_len = decoder_input_length
x_mask = torch.ones(y_len, x_len, dtype=torch.uint8)
y_mask = torch.tril(torch.ones(y_len, y_len, dtype=torch.uint8))
mask = torch.cat((x_mask, y_mask), 1)
# pad remainder with zeros
mask = torch.cat((mask, torch.zeros([x_len, x_len + y_len])), 0)
w = torch.where(mask.bool(), w, self.masked_bias)
else:
mask = self.bias[:, :, ns - nd : ns, :ns]
w = torch.where(mask.bool(), w, self.masked_bias.to(w.dtype))
if attention_mask is not None:
# Apply the attention mask
w = w + attention_mask
w = nn.Softmax(dim=-1)(w)
w = self.attn_dropout(w)
# Mask heads if we want to
if head_mask is not None:
w = w * head_mask
outputs = [torch.matmul(w, v)]
if output_attentions:
outputs.append(w)
return outputs
def merge_heads(self, x):
x = x.permute(0, 2, 1, 3).contiguous()
new_x_shape = x.size()[:-2] + (x.size(-2) * x.size(-1),)
return x.view(*new_x_shape) # in Tensorflow implem: fct merge_states
def split_heads(self, x, k=False):
new_x_shape = x.size()[:-1] + (self.n_head, x.size(-1) // self.n_head)
x = x.view(*new_x_shape) # in Tensorflow implem: fct split_states
if k:
return x.permute(0, 2, 3, 1) # (batch, head, head_features, seq_length)
else:
return x.permute(0, 2, 1, 3) # (batch, head, seq_length, head_features)
def forward(
self,
hidden_states,
layer_past=None,
attention_mask=None,
head_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
use_cache=False,
output_attentions=False,
decoder_input_length=None,
):
if encoder_hidden_states is not None:
assert hasattr(
self, "q_attn"
), "If class is used as cross attention, the weights `q_attn` have to be defined. Please make sure to instantiate class with `Attention(..., is_cross_attention=True)`."
query = self.q_attn(hidden_states)
key, value = self.c_attn(encoder_hidden_states).split(self.split_size, dim=2)
attention_mask = encoder_attention_mask
else:
query, key, value = self.c_attn(hidden_states).split(self.split_size, dim=2)
query = self.split_heads(query)
key = self.split_heads(key, k=True)
value = self.split_heads(value)
if layer_past is not None:
past_key, past_value = (
layer_past[0].transpose(-2, -1),
layer_past[1],
) # transpose back cf below
key = torch.cat((past_key, key), dim=-1)
value = torch.cat((past_value, value), dim=-2)
if use_cache is True:
present = torch.stack(
(key.transpose(-2, -1), value)
) # transpose to have same shapes for stacking
else:
present = (None,)
attn_outputs = self._attn(
query, key, value, attention_mask, head_mask, output_attentions, decoder_input_length
)
a = attn_outputs[0]
a = self.merge_heads(a)
a = self.c_proj(a)
a = self.resid_dropout(a)
outputs = [a, present] + attn_outputs[1:]
return outputs # a, present, (attentions)
class MLP(nn.Module):
def __init__(self, n_state, config): # in MLP: n_state=3072 (4 * n_embd)
super().__init__()
nx = config.n_embd
self.c_fc = Conv1D(n_state, nx)
self.c_proj = Conv1D(nx, n_state)
self.act = ACT2FN[config.activation_function]
self.dropout = nn.Dropout(config.resid_pdrop)
def forward(self, x):
h = self.act(self.c_fc(x))
h2 = self.c_proj(h)
return self.dropout(h2)
class Block(nn.Module):
def __init__(self, n_ctx, config, scale=False):
super().__init__()
hidden_size = config.n_embd
inner_dim = config.n_inner if config.n_inner is not None else 4 * hidden_size
self.ln_1 = nn.LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
self.attn = Attention(hidden_size, n_ctx, config, scale)
self.ln_2 = nn.LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
if config.add_cross_attention:
self.crossattention = Attention(
hidden_size, n_ctx, config, scale, is_cross_attention=True
)
self.ln_cross_attn = nn.LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
self.mlp = MLP(inner_dim, config)
def forward(
self,
hidden_states,
layer_past=None,
attention_mask=None,
head_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
use_cache=False,
output_attentions=False,
decoder_input_length=None,
):
attn_outputs = self.attn(
self.ln_1(hidden_states),
layer_past=layer_past,
attention_mask=attention_mask,
head_mask=head_mask,
use_cache=use_cache,
output_attentions=output_attentions,
decoder_input_length=decoder_input_length,
)
attn_output = attn_outputs[0] # output_attn: a, present, (attentions)
outputs = attn_outputs[1:]
# residual connection
hidden_states = attn_output + hidden_states
if encoder_hidden_states is not None:
# add one self-attention block for cross-attention
assert hasattr(
self, "crossattention"
), f"If `encoder_hidden_states` are passed, {self} has to be instantiated with cross-attention layers by setting `config.add_cross_attention=True`"
cross_attn_outputs = self.crossattention(
self.ln_cross_attn(hidden_states),
attention_mask=attention_mask,
head_mask=head_mask,
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
output_attentions=output_attentions,
)
attn_output = cross_attn_outputs[0]
# residual connection
hidden_states = hidden_states + attn_output
outputs = (
outputs + cross_attn_outputs[1:]
) # add cross attentions if we output attention weights
feed_forward_hidden_states = self.mlp(self.ln_2(hidden_states))
# residual connection
hidden_states = hidden_states + feed_forward_hidden_states
outputs = [hidden_states] + outputs
return outputs # hidden_states, present, (cross_attentions, attentions)
class GPT2PreTrainedModel(PreTrainedModel):
"""An abstract class to handle weights initialization and
a simple interface for downloading and loading pretrained models.
"""
config_class = GPT2Config
load_tf_weights = load_tf_weights_in_gpt2
base_model_prefix = "transformer"
def __init__(self, *inputs, **kwargs):
super().__init__(*inputs, **kwargs)
def _init_weights(self, module):
"""Initialize the weights."""
if isinstance(module, (nn.Linear, nn.Embedding, Conv1D)):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
if isinstance(module, (nn.Linear, Conv1D)) and module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.LayerNorm):
module.bias.data.zero_()
module.weight.data.fill_(1.0)
@dataclass
class GPT2DoubleHeadsModelOutput(ModelOutput):
"""
Base class for outputs of models predicting if two sentences are consecutive or not.
Args:
loss (:obj:`torch.FloatTensor` of shape :obj:`(1,)`, `optional`, returned when ``labels`` is provided):
Language modeling loss.
mc_loss (:obj:`torch.FloatTensor` of shape :obj:`(1,)`, `optional`, returned when :obj:`mc_labels` is provided):
Multiple choice classification loss.
logits (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, num_choices, sequence_length, config.vocab_size)`):
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
mc_logits (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, num_choices)`):
Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).
past_key_values (:obj:`List[torch.FloatTensor]`, `optional`, returned when ``use_cache=True`` is passed or when ``config.use_cache=True``):
List of :obj:`torch.FloatTensor` of length :obj:`config.n_layers`, with each tensor of shape
:obj:`(2, batch_size, num_heads, sequence_length, embed_size_per_head)`).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
``past_key_values`` input) to speed up sequential decoding.
hidden_states (:obj:`tuple(torch.FloatTensor)`, `optional`, returned when ``output_hidden_states=True`` is passed or when ``config.output_hidden_states=True``):
Tuple of :obj:`torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer)
of shape :obj:`(batch_size, sequence_length, hidden_size)`.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
attentions (:obj:`tuple(torch.FloatTensor)`, `optional`, returned when ``output_attentions=True`` is passed or when ``config.output_attentions=True``):
Tuple of :obj:`torch.FloatTensor` (one for each layer) of shape
:obj:`(batch_size, num_heads, sequence_length, sequence_length)`.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.
"""
loss: Optional[torch.FloatTensor] = None
mc_loss: Optional[torch.FloatTensor] = None
logits: torch.FloatTensor = None
mc_logits: torch.FloatTensor = None
past_key_values: Optional[List[torch.FloatTensor]] = None
hidden_states: Optional[Tuple[torch.FloatTensor]] = None
attentions: Optional[Tuple[torch.FloatTensor]] = None
GPT2_START_DOCSTRING = r"""
This model is a PyTorch `torch.nn.Module <https://pytorch.org/docs/stable/nn.html#torch.nn.Module>`_ sub-class.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general
usage and behavior.
Parameters:
config (:class:`~transformers.GPT2Config`): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the configuration.
Check out the :meth:`~transformers.PreTrainedModel.from_pretrained` method to load the model weights.
"""
GPT2_INPUTS_DOCSTRING = r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, input_ids_length)`):
:obj:`input_ids_length` = ``sequence_length`` if ``past_key_values`` is ``None`` else
``past_key_values[0].shape[-2]`` (``sequence_length`` of input past key value states).
Indices of input sequence tokens in the vocabulary.
If ``past_key_values`` is used, only ``input_ids`` that do not have their past calculated should be passed
as ``input_ids``.
Indices can be obtained using :class:`transformers.GPT2Tokenizer`.
See :func:`transformers.PreTrainedTokenizer.encode` and
:func:`transformers.PreTrainedTokenizer.__call__` for details.
`What are input IDs? <../glossary.html#input-ids>`__
past_key_values (:obj:`List[torch.FloatTensor]` of length :obj:`config.n_layers`):
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model
(see ``past_key_values`` output below). Can be used to speed up sequential decoding.
The ``input_ids`` which have their past given to this model should not be passed as ``input_ids`` as they have already been computed.
attention_mask (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
Mask to avoid performing attention on padding token indices.
Mask values selected in ``[0, 1]``:
``1`` for tokens that are NOT MASKED, ``0`` for MASKED tokens.
`What are attention masks? <../glossary.html#attention-mask>`__
token_type_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, input_ids_length)`, `optional`):
`input_ids_length` = `sequence_length if `past` is None else 1
Segment token indices to indicate first and second portions of the inputs.
Indices are selected in ``[0, 1]``: ``0`` corresponds to a `sentence A` token, ``1``
corresponds to a `sentence B` token
`What are token type IDs? <../glossary.html#token-type-ids>`_
position_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
Indices of positions of each input sequence tokens in the position embeddings.
Selected in the range ``[0, config.max_position_embeddings - 1]``.
`What are position IDs? <../glossary.html#position-ids>`_
head_mask (:obj:`torch.FloatTensor` of shape :obj:`(num_heads,)` or :obj:`(num_layers, num_heads)`, `optional`):
Mask to nullify selected heads of the self-attention modules.
Mask values selected in ``[0, 1]``:
:obj:`1` indicates the head is **not masked**, :obj:`0` indicates the head is **masked**.
inputs_embeds (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length, hidden_size)`, `optional`):
This is useful if you want more control over how to convert `input_ids` indices into associated vectors
than the model's internal embedding lookup matrix.
If ``past_key_values`` is used, optionally only the last `inputs_embeds` have to be input (see ``past_key_values``).
use_cache (:obj:`bool`):
If `use_cache` is True, ``past_key_values`` key value states are returned and can be used to speed up decoding (see ``past_key_values``). Defaults to `True`.
output_attentions (:obj:`bool`, `optional`):
If set to ``True``, the attentions tensors of all attention layers are returned. See ``attentions`` under returned tensors for more detail.
output_hidden_states (:obj:`bool`, `optional`):
If set to ``True``, the hidden states of all layers are returned. See ``hidden_states`` under returned tensors for more detail.
return_dict (:obj:`bool`, `optional`):
If set to ``True``, the model will return a :class:`~transformers.file_utils.ModelOutput` instead of a
plain tuple.
"""
@add_start_docstrings(
"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top.",
GPT2_START_DOCSTRING,
)
class GPT2Model(GPT2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.wte = nn.Embedding(config.vocab_size, config.n_embd)
self.wpe = nn.Embedding(config.n_positions, config.n_embd)
self.drop = nn.Dropout(config.embd_pdrop)
self.h = nn.ModuleList(
[Block(config.n_ctx, config, scale=True) for _ in range(config.n_layer)]
)
self.ln_f = nn.LayerNorm(config.n_embd, eps=config.layer_norm_epsilon)
self.init_weights()
def get_input_embeddings(self):
return self.wte
def set_input_embeddings(self, new_embeddings):
self.wte = new_embeddings
def _prune_heads(self, heads_to_prune):
"""Prunes heads of the model.
heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
"""
for layer, heads in heads_to_prune.items():
self.h[layer].attn.prune_heads(heads)
@add_start_docstrings_to_callable(GPT2_INPUTS_DOCSTRING)
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
checkpoint="gpt2",
output_type=BaseModelOutputWithPast,
config_class=_CONFIG_FOR_DOC,
)
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
use_lm=False,
**kwargs,
):
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
output_attentions = (
output_attentions if output_attentions is not None else self.config.output_attentions
)
output_hidden_states = (
output_hidden_states
if output_hidden_states is not None
else self.config.output_hidden_states
)
use_cache = use_cache if use_cache is not None else self.config.use_cache
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
if input_ids is not None and inputs_embeds is not None:
raise ValueError(
"You cannot specify both input_ids and inputs_embeds at the same time"
)
elif input_ids is not None:
input_shape = input_ids.size()
input_ids = input_ids.view(-1, input_shape[-1])
batch_size = input_ids.shape[0]
elif inputs_embeds is not None:
input_shape = inputs_embeds.size()[:-1]
batch_size = inputs_embeds.shape[0]
else:
raise ValueError("You have to specify either input_ids or inputs_embeds")
if token_type_ids is not None:
token_type_ids = token_type_ids.view(-1, input_shape[-1])
if position_ids is not None:
position_ids = position_ids.view(-1, input_shape[-1])
if past_key_values is None:
past_length = 0
past_key_values = [None] * len(self.h)
else:
past_length = past_key_values[0][0].size(-2)
if position_ids is None:
device = input_ids.device if input_ids is not None else inputs_embeds.device
position_ids = torch.arange(
past_length, input_shape[-1] + past_length, dtype=torch.long, device=device
)
position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])
# Attention mask.
if attention_mask is not None:
assert batch_size > 0, "batch_size has to be defined and > 0"
attention_mask = attention_mask.view(batch_size, -1)
# We create a 3D attention mask from a 2D tensor mask.
# Sizes are [batch_size, 1, 1, to_seq_length]
# So we can broadcast to [batch_size, num_heads, from_seq_length, to_seq_length]
# this attention mask is more simple than the triangular masking of causal attention
# used in OpenAI GPT, we just need to prepare the broadcast dimension here.
attention_mask = attention_mask[:, None, None, :]
# Since attention_mask is 1.0 for positions we want to attend and 0.0 for
# masked positions, this operation will create a tensor which is 0.0 for
# positions we want to attend and -10000.0 for masked positions.
# Since we are adding it to the raw scores before the softmax, this is
# effectively the same as removing these entirely.
attention_mask = attention_mask.to(
dtype=next(self.parameters()).dtype
) # fp16 compatibility
attention_mask = (1.0 - attention_mask) * -10000.0
# If a 2D ou 3D attention mask is provided for the cross-attention
# we need to make broadcastabe to [batch_size, num_heads, seq_length, seq_length]
if self.config.add_cross_attention and encoder_hidden_states is not None:
encoder_batch_size, encoder_sequence_length, _ = encoder_hidden_states.size()
encoder_hidden_shape = (encoder_batch_size, encoder_sequence_length)
if encoder_attention_mask is None:
encoder_attention_mask = torch.ones(encoder_hidden_shape, device=device)
encoder_attention_mask = self.invert_attention_mask(encoder_attention_mask)
elif use_lm:
encoder_attention_mask = self.invert_attention_mask(encoder_attention_mask)
else:
encoder_attention_mask = None
# Prepare head mask if needed
# 1.0 in head_mask indicate we keep the head
# attention_probs has shape bsz x n_heads x N x N
# head_mask has shape n_layer x batch x n_heads x N x N
head_mask = self.get_head_mask(head_mask, self.config.n_layer)
if inputs_embeds is None:
inputs_embeds = self.wte(input_ids)
position_embeds = self.wpe(position_ids)
if token_type_ids is not None:
token_type_embeds = self.wte(token_type_ids)
else:
token_type_embeds = 0
hidden_states = inputs_embeds + position_embeds + token_type_embeds
hidden_states = self.drop(hidden_states)
output_shape = input_shape + (hidden_states.size(-1),)
presents = () if use_cache else None
all_attentions = () if output_attentions else None
all_hidden_states = () if output_hidden_states else None
if use_lm:
hidden_states = torch.cat((encoder_hidden_states, inputs_embeds), 1)
attention_mask = torch.cat((encoder_attention_mask, attention_mask), 3)
y_len = inputs_embeds.shape[-2]
encoder_hidden_states = None
encoder_attention_mask = None
else:
y_len = None
for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
if output_hidden_states:
all_hidden_states = all_hidden_states + (hidden_states.view(*output_shape),)
outputs = block(
hidden_states,
layer_past=layer_past,
attention_mask=attention_mask,
head_mask=head_mask[i],
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
use_cache=use_cache,
output_attentions=output_attentions,
decoder_input_length=y_len,
)
hidden_states, present = outputs[:2]
if use_cache is True:
presents = presents + (present,)
if output_attentions:
all_attentions = all_attentions + (outputs[2],)
hidden_states = self.ln_f(hidden_states)
if use_lm:
hidden_states = hidden_states[:, -output_shape[-2] :, :]
else:
hidden_states = hidden_states.view(*output_shape)
# Add last hidden state
if output_hidden_states:
all_hidden_states = all_hidden_states + (hidden_states,)
if not return_dict:
return tuple(
v
for v in [hidden_states, presents, all_hidden_states, all_attentions]
if v is not None
)
return BaseModelOutputWithPast(
last_hidden_state=hidden_states,
past_key_values=presents,
hidden_states=all_hidden_states,
attentions=all_attentions,
)
@add_start_docstrings(
"""The GPT2 Model transformer with a language modeling head on top
(linear layer with weights tied to the input embeddings). """,
GPT2_START_DOCSTRING,
)
class GPT2LMHeadModel(GPT2PreTrainedModel):
authorized_missing_keys = [r"h\.\d+\.attn\.masked_bias", r"lm_head\.weight"]
def __init__(self, config):
super().__init__(config)
self.transformer = GPT2Model(config)
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
self.init_weights()
def get_output_embeddings(self):
return self.lm_head
def prepare_inputs_for_generation(self, input_ids, past=None, **kwargs):
# only last token for inputs_ids if past is defined in kwargs
if past:
input_ids = input_ids[:, -1].unsqueeze(-1)
return {
"input_ids": input_ids,
"past_key_values": past,
"use_cache": kwargs.get("use_cache"),
}
@add_start_docstrings_to_callable(GPT2_INPUTS_DOCSTRING)
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
checkpoint="gpt2",
output_type=CausalLMOutputWithPast,
config_class=_CONFIG_FOR_DOC,
)
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
labels=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
use_lm=False,
**kwargs,
):
r"""
labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
Labels for language modeling.
Note that the labels **are shifted** inside the model, i.e. you can set ``labels = input_ids``
Indices are selected in ``[-100, 0, ..., config.vocab_size]``
All labels set to ``-100`` are ignored (masked), the loss is only
computed for labels in ``[0, ..., config.vocab_size]``
"""
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
transformer_outputs = self.transformer(
input_ids,
past_key_values=past_key_values,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
position_ids=position_ids,
head_mask=head_mask,
inputs_embeds=inputs_embeds,
encoder_hidden_states=encoder_hidden_states,
encoder_attention_mask=encoder_attention_mask,
use_cache=use_cache,
output_attentions=output_attentions,
output_hidden_states=output_hidden_states,
return_dict=return_dict,
use_lm=use_lm,
)
hidden_states = transformer_outputs[0]
lm_logits = self.lm_head(hidden_states)
loss = None
if labels is not None:
# Shift so that tokens < n predict n
shift_logits = lm_logits[..., :-1, :].contiguous()
shift_labels = labels[..., 1:].contiguous()
# Flatten the tokens
loss_fct = CrossEntropyLoss()
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
if not return_dict:
output = (lm_logits,) + transformer_outputs[1:]
return ((loss,) + output) if loss is not None else output
return CausalLMOutputWithPast(
loss=loss,
logits=lm_logits,
past_key_values=transformer_outputs.past_key_values,
hidden_states=transformer_outputs.hidden_states,
attentions=transformer_outputs.attentions,
)
@add_start_docstrings(
"""The GPT2 Model transformer with a language modeling and a multiple-choice classification
head on top e.g. for RocStories/SWAG tasks. The two heads are two linear layers.
The language modeling head has its weights tied to the input embeddings,
the classification head takes as input the input of a specified classification token index in the input sequence).
""",
GPT2_START_DOCSTRING,
)
class GPT2DoubleHeadsModel(GPT2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
config.num_labels = 1
self.transformer = GPT2Model(config)
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
self.multiple_choice_head = SequenceSummary(config)
self.init_weights()
def get_output_embeddings(self):
return self.lm_head
def prepare_inputs_for_generation(self, input_ids, past=None, **kwargs):
# only last token for inputs_ids if past is defined in kwargs
if past:
input_ids = input_ids[:, -1].unsqueeze(-1)
return {
"input_ids": input_ids,
"past_key_values": past,
"use_cache": kwargs.get("use_cache"),
}
@add_start_docstrings_to_callable(GPT2_INPUTS_DOCSTRING)
@replace_return_docstrings(
output_type=GPT2DoubleHeadsModelOutput, config_class=_CONFIG_FOR_DOC
)
def forward(
self,
input_ids=None,
past_key_values=None,
attention_mask=None,
token_type_ids=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
mc_token_ids=None,
labels=None,
mc_labels=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
**kwargs,
):
r"""
mc_token_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
Index of the classification token in each input sequence.
Selected in the range ``[0, input_ids.size(-1) - 1[``.
labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`)
Labels for language modeling.
Note that the labels **are shifted** inside the model, i.e. you can set ``labels = input_ids``
Indices are selected in ``[-1, 0, ..., config.vocab_size]``
All labels set to ``-100`` are ignored (masked), the loss is only
computed for labels in ``[0, ..., config.vocab_size]``
mc_labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size)`, `optional`)
Labels for computing the multiple choice classification loss.
Indices should be in ``[0, ..., num_choices]`` where `num_choices` is the size of the second dimension
of the input tensors. (see `input_ids` above)
kwargs (:obj:`Dict[str, any]`, optional, defaults to `{}`):
Used to hide legacy arguments that have been deprecated.
Return:
Examples::
>>> import torch
>>> from transformers import GPT2Tokenizer, GPT2DoubleHeadsModel
>>> tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
>>> model = GPT2DoubleHeadsModel.from_pretrained('gpt2, return_dict=True)
>>> # Add a [CLS] to the vocabulary (we should train it also!)
>>> num_added_tokens = tokenizer.add_special_tokens({'cls_token': '[CLS]'})
>>> embedding_layer = model.resize_token_embeddings(len(tokenizer)) # Update the model embeddings with the new vocabulary size
>>> choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
>>> encoded_choices = [tokenizer.encode(s) for s in choices]
>>> cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]
>>> input_ids = torch.tensor(encoded_choices).unsqueeze(0) # Batch size: 1, number of choices: 2
>>> mc_token_ids = torch.tensor([cls_token_location]) # Batch size: 1
>>> outputs = model(input_ids, mc_token_ids=mc_token_ids)
>>> lm_logits = outputs.lm_logits
>>> mc_logits = outputs.mc_logits
"""
if "lm_labels" in kwargs:
warnings.warn(
"The `lm_labels` argument is deprecated and will be removed in a future version, use `labels` instead.",
FutureWarning,
)
labels = kwargs.pop("lm_labels")
if "past" in kwargs:
warnings.warn(
"The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.",
FutureWarning,
)
past_key_values = kwargs.pop("past")
assert kwargs == {}, f"Unexpected keyword arguments: {list(kwargs.keys())}."
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
transformer_outputs = self.transformer(
input_ids,
past_key_values=past_key_values,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
position_ids=position_ids,
head_mask=head_mask,
inputs_embeds=inputs_embeds,
use_cache=use_cache,
output_attentions=output_attentions,
output_hidden_states=output_hidden_states,
return_dict=return_dict,
)
hidden_states = transformer_outputs[0]
lm_logits = self.lm_head(hidden_states)
mc_logits = self.multiple_choice_head(hidden_states, mc_token_ids).squeeze(-1)
mc_loss = None
if mc_labels is not None:
loss_fct = CrossEntropyLoss()
mc_loss = loss_fct(mc_logits.view(-1, mc_logits.size(-1)), mc_labels.view(-1))
lm_loss = None
if labels is not None:
shift_logits = lm_logits[..., :-1, :].contiguous()
shift_labels = labels[..., 1:].contiguous()
loss_fct = CrossEntropyLoss()
lm_loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
if not return_dict:
output = (lm_logits, mc_logits) + transformer_outputs[1:]
if mc_loss is not None:
output = (mc_loss,) + output
return ((lm_loss,) + output) if lm_loss is not None else output
return GPT2DoubleHeadsModelOutput(
loss=lm_loss,
mc_loss=mc_loss,
logits=lm_logits,
mc_logits=mc_logits,
past_key_values=transformer_outputs.past_key_values,
hidden_states=transformer_outputs.hidden_states,
attentions=transformer_outputs.attentions,
)
| craftassist-master | python/base_agent/ttad/back_translation/huggingface_modeling_gpt2.py |
import argparse
import ast
import copy
import json
import os
import random
from recombine_data_utils import *
from typing import *
def create_train_valid_split(chunk_index: int, k: int, data_dir: str, output_dir: str):
"""Create partitions for k fold Cross Validation
Given a chunk index for the valid set, create train and valid split from k chunks of the dataset.
Chunk index is a an index in the range 0 to k.
"""
# Read from other chunks and write JSON file to train/ dir
train_dataset: List[Dict] = []
valid_dataset: List[Dict] = []
for i in range(k):
# Use this as the validation set
if i == chunk_index:
valid_dataset += json.load(
open(data_dir + "cv_pool/chunk_{}/annotated_augmented.json".format(i))
)
else:
train_dataset += json.load(
open(data_dir + "cv_pool/chunk_{}/annotated_augmented.json".format(i))
)
# Write to train and valid directories
directories: List[str] = ["/", "train/", "valid/"]
for d in directories:
if not os.path.isdir(output_dir + d):
os.mkdir(output_dir + d)
print(
"Writing {} entries to {}".format(
len(train_dataset), output_dir + "train/annotated_augmented.json"
)
)
json.dump(train_dataset, open(output_dir + "train/annotated_augmented.json", "w"))
print(
"Writing {} entries to {}".format(
len(valid_dataset), output_dir + "valid/annotated_augmented.json"
)
)
json.dump(valid_dataset, open(output_dir + "valid/annotated_augmented.json", "w"))
def get_train_annotated_commands(
data_dir: str, tool1_path: str, tool2_path: str, node_types: List[str]
) -> (List[str], List[str], Dict[str, dict]):
"""
Fetch Turk data corresponding to annotated data training set.
"""
# Read from tool 1
tool1_lines: List[str] = open(tool1_path).readlines()
# Read from tool 2
tool2_lines: List[str] = open(tool2_path).readlines()
# Load the training data that we created
train_annotated_trees = json.load(open(data_dir + "train/annotated_augmented.json"))
train_annotated_phrases: List[str] = [x[0] for x in train_annotated_trees]
turk_processor = TurkToolProcessor(train_annotated_phrases, node_types)
# Filter samples that we want to use for recombination
filtered_tool1_lines: List[str] = turk_processor.filter_tool1_lines(tool1_lines)
filtered_tool2_lines: List[str] = turk_processor.filter_tool2_lines(tool2_lines)
chat_tree_inserts = turk_processor.build_tree_inserts_dict(tool2_lines)
return (filtered_tool1_lines, filtered_tool2_lines, chat_tree_inserts)
def create_templates_for_node_type(
chat: str,
node_type: str,
action_dict: dict,
filtered_tool1_lines: List[str],
chat_tree_inserts: dict,
) -> (List[tuple], List[tuple]):
"""
Generate templates and fragments for recombination.
"""
new_templates = []
new_fragments = []
# create recombination template and fragment from tree and chat
for k, v in ast.literal_eval(action_dict).items():
if k == node_type:
if contains_span(v):
full_tree_with_hole = get_full_tree(
chat, node_type, filtered_tool1_lines, chat_tree_inserts
)
if full_tree_with_hole is None:
print("Error finding the full tree for chat {}".format(chat))
break
span_idxs = get_loc_span_range(full_tree_with_hole, node_type)
fragment, new_chat = process_chat(chat, span_idxs[1])
# chat, fragment for subs, original tree with hole (for fragment)
# original span idxs so we can shift the new ones over
new_templates.append((new_chat, span_idxs[1], v, full_tree_with_hole))
# chat fragment, corresponding tree
new_fragments.append((fragment, span_idxs[1], v))
return (new_templates, new_fragments)
def gen_chat_tree_templates_and_fragments(
filtered_tool1_lines, filtered_tool2_lines, chat_tree_inserts, node_types
) -> (Dict[str, list], Dict[str, list]):
"""
Generate chat and tree fragments and templates.
"""
full_trees = {}
fragments = {}
for l in filtered_tool2_lines:
chat, child_name, action_dict = l.split("\t")
if child_name in node_types:
if child_name not in full_trees:
full_trees[child_name] = []
if child_name not in fragments:
fragments[child_name] = []
new_templates, new_fragments = create_templates_for_node_type(
chat, child_name, action_dict, filtered_tool1_lines, chat_tree_inserts
)
full_trees[child_name] += new_templates
fragments[child_name] += new_fragments
return (full_trees, fragments)
def process_chat(chat: str, span_idxs: list) -> (str, str):
"""Given a chat and span range, remove the span and insert a single <unk> token.
Return the removed span (Fragment) and processed chat (Template).
"""
tokens = chat.split(" ")
fragment = []
new_tokens = []
idx = span_idxs[0]
while idx <= span_idxs[1]:
fragment.append(tokens[idx])
idx += 1
new_tokens += tokens[0 : span_idxs[0]]
new_tokens.append("<unk>")
if len(span_idxs) > 1:
new_tokens += tokens[(span_idxs[1] + 1) : len(tokens)]
return (" ".join(fragment), " ".join(new_tokens))
def insert_fragment_to_templated_chat(templated_chat: str, fragment: str) -> (str, list):
"""
Utility for inserting fragments to trees and chats. Note that we deepcopy subtrees.
"""
chat_str = templated_chat.split(" ")
new_chat_str = []
span_idx = []
for token in chat_str:
if token == "<unk>":
span_idx.append(len(new_chat_str))
new_chat_str += fragment.split(" ")
span_idx.append(len(new_chat_str) - 1)
else:
new_chat_str.append(token)
return (" ".join(new_chat_str), span_idx)
def insert_subtree_into_full_tree(
subtree: dict, full_tree: dict, original_span_idx: list, idx_shift: int, span_offset: int
) -> dict:
"""
Recursively make sure each span node is updated other than the "no"
"""
new_tree = copy.deepcopy(full_tree)
for k, v in new_tree.items():
if type(v) == dict:
new_tree[k] = insert_subtree_into_full_tree(
subtree, v, original_span_idx, idx_shift, span_offset
)
if type(v) == list:
if type(v[0]) == str:
if v[0] == "yes":
if type(v[1]) == dict:
new_tree[k] = insert_subtree_into_full_tree(
subtree, v[1], original_span_idx, idx_shift, span_offset
)
elif type(v[1]) == list and is_span(v[1]):
new_tree[k] = reformat_span_idxs(v[1])
if new_tree[k][1][0] > original_span_idx[0]:
new_tree[k][1] = [x - idx_shift[1] for x in new_tree[k][1]]
else:
new_tree[k] = v[1]
elif v[0] == "no":
new_tree[k] = update_tree_spans(copy.deepcopy(subtree), span_offset)
elif is_span(v):
new_tree[k] = reformat_span_idxs(v)
# shift indices over if needed
if new_tree[k][1][0] > original_span_idx[0]:
new_tree[k][1] = [x - idx_shift[1] for x in new_tree[k][1]]
return new_tree
def update_fragment_tree(tree: dict, offset: int) -> dict:
"""
Update span positions in a subtree.
"""
new_tree = copy.deepcopy(tree)
for key, value in tree.items():
if type(value) == list and is_span(value):
reformat_idxs = reformat_span_idxs(value)
if contains_negative(reformat_idxs[1], offset):
del new_tree[key]
else:
new_tree[key] = [0, [x - offset for x in reformat_idxs[1]]]
elif type(value) == dict:
new_tree[key] = update_fragment_tree(value, offset)
return new_tree
def create_fragment_dataset(subtrees: list, key: str) -> list:
"""
Creates a dataset of spans given a node type, eg. schematic.
"""
fragments_dataset = []
for fragment_set in subtrees:
text, span, tree = fragment_set
head = {key: copy.deepcopy(tree)}
new_tree = postprocess_tree(update_fragment_tree(head, span[0]))
fragments_dataset.append((text, new_tree["action_sequence"][0]))
return fragments_dataset
def gen_recombined_data(templates: List[tuple], fragments: List[tuple]) -> List[tuple]:
"""
Generate recombined examples.
"""
recombined_data = []
for i in range(len(templates)):
for j in range(len(fragments)):
if i == j:
continue
templated_chat, orig_chat_span_idx, templated_tree, templated_full_tree = templates[i]
fragment, orig_fragment_span_idx, subtree = fragments[j]
recombined_chat, new_chat_span_idx = insert_fragment_to_templated_chat(
templated_chat, fragment
)
# Calculate shift between original span idx and new span idx
idx_shift = [
orig_chat_span_idx[0] - new_chat_span_idx[0],
orig_chat_span_idx[1] - new_chat_span_idx[1],
]
# span gap for templated chat - orig_chat_span_idx
# offset for span - orig_fragment_span_idx
span_offset = orig_fragment_span_idx[0] - new_chat_span_idx[0]
recombined_full_tree = insert_subtree_into_full_tree(
subtree, templated_full_tree, orig_chat_span_idx, idx_shift, span_offset
)
recombined_full_tree = postprocess_tree(recombined_full_tree)
recombined_data.append((recombined_chat, recombined_full_tree))
return recombined_data
def write_recombined_data_chunk(
data_dir: str,
output_dir: str,
tool1_path: str,
tool2_path: str,
dataset_name: str,
node_types: List[str],
use_fragments: bool,
):
"""
Read from a partition and write recombined results to output directory.
"""
filtered_tool1_lines, filtered_tool2_lines, chat_tree_inserts = get_train_annotated_commands(
data_dir, tool1_path, tool2_path, node_types
)
combined_templates, combined_fragments = gen_chat_tree_templates_and_fragments(
filtered_tool1_lines, filtered_tool2_lines, chat_tree_inserts, node_types
)
recombined_data: List[List[str, dict]] = []
fragments_dataset: List[List[str, dict]] = []
for key in node_types:
recombined_data += gen_recombined_data(combined_templates[key], combined_fragments[key])
fragments_dataset += create_fragment_dataset(combined_fragments[key], key)
train_output_dir = output_dir + "train/"
if not os.path.isdir(train_output_dir):
os.mkdir(train_output_dir)
if use_fragments:
random.shuffle(fragments_dataset)
fragments_data = [[str(x[0]), x[1]] for x in fragments_dataset]
with open(train_output_dir + dataset_name + "_fragments.json", "w") as outfile:
print(
"Writing {} fragments data samples to directory {}".format(
len(fragments_data), train_output_dir + dataset_name + ".json"
)
)
json.dump(fragments_dataset, outfile)
else:
recombined_data += fragments_dataset
random.shuffle(recombined_data)
recombined_data = [[str(x[0]), x[1]] for x in recombined_data]
print("Created recombined dataset with size {}".format(len(recombined_data)))
with open(train_output_dir + dataset_name + ".json", "w") as outfile:
print(
"Writing {} recombined data samples to directory {}".format(
len(recombined_data), train_output_dir + dataset_name + ".json"
)
)
json.dump(recombined_data, outfile)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="/private/home/rebeccaqian/minecraft/python/craftassist/ttad/data/annotated_data/",
type=str,
help="train/valid/test data",
)
parser.add_argument(
"--dataset_name",
default="prompts_recombined_location_ref_objects",
type=str,
help="name of recombined dataset",
)
parser.add_argument(
"--output_dir",
default="/checkpoint/rebeccaqian/files/annotated_data/",
type=str,
help="directory to write recombined data",
)
parser.add_argument(
"-k", default=10, type=int, help="Number of partitions in leave-k-out-cross-validation."
)
parser.add_argument(
"--create_k_fold_split",
action="store_true",
help="Whether to split data into k partitions.",
)
parser.add_argument(
"--fragments", action="store_true", help="Only generate fragments (default is both)."
)
parser.add_argument(
"--node_types",
default="location,reference_object,schematic",
type=str,
help="Comma-separated types of nodes to use for recombination",
)
parser.add_argument(
"--tool1_path",
default="/private/home/rebeccaqian/minecraft/python/craftassist/text_to_tree_tool/turk_data/tool1/prompts/2_200/all_agreements.txt",
type=str,
help="Path to tool1 .txt file",
)
parser.add_argument(
"--tool2_path",
default="/private/home/rebeccaqian/minecraft/python/craftassist/text_to_tree_tool/turk_data/tool2/prompts/2_200/all_agreements.txt",
type=str,
help="Path to tool2 .txt file",
)
args = parser.parse_args()
# types of nodes we want to use for recombination
node_types = args.node_types.split(",")
if args.create_k_fold_split:
for valid_partition_idx in range(args.k):
output_dir = args.output_dir + "run_{}".format(str(valid_partition_idx)) + "/"
create_train_valid_split(valid_partition_idx, args.k, args.data_dir, output_dir)
data_dir = output_dir
write_recombined_data_chunk(
data_dir=data_dir,
output_dir=output_dir,
tool1_path=args.tool1_path,
tool2_path=args.tool2_path,
dataset_name=args.dataset_name,
node_types=node_types,
use_fragments=args.fragments,
)
else:
output_dir = args.output_dir
data_dir = args.data_dir
write_recombined_data_chunk(
data_dir=data_dir,
output_dir=output_dir,
tool1_path=args.tool1_path,
tool2_path=args.tool2_path,
dataset_name=args.dataset_name,
node_types=node_types,
use_fragments=args.fragments,
)
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/recombine_data.py |
# flake8: noqa
import json
import math
import pickle
import torch
from transformers import AutoModel, AutoTokenizer, BertConfig
from utils_caip import *
from utils_parsing import *
from train_model import *
from pprint import pprint
model = "python/craftassist/models/semantic_parser/ttad_bert_updated/caip_test_model.pth"
args_path = "python/craftassist/models/semantic_parser/ttad_bert_updated/caip_test_model_args.pk"
args = pickle.load(open(args_path, "rb"))
tokenizer = AutoTokenizer.from_pretrained(args.pretrained_encoder_name)
full_tree, tree_i2w = json.load(open(args.tree_voc_file))
dataset = CAIPDataset(tokenizer, args, prefix="", full_tree_voc=(full_tree, tree_i2w))
enc_model = AutoModel.from_pretrained(args.pretrained_encoder_name)
bert_config = BertConfig.from_pretrained("bert-base-uncased")
bert_config.is_decoder = True
bert_config.vocab_size = len(tree_i2w) + 8
bert_config.num_hidden_layers = args.num_decoder_layers
dec_with_loss = DecoderWithLoss(bert_config, args, tokenizer)
encoder_decoder = EncoderDecoderWithLoss(enc_model, dec_with_loss, args)
encoder_decoder.load_state_dict(torch.load(model))
encoder_decoder = encoder_decoder.cuda()
_ = encoder_decoder.eval()
def get_beam_tree(chat, noop_thres=0.95, beam_size=5, well_formed_pen=1e2):
btr = beam_search(chat, encoder_decoder, tokenizer, dataset, beam_size, well_formed_pen)
if btr[0][0].get("dialogue_type", "NONE") == "NOOP" and math.exp(btr[0][1]) < noop_thres:
tree = btr[1][0]
else:
tree = btr[0][0]
return tree
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/test_model_script.py |
import argparse
import functools
import json
import logging
import logging.handlers
import os
import pickle
from time import time
from os.path import isfile
from os.path import join as pjoin
from tqdm import tqdm
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from transformers import AutoModel, AutoTokenizer, BertConfig
from utils_parsing import *
from utils_caip import *
# Wrapper Class around model and data loader
class ModelTrainer:
def __init__(self, args):
self.args = args
# training loop (all epochs at once)
def train(self, model, dataset, tokenizer, model_identifier, full_tree_voc):
# make data sampler
train_sampler = RandomSampler(dataset)
logging.info("Initializing train data sampler: {}".format(train_sampler))
model_collate_fn = functools.partial(
caip_collate, tokenizer=tokenizer, tree_to_text=self.args.tree_to_text
)
train_dataloader = DataLoader(
dataset,
sampler=train_sampler,
batch_size=self.args.batch_size,
collate_fn=model_collate_fn,
)
epoch_iterator = tqdm(train_dataloader, desc="Iteration", disable=True)
# make optimizer
optimizer = OptimWarmupEncoderDecoder(model, self.args)
text_span_optimizer = Adam(
[
{"params": model.decoder.text_span_start_head.parameters()},
{"params": model.decoder.text_span_end_head.parameters()},
],
lr=0.001,
)
text_span_loss_attenuation_factor = self.args.alpha
# training loop
logging.info("Beginning training loop")
for e in range(self.args.num_epochs):
logging.info("Epoch: {}".format(e))
loc_steps = 0
loc_loss = 0.0
loc_int_acc = 0.0
loc_span_acc = 0.0
loc_full_acc = 0.0
text_span_accuracy = 0.0
tot_steps = 0
tot_loss = 0.0
text_span_tot_loss = 0.0
text_span_loc_loss = 0.0
tot_accuracy = 0.0
st_time = time()
for step, batch in enumerate(epoch_iterator):
batch_examples = batch[-1]
batch_tensors = [
t.to(model.decoder.lm_head.predictions.decoder.weight.device)
for t in batch[:4]
]
x, x_mask, y, y_mask = batch_tensors
if self.args.tree_to_text:
outputs = model(y, y_mask, x, x_mask)
else:
outputs = model(x, x_mask, y, y_mask)
loss = outputs["loss"]
text_span_loss = outputs["text_span_loss"]
model.zero_grad()
# backprop
text_span_loss.backward()
text_span_optimizer.step()
loss.backward()
model.decoder.bert_final_layer_out.grad = model.decoder.bert_final_layer_out.grad.add(
text_span_loss_attenuation_factor
* (
model.decoder.text_span_start_hidden_z.grad
+ model.decoder.text_span_end_hidden_z.grad
)
)
if step % self.args.param_update_freq == 0:
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
# text_span_optimizer.step()
optimizer.step()
# compute accuracy and add hard examples
if self.args.tree_to_text:
full_acc = compute_accuracy(outputs, x)
# hacky
lm_acc = full_acc
else:
lm_acc, sp_acc, text_span_acc, full_acc = compute_accuracy(outputs, y)
if "hard" in dataset.dtypes:
if e > 0 or tot_steps > 2 * args.decoder_warmup_steps:
for acc, exple in zip(lm_acc, batch_examples):
if not acc.item():
if step % 200 == 100:
print("ADDING HE:", step, exple[0])
dataset.add_hard_example(exple)
# book-keeping
loc_int_acc += lm_acc.sum().item() / lm_acc.shape[0]
loc_full_acc += full_acc.sum().item() / full_acc.shape[0]
tot_accuracy += full_acc.sum().item() / full_acc.shape[0]
text_span_accuracy += text_span_acc.sum().item() / text_span_acc.shape[0]
if not self.args.tree_to_text:
loc_span_acc += sp_acc.sum().item() / sp_acc.shape[0]
loc_loss += loss.item()
loc_steps += 1
tot_loss += loss.item()
tot_steps += 1
text_span_tot_loss += text_span_loss.item()
text_span_loc_loss += text_span_loss.item()
if step % 400 == 0:
print(
"{:2d} - {:5d} \t L: {:.3f} A: {:.3f} \t {:.2f}".format(
e,
step,
loc_loss / loc_steps,
loc_full_acc / loc_steps,
time() - st_time,
)
)
logging.info(
"{:2d} - {:5d} \t L: {:.3f} A: {:.3f} \t {:.2f}".format(
e,
step,
loc_loss / loc_steps,
loc_full_acc / loc_steps,
time() - st_time,
)
)
logging.info("text span acc: {:.3f}".format(text_span_accuracy / loc_steps))
logging.info("text span loss: {:.3f}".format(text_span_loc_loss / loc_steps))
loc_loss = 0
loc_steps = 0
loc_int_acc = 0.0
loc_span_acc = 0.0
loc_full_acc = 0.0
text_span_accuracy = 0.0
text_span_loc_loss = 0.0
torch.save(
model.state_dict(),
pjoin(self.args.output_dir, "{}(ep=={}).pth".format(model_identifier, e)),
)
# Evaluating model
model.eval()
logging.info("evaluating model")
for dtype_spec in json.loads(self.args.dtype_samples):
dtype, ratio = dtype_spec
self.eval_model_on_dataset(model, dtype, full_tree_voc, tokenizer)
return (tot_loss / tot_steps, tot_accuracy / tot_steps)
# same as training loop without back-propagation
def validate(self, model, dataset, tokenizer, args):
# make data sampler
train_sampler = SequentialSampler(dataset)
model_collate_fn = functools.partial(
caip_collate, tokenizer=tokenizer, tree_to_text=args.tree_to_text
)
train_dataloader = DataLoader(
dataset, sampler=train_sampler, batch_size=args.batch_size, collate_fn=model_collate_fn
)
epoch_iterator = tqdm(train_dataloader, desc="Iteration", disable=True)
# training loop
tot_steps = 0
tot_loss = 0.0
tot_int_acc = 0.0
tot_span_acc = 0.0
tot_accu = 0.0
text_span_tot_acc = 0.0
text_span_tot_loss = 0.0
# disable autograd to reduce memory usage
with torch.no_grad():
for step, batch in enumerate(epoch_iterator):
batch_tensors = [
t.to(model.decoder.lm_head.predictions.decoder.weight.device)
for t in batch[:4]
]
x, x_mask, y, y_mask = batch_tensors
outputs = model(x, x_mask, y, y_mask)
loss = outputs["loss"]
text_span_loss = outputs["text_span_loss"]
# compute accuracy and add hard examples
lm_acc, sp_acc, text_span_acc, full_acc = compute_accuracy(outputs, y)
# book-keeping
tot_int_acc += lm_acc.sum().item() / lm_acc.shape[0]
tot_span_acc += sp_acc.sum().item() / sp_acc.shape[0]
tot_accu += full_acc.sum().item() / full_acc.shape[0]
tot_loss += loss.item()
tot_steps += 1
# text span stats
text_span_tot_acc += text_span_acc.sum().item() / text_span_acc.shape[0]
text_span_tot_loss += text_span_loss.item()
return (
tot_loss / tot_steps,
tot_int_acc / tot_steps,
tot_span_acc / tot_steps,
tot_accu / tot_steps,
text_span_tot_acc / tot_steps,
text_span_tot_loss / tot_steps,
)
# Evaluate model on a given validation dataset:
def eval_model_on_dataset(self, encoder_decoder, dtype, full_tree_voc, tokenizer):
valid_dataset = CAIPDataset(
tokenizer, self.args, prefix="valid", dtype=dtype, full_tree_voc=full_tree_voc
)
l, _, _, a, text_span_acc, text_span_loss = self.validate(
encoder_decoder, valid_dataset, tokenizer, self.args
)
print("evaluating on {} valid: \t Loss: {:.4f} \t Accuracy: {:.4f}".format(dtype, l, a))
logging.info(
"evaluating on {} valid: \t Loss: {:.4f} \t Accuracy: {:.4f}".format(dtype, l, a)
)
logging.info(
"text span Loss: {:.4f} \t Accuracy: {:.4f}".format(text_span_loss, text_span_acc)
)
def generate_model_name(args, optional_identifier=""):
name = ""
# unix time in seconds, used as a unique identifier
time_now = round(time())
args_keys = {
"batch_size": "batch",
"decoder_learning_rate": "dec_lr",
"decoder_warmup_steps": "dec_ws",
"dtype_samples": "spl",
"encoder_learning_rate": "enc_lr",
"encoder_warmup_steps": "enc_ws",
"model_name": "name",
"node_label_smoothing": "n_ls",
"num_epochs": "ep",
"num_highway": "hw",
"param_update_freq": "upd_frq",
"word_dropout": "word_drp",
"alpha": "a",
}
for k, v in vars(args).items():
if k in args_keys:
name += "{param}={value}|".format(param=args_keys[k], value=v)
# In case we want additional identification for the model, eg. test run
name += "{time}|".format(time=time_now)
name += optional_identifier
return name
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="python/craftassist/datasets/annotated_data/",
type=str,
help="train/valid/test data",
)
parser.add_argument(
"--output_dir",
default="python/craftassist/models/semantic_parser/ttad_bert_updated/",
type=str,
help="Where we save the model",
)
parser.add_argument("--model_name", default="caip_parser", type=str, help="Model name")
parser.add_argument(
"--tree_voc_file",
default="python/craftassist/models/semantic_parser/ttad_bert_updated/caip_test_model_tree.json",
type=str,
help="Pre-computed grammar and output vocabulary",
)
# model arguments
parser.add_argument(
"--pretrained_encoder_name",
default="distilbert-base-uncased",
type=str,
help="Pretrained text encoder "
"See full list at https://huggingface.co/transformers/pretrained_models.html",
)
parser.add_argument(
"--num_decoder_layers",
default=6,
type=int,
help="Number of transformer layers in the decoder",
)
parser.add_argument(
"--num_highway", default=2, type=int, help="Number of highway layers in the mapping model"
)
# optimization arguments
parser.add_argument(
"--optimizer", default="adam", type=str, help="Optimizer in [adam|adagrad]"
)
parser.add_argument("--batch_size", default=56, type=int, help="Batch size")
parser.add_argument("--param_update_freq", default=1, type=int, help="Group N batch updates")
parser.add_argument("--num_epochs", default=8, type=int, help="Number of training epochs")
parser.add_argument(
"--examples_per_epoch", default=-1, type=int, help="Number of training examples per epoch"
)
parser.add_argument(
"--train_encoder", action="store_true", help="Whether to finetune the encoder"
)
parser.add_argument(
"--encoder_warmup_steps",
default=1,
type=int,
help="Learning rate warmup steps for the encoder",
)
parser.add_argument(
"--encoder_learning_rate", default=0.0, type=float, help="Learning rate for the encoder"
)
parser.add_argument(
"--decoder_warmup_steps",
default=1000,
type=int,
help="Learning rate warmup steps for the decoder",
)
parser.add_argument(
"--decoder_learning_rate", default=1e-5, type=float, help="Learning rate for the decoder"
)
parser.add_argument(
"--lambda_span_loss",
default=0.5,
type=float,
help="Weighting between node and span prediction losses",
)
parser.add_argument(
"--node_label_smoothing",
default=0.0,
type=float,
help="Label smoothing for node prediction",
)
parser.add_argument(
"--span_label_smoothing",
default=0.0,
type=float,
help="Label smoothing for span prediction",
)
parser.add_argument(
"--dtype_samples",
default='[["templated", 0.55], ["templated_modify", 0.05], ["annotated", 0.4]]',
type=str,
help="Sampling probabilities for handling different data types",
)
parser.add_argument(
"--rephrase_proba", default=-1.0, type=float, help="Only specify probablility of rephrases"
)
parser.add_argument(
"--word_dropout",
default=0.0,
type=float,
help="Probability of replacing input token with [UNK]",
)
parser.add_argument(
"--encoder_dropout", default=0.0, type=float, help="Apply dropout to encoder output"
)
parser.add_argument("--tree_to_text", action="store_true", help="Back translation flag")
parser.add_argument(
"--optional_identifier", default="", type=str, help="Optional run info eg. debug or test"
)
parser.add_argument(
"--alpha",
default=0.8,
type=float,
help="Attenuation factor for text span loss gradient affecting shared layers for tree structure prediction",
)
args = parser.parse_args()
# HACK: allows us to give rephrase proba only instead of full dictionary
if args.rephrase_proba > 0:
args.dtype_samples = json.dumps(
[["templated", 1.0 - args.rephrase_proba], ["rephrases", args.rephrase_proba]]
)
model_identifier = generate_model_name(args, args.optional_identifier)
# set up logging
l_handler = logging.handlers.WatchedFileHandler(
"{}/{}.log".format(args.output_dir, model_identifier)
)
l_format = logging.Formatter(fmt="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S")
l_handler.setFormatter(l_format)
l_root = logging.getLogger()
l_root.setLevel(os.environ.get("LOGLEVEL", "INFO"))
l_root.addHandler(l_handler)
logging.info("****** Args ******")
logging.info(vars(args))
logging.info("model identifier: {}".format(model_identifier))
if isfile(args.tree_voc_file):
logging.info("====== Loading Grammar ======")
full_tree, tree_i2w = json.load(open(args.tree_voc_file))
else:
logging.info("====== Making Grammar ======")
data = {"train": {}, "valid": {}, "test": {}}
dtype_samples_unpacked = json.loads(args.dtype_samples)
dtypes = [t for t, p in dtype_samples_unpacked]
for spl in data:
for dt in dtypes:
fname = pjoin(args.data_dir, "{}/{}.txt".format(spl, dt))
logging.info("loading file {}".format(fname))
if isfile(fname):
data[spl][fname.split("/")[-1][:-4]] = process_txt_data(filepath=fname)
full_tree, tree_i2w = make_full_tree(
[
(d_list, 1.0)
for spl, dtype_dict in data.items()
for dtype, d_list in dtype_dict.items()
]
)
json.dump((full_tree, tree_i2w), open(args.tree_voc_file, "w"))
tokenizer = AutoTokenizer.from_pretrained(args.pretrained_encoder_name)
logging.info("====== Loading Dataset ======")
train_dataset = CAIPDataset(
tokenizer,
args,
prefix="train",
sampling=True,
word_noise=args.word_dropout,
full_tree_voc=(full_tree, tree_i2w),
)
logging.info("====== Setting up Model ======")
# make model
logging.info("making model")
enc_model = AutoModel.from_pretrained(args.pretrained_encoder_name)
bert_config = BertConfig.from_pretrained("bert-base-uncased")
bert_config.is_decoder = True
if args.tree_to_text:
tokenizer.add_tokens(tree_i2w)
else:
bert_config.vocab_size = len(tree_i2w) + 8
logging.info("vocab size {}".format(bert_config.vocab_size))
bert_config.num_hidden_layers = args.num_decoder_layers
dec_with_loss = DecoderWithLoss(bert_config, args, tokenizer)
encoder_decoder = EncoderDecoderWithLoss(enc_model, dec_with_loss, args)
# save configs
json.dump(
(full_tree, tree_i2w), open(pjoin(args.output_dir, model_identifier + "_tree.json"), "w")
)
pickle.dump(args, open(pjoin(args.output_dir, model_identifier + "_args.pk"), "wb"))
# train_model
logging.info("====== Training Model ======")
encoder_decoder = encoder_decoder.cuda()
encoder_decoder.train()
full_tree_voc = (full_tree, tree_i2w)
model_trainer = ModelTrainer(args)
loss, accu = model_trainer.train(
encoder_decoder, train_dataset, tokenizer, model_identifier, full_tree_voc
)
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/train_model.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/__init__.py |
import ast
import copy
from enum import Enum
from typing import *
class TurkToolProcessor:
def __init__(self, train_annotated_phrases: List[str], node_types: List[str]):
self.train_annotated_phrases = train_annotated_phrases
self.node_types = node_types
def filter_tool1_lines(self, tool1_lines: List[str]) -> List[str]:
"""Fetch Turk tool1 lines that correspond to the training dataset.
-- tool1_lines: input from Turk tool, with format <text> \t <action dict>
-- node_types: list of nodes we want to swap, eg. location
Source: https://github.com/fairinternal/minecraft/tree/master/python/craftassist/text_to_tree_tool/turk_data/tool1/
"""
filtered_lines = []
for l in tool1_lines:
text, action_dict = l.split("\t")
if text in self.train_annotated_phrases:
# Check that the tree can be expanded
if "no" not in action_dict:
continue
for key in self.node_types:
if key in action_dict:
filtered_lines.append(l)
break
return filtered_lines
def is_chat_subset(self, chat: str) -> bool:
"""
Checks whether a chat fits criteria for recombination.
"""
return (
chat in self.train_annotated_phrases
and len(chat.split(" ")) <= 30
and "composite_action" not in chat
)
def filter_tool2_lines(self, tool2_lines: List[str]) -> List[str]:
"""Fetch Turk tool2 lines that correspond to the training dataset.
tool2_lines -- input from Turk tool, with format <chat> \t <tag> \t <action dict>
node_types -- list of nodes we want to swap, eg. location
Source: https://github.com/fairinternal/minecraft/tree/master/python/craftassist/text_to_tree_tool/turk_data/tool2/
"""
filtered_lines = []
for l in tool2_lines:
chat, tag, action_dict = l.split("\t")
use_chat = self.is_chat_subset(chat)
if tag in self.node_types and use_chat:
filtered_lines.append(l)
return filtered_lines
def build_tree_inserts_dict(self, lines: List[str]) -> Dict[str, dict]:
"""
Build tree representation of chats and all inserts for the full tree
"""
chat_tree_inserts = {}
for l in lines:
chat, tag, action_dict = l.split("\t")
if chat in self.train_annotated_phrases:
if chat not in chat_tree_inserts:
chat_tree_inserts[chat] = {tag: ast.literal_eval(action_dict)}
else:
chat_tree_inserts[chat][tag] = ast.literal_eval(action_dict)
return chat_tree_inserts
def get_full_tree(
chat: str, key: str, tool1_lines: List[str], chat_tree_inserts: List[dict]
) -> Union[dict, None]:
"""
Given a chat command, fetch the full tree minus the node we want to swap.
"""
# Fetch the corresponding full tree with hole
for full_line in tool1_lines:
if chat in full_line:
_, full_tree = full_line.split("\t")
full_tree_dict = ast.literal_eval(full_tree)
# fill other holes
full_tree_dict = fill_other_holes(key, full_tree_dict, chat, chat_tree_inserts)
return full_tree_dict
return None
def fill_other_holes(key: str, full_tree: dict, chat: str, chat_tree_inserts: dict) -> dict:
"""Given a full tree (with holes), node type of swaps and the chat command, fill the holes for nodes
that we are not swapping.
"""
new_tree = copy.deepcopy(full_tree)
for k, v in new_tree.items():
if v[0] == "no" and k != key:
if type(v[1]) == list:
new_tree[k] = v[1]
# get the subtree from the grouped document by the chat instruction
tree_insert = copy.deepcopy(chat_tree_inserts[chat][k][k])
new_tree[k] = tree_insert
return new_tree
class SpanType(Enum):
TURK = 1
DATASET = 2
def is_span(val: Any) -> Union[bool, SpanType]:
"""
Check if a value is a span type.
"""
if type(val) == list:
# Unformatted spans
if type(val[0]) == list and type(val[0][0]) == int:
return SpanType.TURK
# Formatted spans
if type(val[0]) == int and type(val[1]) == list:
return SpanType.DATASET
return False
def contains_negative(span: List[int], offset: int) -> bool:
"""
Checks if a recombined span contains negative values.
"""
for idx in span:
if idx - int(offset) < 0:
return True
return False
def contains_span(tree: dict) -> bool:
"""
Whether a tree contains span nodes.
"""
for k, v in tree.items():
if type(v) == dict:
return contains_span(v)
if type(v) == list:
if is_span(v):
return True
return False
def get_loc_span_range(tree: dict, key: str) -> Union[list, None]:
"""
Fetch the span range for the subtree to be inserted into the full tree (with hole).
"""
for k, v in tree.items():
if k == key:
if type(v) == list and v[0] == "no":
span_range = reformat_span_idxs(v[1])
return span_range
return None
def reformat_span_idxs(span_idx_list: List[List[int]]) -> list:
"""
Reformat span idxs to look like [0, [start_idx, end_idx]]
"""
span_idxs = [x[0] for x in span_idx_list]
start_idx = min(span_idxs)
end_idx = max(span_idxs)
return [0, [start_idx, end_idx]]
def update_tree_spans(tree: dict, shift: int) -> dict:
"""Insert recombined tree into parent tree.
Get rid of "yes" and "no" indicators, reformat tree, insert subtrees.
"""
new_tree = copy.deepcopy(tree)
for k, v in new_tree.items():
if type(v) == dict:
new_tree[k] = update_tree_spans(v, shift)
span_type = is_span(v)
if span_type:
if span_type == SpanType.TURK:
new_tree[k] = reformat_span_idxs(v)
new_tree[k][1] = [x - shift for x in new_tree[k][1]]
return new_tree
def postprocess_tree(tree: dict) -> dict:
"""
Process a turk tool generated tree to fit the format for model datasets.
"""
new_tree = copy.deepcopy(tree)
new_tree = postprocess_tree_helper(new_tree)
new_tree["action_sequence"] = [{}]
for k, v in copy.deepcopy(new_tree).items():
if k != "dialogue_type" and k != "action_sequence":
for i in range(len(new_tree["action_sequence"])):
action_dict = new_tree["action_sequence"][i]
if k not in action_dict:
action_dict[k] = v
elif i == len(new_tree["action_sequence"]) - 1:
new_tree["action_sequence"].append({k: v})
del new_tree[k]
return new_tree
def postprocess_tree_helper(tree: dict) -> dict:
"""
Post processing recombined tree.
"""
new_tree = copy.deepcopy(tree)
for k, v in tree.items():
if k == "action_type":
if v == "copy":
new_tree[k] = "build"
new_tree[k] = new_tree[k].upper()
if k == "contains_coreference" and v == "no":
del new_tree[k]
if type(v) == dict:
new_tree[k] = postprocess_tree_helper(v)
return new_tree
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/recombine_data_utils.py |
import json
import numpy as np
import random
import re
import ast
from os.path import isfile, isdir
from os.path import join as pjoin
import torch
from torch.utils.data import Dataset
#########
# Node typing: checking the type of a specific sub-tree (dict value)
#########
def is_span(val):
try:
a, (b, c) = val
return all([type(v) == int for v in [a, b, c]])
except (ValueError, TypeError):
return False
def is_span_list(val):
res = type(val) == list and len(val) > 0 and all([is_span(v) for v in val])
return res
def is_cat(val):
return type(val) == str or val is True or val is False
def is_cat_list(val):
res = (type(val) == list) and len(val) > 0 and all([is_cat(v) for v in val])
return res
def is_int(val):
return type(val) == dict
def is_int_list(val):
res = (type(val) == list) and len(val) > 0 and all([is_int(v) for v in val])
return res
#########
# Make grammar from dataset. Starts with empty full_tree
# then add all nodes found in the dataset
#########
# if new_tree is outside of what the grammar can handle, modifies grammar
# also counts number of occurence of each node
def add_tree(full_tree, new_tree, vocounts, nw=1):
for k, v in new_tree.items():
if k not in full_tree:
full_tree[k] = {"name": k, "children": {}, "values": {}, "count": 0}
full_tree[k]["count"] += nw
if is_cat(v):
full_tree[k]["values"][v] = full_tree[k]["values"].get(v, 0) + nw
w = "C:" + k + "|" + str(v)
vocounts[w] = vocounts.get(w, 0) + nw
elif is_int(v):
ws = "IB:" + k
we = "IE:" + k
vocounts[ws] = vocounts.get(ws, 0) + nw
vocounts[we] = vocounts.get(we, 0) + nw
add_tree(full_tree[k]["children"], v, vocounts, nw)
elif is_int_list(v):
ws = "ILB:" + k
wi = "IL&:" + k
we = "ILE:" + k
vocounts[ws] = vocounts.get(ws, 0) + nw
vocounts[wi] = vocounts.get(wi, 0) + nw
vocounts[we] = vocounts.get(we, 0) + nw
for c in v:
add_tree(full_tree[k]["children"], c, vocounts, nw)
elif is_span(v) or is_span_list(v):
# Treating text spans differently because of separate head predicting text spans
if k == "text_span":
w = "TS:" + k
ws = "TBE:" + k
vocounts[w] = vocounts.get(w, 0) + nw
vocounts[ws] = vocounts.get(ws, 0) + nw
w = "S:" + k
ws = "BE:" + k
vocounts[w] = vocounts.get(w, 0) + nw
vocounts[ws] = vocounts.get(ws, 0) + nw
# starts with an empty grammar and adds trees from the dataset
def make_full_tree(trees_weight_ls):
res = {}
vocounts = {}
for trees, weight in trees_weight_ls:
try:
for tree in trees:
dlg, tr = tree
add_tree(res, tr, vocounts, weight)
except ValueError as e:
print(e)
print(tree)
tree_i2w = [k for k, v in sorted(vocounts.items(), key=lambda x: x[1], reverse=True)] + [
"BE:span"
]
return res, tree_i2w
# Converts a txt file format to the tree format needed to construct grammar
def process_txt_data(filepath: str):
samples = open(filepath, "r").readlines()
split_lines = [line.split("|") for line in samples]
# Format of each sample is [text, action_dict]
formatted_data = [[text, ast.literal_eval(action_dict)] for text, action_dict in split_lines]
return formatted_data
#########
# Linearize and de-linearize trees
#########
# transforms tree into sequence of (token, span_start, span_end, text_span_start, text_span_end)
# idx_map maps the span ids before and after tokenization
def tree_to_seq(full_tree, tree, idx_map=None):
res = []
sorted_keys = sorted(
[k for k in tree.keys() if k in full_tree],
key=lambda x: full_tree[x]["count"],
reverse=True,
) + sorted([k for k, v in tree.items() if k not in full_tree])
for k in sorted_keys:
if is_cat(tree[k]):
res += [("C:" + k + "|" + str(tree[k]), -1, -1, -1, -1)]
elif is_span(tree[k]):
if k == "text_span":
a, (b, c) = tree[k]
res += [("TS:" + k, -1, -1, -1, -1)]
res += [("TBE:" + k, -1, -1, idx_map[a][b][0], idx_map[a][c][1])]
else:
a, (b, c) = tree[k]
res += [("S:" + k, -1, -1, -1, -1)]
res += [("BE:" + k, idx_map[a][b][0], idx_map[a][c][1], -1, -1)]
elif is_int(tree[k]):
res += (
[("IB:" + k, -1, -1, -1, -1)]
+ tree_to_seq(full_tree.get(k, {"children": {}})["children"], tree[k], idx_map)
+ [("IE:" + k, -1, -1, -1, -1)]
)
elif is_int_list(tree[k]):
res += [("ILB:" + k, -1, -1, -1, -1)]
for c in tree[k]:
res += tree_to_seq(full_tree.get(k, {"children": {}})["children"], c, idx_map) + [
("IL&:" + k, -1, -1, -1, -1)
]
res = res[:-1] + [("ILE:" + k, -1, -1, -1, -1)]
else:
raise NotImplementedError
return res
# selects sub-tree in (span in the output sequence) so we can apply recursively seq_to_tree
def select_spans(seq):
spans = [-1 for _ in seq]
active = {}
unopened = False
for i, (w, b_id, e_id, text_span_b_id, text_span_e_id) in enumerate(seq):
if w.startswith("IB:") or w.startswith("ILB:"):
active[w] = active.get(w, {})
active[w][i] = 0
for s_idx in active[w]:
active[w][s_idx] += 1
elif w.startswith("IE:") or w.startswith("ILE:"):
ws = w.replace("E:", "B:")
if ws not in active:
# closing an unopened bracket
unopened = True
else:
closed = []
for s_idx in active[ws]:
active[ws][s_idx] -= 1
if active[ws][s_idx] <= 0:
closed += [s_idx]
spans[s_idx] = i
for s_idx in closed:
del active[ws][s_idx]
# check whether all brackets have been closed
well_formed = (sum([len(ctr_dict) for ws, ctr_dict in active.items()]) == 0) and not unopened
for ws in active:
for s_idx in active[ws]:
spans[s_idx] = len(seq)
# create a dictionary of left bracket > right bracket
span_dict = {}
for s_idx, e_idx in enumerate(spans):
if e_idx > 0:
span_dict[s_idx] = e_idx
return (span_dict, well_formed)
# transforms sequence back into tree of nested dictionaries
# span_dict identifies the sub-sequences corresponding to sub-trees
def seq_to_tree(full_tree, seq, idx_rev_map=None, span_dct=None, start_id=0):
res = {}
if span_dct is None:
span_dict, well_formed = select_spans(seq)
else:
span_dict = span_dct
well_formed = True
idx = 0
while idx < len(seq):
if ":" not in seq[idx][0]:
idx += 1
continue
t, w = seq[idx][0].split(":")
# categorical node
if t == "C":
cat, val = w.split("|")
res[cat] = val
idx += 1
# span node
elif t == "S":
if idx + 1 < len(seq):
b_pre = seq[idx + 1][1]
e_pre = seq[idx + 1][2]
l_idx, b_idx = idx_rev_map[b_pre]
_, e_idx = idx_rev_map[e_pre]
res[w] = [l_idx, [b_idx, e_idx]]
else:
res[w] = [-1, [-1, -1]]
# idx += 1
idx += 2
elif t == "TS":
if idx + 1 < len(seq):
text_span_start = seq[idx + 1][3]
text_span_end = seq[idx + 1][4]
list_idx, start_idx = idx_rev_map[text_span_start]
_, end_idx = idx_rev_map[text_span_end]
res[w] = [list_idx, [start_idx, end_idx]]
else:
res[w] = [-1, [-1, -1]]
idx += 2
# internal node
elif t == "IB":
sub_full_tree = full_tree.get(w, {"children": {}})["children"]
sub_span = (idx + 1, span_dict[start_id + idx] - start_id)
sub_seq = seq[sub_span[0] : sub_span[1]]
res[w] = seq_to_tree(
sub_full_tree, sub_seq, idx_rev_map, span_dict, start_id=start_id + sub_span[0]
)[0]
idx = sub_span[1]
# internal node list
elif t == "ILB":
sub_full_tree = full_tree.get(w, {"children": {}})["children"]
sub_span = (idx + 1, span_dict[start_id + idx] - start_id)
pre_sub_seq = seq[sub_span[0] : sub_span[1]]
# split sub-sequence by list items
sub_seq_ls_idx = (
[-1]
+ [i for i, sw in enumerate(pre_sub_seq) if sw[0] == "IL&:" + w]
+ [len(pre_sub_seq)]
)
sub_span_ls = [
(sub_span[0] + sub_seq_ls_idx[i] + 1, sub_span[0] + sub_seq_ls_idx[i + 1])
for i in range(len(sub_seq_ls_idx) - 1)
]
# read sub-trees
res[w] = []
for s_sub_span in sub_span_ls:
sub_seq = seq[s_sub_span[0] : s_sub_span[1]]
res[w] += [
seq_to_tree(
sub_full_tree,
sub_seq,
idx_rev_map,
span_dict,
start_id=start_id + s_sub_span[0],
)[0]
]
idx = sub_span[1]
# failure case??? TODO: raise error
else:
idx += 1
return (res, well_formed)
# returns empty tree if ta and tb are the same tree
def compare_tree(ta, tb):
res = {}
# internal node
if is_int(ta) or is_int_list(ta):
if is_int_list(ta):
ta = ta[0]
tb = tb[0]
for a in ta:
if a in tb:
comp = compare_tree(ta[a], tb[a])
if len(comp) > 0:
res[a] = comp
else:
res[a] = (ta[a], "")
for b in tb:
if b not in ta:
res[b] = ("", tb[b])
elif ta != tb:
res = (ta, tb)
return res
##################
# torch Dataset
##################
# helper function to align word indices before and after applying BPE
def align_post_tok(pre_tok, post_tok, seen_toks=0):
i, j, ci, cj = [0] * 4
idx_map = [[seen_toks, seen_toks] for _ in range(len(pre_tok.split()))]
while ci < len(pre_tok) and cj < len(post_tok):
if pre_tok[ci] == post_tok[cj]:
if pre_tok[ci] == " ":
i += 1
j += 1
if i > 0:
idx_map[i - 1][1] = j - 1 + seen_toks
idx_map[i][0] = j + seen_toks
ci += 1
cj += 1
elif post_tok[cj] == " ":
j += 1
cj += 1
elif pre_tok[ci] == " ":
i += 1
if i > 0:
idx_map[i - 1][0] = j - 1 + seen_toks
idx_map[i][1] = j + seen_toks
ci += 1
else:
cj += 1
idx_map[i][-1] = j + seen_toks
return idx_map
# applies BPE to input and creates mapping of span indices before and after BPE
def tokenize_mapidx(text, tokenizer):
# re-order lines: last chat in multi-chat is first in the list
# rev_lines = [line.strip() for line in text.split('<SEP>')]
# text_lines = [rev_lines[i - 1] for i in range(len(rev_lines), 0, -1)]
text_lines = [line.strip() for line in text.split("<SEP>")]
# tokenize text and linearize tree
seen_toks = 1
idx_maps = [[] for _ in text_lines]
res_toks = ["[CLS]"]
for lid, line in enumerate(text_lines):
tok_line = tokenizer.tokenize(line)
tok_join = " ".join(tok_line)
idx_maps[-1 - lid] = align_post_tok(line, tok_join, seen_toks)
res_toks += tok_line[:] + ["[SEP]"]
seen_toks += len(tok_line) + 1
return (" ".join(res_toks), idx_maps)
# takes raw text and tree, returns BPE-ed text and linearized tree
def tokenize_linearize(text, tree, tokenizer, full_tree, word_noise=0.0):
tok_text, idx_maps = tokenize_mapidx(text, tokenizer)
tokenized = " ".join(
[
"[UNK]" if w not in ["[CLS]", "[SEP]"] and random.random() < word_noise else w
for w in tok_text.split()
]
)
lin_tree = tree_to_seq(full_tree, tree, idx_maps)
return (tokenized, lin_tree)
# torch Dataset for the CAIP format, applies BPE and linearizes trees on-the-fly
class CAIPDataset(Dataset):
"""
CAIP: CraftAssist Instruction Parsing
"""
def __init__(
self,
tokenizer,
args,
prefix="train",
dtype="templated",
sampling=False,
word_noise=0.0,
full_tree_voc=None,
):
assert isdir(args.data_dir)
self.tokenizer = tokenizer
self.tree_to_text = args.tree_to_text
# We load the (input, tree) pairs for all data types and
# initialize the hard examples buffer
self.data = {}
self.sampling = sampling
self.word_noise = word_noise
dtype_samples = json.loads(args.dtype_samples)
self.dtype = dtype
self.dtypes = [t for t, p in dtype_samples]
self.sample_probas = np.array([p for t, p in dtype_samples])
self.sample_probas /= self.sample_probas.sum()
if prefix == "train":
for k in self.dtypes:
fname = pjoin(args.data_dir, prefix, k + ".txt")
assert isfile(fname)
print("loading {}".format(fname))
self.data[k] = process_txt_data(fname)
self.hard_buffer_size = 1024
self.hard_buffer_counter = 0
else:
fname = pjoin(args.data_dir, prefix, dtype + ".txt")
if isfile(fname):
print("loading {}".format(fname))
self.data[dtype] = process_txt_data(fname)
else:
print("could not find dataset {}".format(fname))
self.data[dtype] = []
# load meta-tree and tree vocabulary
if full_tree_voc is None:
print("making tree")
ftr, tr_i2w = make_full_tree(
[
(self.data["humanbot"], 3e5),
(self.data["prompts"], 1e5),
(self.data["templated"][:100000], 1),
]
)
self.full_tree = ftr
else:
full_tree, tr_i2w = full_tree_voc
self.full_tree = full_tree
spec_tokens = ["[PAD]", "unused", "[UNK]", "[CLS]", "[SEP]", "[MASK]", "<S>", "</S>"]
self.tree_voc = spec_tokens[:] + tr_i2w
self.tree_idxs = dict([(w, i) for i, w in enumerate(self.tree_voc)])
self.dataset_length = max([len(v) for v in self.data.values()])
if args.examples_per_epoch > 0:
self.dataset_length = min(self.dataset_length, args.examples_per_epoch)
def _contains_span_indices(self, token_idx_list: list):
return token_idx_list[1] >= 0 and token_idx_list[2] >= 0
def __len__(self):
return self.dataset_length
def __getitem__(self, idx):
# sample data type and get example
if self.sampling:
dtype = np.random.choice(self.dtypes, p=self.sample_probas)
if len(self.data[dtype]) == 0:
dtype = self.dtype
else:
dtype = self.dtype
try:
t = self.data[dtype][idx % len(self.data[dtype])]
p_text, p_tree = t
except ValueError as e:
print(e)
text, tree = tokenize_linearize(
p_text, p_tree, self.tokenizer, self.full_tree, self.word_noise
)
text_idx_ls = [self.tokenizer._convert_token_to_id(w) for w in text.split()]
tree_idx_ls = [
[self.tree_idxs[w], bi, ei, text_span_start, text_span_end]
for w, bi, ei, text_span_start, text_span_end in [("<S>", -1, -1, -1, -1)]
+ tree
+ [("</S>", -1, -1, -1, -1)]
]
if self.tree_to_text:
stripped_tree_tokens = []
for w, bi, ei in tree:
tree_node = w.lower()
tree_node_processed = re.sub("[^0-9a-zA-Z]+", " ", tree_node)
tree_tokens = tree_node_processed.split(" ")
stripped_tree_tokens += [x for x in tree_tokens if x != ""]
extended_tree = ["[CLS]"] + stripped_tree_tokens + ["[SEP]"]
tree_idx_ls = [self.tokenizer._convert_token_to_id(w) for w in extended_tree]
return (text_idx_ls, tree_idx_ls, (text, p_text, p_tree))
def add_hard_example(self, exple):
if self.hard_buffer_counter < self.hard_buffer_size:
self.data["hard"] += [exple]
else:
self.data["hard"][self.hard_buffer_counter % self.hard_buffer_size] = exple
self.hard_buffer_counter += 1
# applies padding and makes batch tensors
def caip_collate(batch, tokenizer, tree_to_text=False):
# keep track of examples
pre_examples = [(p_text, p_tree) for x, y, (_, p_text, p_tree) in batch]
# input: text
batch_x_ls = [x for x, y, _ in batch]
x_len = max([len(x) for x in batch_x_ls])
x_mask_ls = [[1] * len(x) + [0] * (x_len - len(x)) for x in batch_x_ls]
batch_x_pad_ls = [x + [tokenizer.pad_token_id] * (x_len - len(x)) for x in batch_x_ls]
# output: linearized trees
batch_y_ls = [y for x, y, _ in batch]
y_len = max([len(y) for y in batch_y_ls])
y_mask_ls = [[1] * len(y) + [0] * (y_len - len(y)) for y in batch_y_ls]
if tree_to_text:
batch_y_pad_ls = [
y + [tokenizer.pad_token_id] * (y_len - len(y)) for y in batch_y_ls
] # 0 as padding idx
else:
batch_y_pad_ls = [
y + [[0, -1, -1, -1, -1]] * (y_len - len(y)) for y in batch_y_ls
] # 0 as padding idx
# tensorize
x = torch.tensor(batch_x_pad_ls)
x_mask = torch.tensor(x_mask_ls)
y = torch.tensor(batch_y_pad_ls)
y_mask = torch.tensor(y_mask_ls)
return (x, x_mask, y, y_mask, pre_examples)
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/utils_caip.py |
import argparse
import os
import random
import math
from typing import *
def partition_dataset(k: int, data_path: str, output_dir: str):
"""
Split dataset into k partitions.
"""
# Read in annotated dataset
full_dataset = open(data_path + "annotated_data_text_spans.txt").readlines()
print("Length of dataset: {} lines".format(len(full_dataset)))
# shuffle
random.shuffle(full_dataset)
chunk_size = int(math.ceil(len(full_dataset) / float(k)))
print("k is {}".format(k))
print("Chunk size: {}".format(chunk_size))
start_idx = 0
# Split into k chunks
for i in range(k):
end_idx = start_idx + chunk_size
chunk_i = full_dataset[start_idx : min(end_idx, len(full_dataset))]
print("Length of chunk {}: {}".format(i, len(chunk_i)))
partition_path = output_dir + "chunk_{}/".format(i)
if not os.path.isdir(partition_path):
os.mkdir(partition_path)
with open(partition_path + "annotated.txt", "w") as fd:
for line in chunk_i:
fd.write(line)
start_idx += chunk_size
def create_train_valid_split(chunk_index: int, k: int, data_dir: str, output_dir: str):
"""Create partitions for k fold Cross Validation
Given a chunk index for the valid set, create train and valid split from k chunks of the dataset.
Chunk index is a an index in the range 0 to k.
"""
# Read from other chunks and write txt file to train/ dir
train_dataset: List[Dict] = []
valid_dataset: List[Dict] = []
for i in range(k):
# Use this as the validation set
if i == chunk_index:
valid_dataset += open(data_dir + "chunk_{}/annotated.txt".format(i)).readlines()
else:
train_dataset += open(data_dir + "chunk_{}/annotated.txt".format(i)).readlines()
# Write to train and valid directories
directories: List[str] = ["/", "train/", "valid/"]
for d in directories:
if not os.path.isdir(output_dir + d):
os.mkdir(output_dir + d)
print(
"Writing {} entries to {}".format(len(train_dataset), output_dir + "train/annotated.txt")
)
with open(output_dir + "train/annotated.txt", "w") as fd:
for line in train_dataset:
fd.write(line)
print(
"Writing {} entries to {}".format(len(valid_dataset), output_dir + "valid/annotated.txt")
)
with open(output_dir + "valid/annotated.txt", "w") as fd:
for line in valid_dataset:
fd.write(line)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default="/checkpoint/rebeccaqian/datasets/06_24/",
type=str,
help="Contains the full dataset to partition",
)
parser.add_argument(
"--output_dir",
default="/checkpoint/rebeccaqian/datasets/06_24/",
type=str,
help="Directory to write data partitions for CV runs",
)
parser.add_argument(
"-k", default=10, type=int, help="Number of partitions in leave-k-out-cross-validation."
)
args = parser.parse_args()
partition_dataset(args.k, args.data_dir, args.output_dir)
for valid_partition_idx in range(args.k):
chunk_path = args.output_dir + "run_{}/".format(valid_partition_idx)
if not os.path.isdir(chunk_path):
os.mkdir(chunk_path)
output_dir = chunk_path
create_train_valid_split(valid_partition_idx, args.k, args.data_dir, output_dir)
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/gen_cross_valid_chunks.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import Adam, Adagrad
from transformers.modeling_bert import BertModel, BertOnlyMLMHead
from utils_caip import *
# --------------------------
# Transformer-based decoder module for sequence ans span prediction, computes the loss
# --------------------------
def my_xavier_init(m, gain=1):
for p in m.parameters():
if p.dim() > 1:
nn.init.xavier_uniform_(p, gain)
else:
nn.init.constant_(p, 0)
class HighwayLayer(torch.nn.Module):
def __init__(self, dim):
super(HighwayLayer, self).__init__()
self.gate_proj = nn.Linear(dim, dim, bias=True)
self.nlin_proj = nn.Linear(dim, dim, bias=True)
my_xavier_init(self.nlin_proj)
my_xavier_init(self.gate_proj)
nn.init.constant_(self.gate_proj.bias, -1)
def forward(self, x):
gate = torch.sigmoid(self.gate_proj(x))
nlin = torch.tanh(self.nlin_proj(x))
res = gate * nlin + (1 - gate) * x
return res
# single module to predict the output sequence and compute the
# loss if the target sequence is provided for convenience
class DecoderWithLoss(nn.Module):
def __init__(self, config, args, tokenizer):
super(DecoderWithLoss, self).__init__()
# model components
print("initializing decoder with params {}".format(args))
self.bert = BertModel(config)
self.lm_head = BertOnlyMLMHead(config)
self.span_b_proj = nn.ModuleList([HighwayLayer(768) for _ in range(args.num_highway)])
self.span_e_proj = nn.ModuleList([HighwayLayer(768) for _ in range(args.num_highway)])
# TODO: check dimensions for span head
# predict text span beginning and end
self.text_span_start_head = nn.Linear(768, 768)
self.text_span_end_head = nn.Linear(768, 768)
# loss functions
if args.node_label_smoothing > 0:
self.lm_ce_loss = LabelSmoothingLoss(
args.node_label_smoothing, config.vocab_size, ignore_index=tokenizer.pad_token_id
)
else:
self.lm_ce_loss = torch.nn.CrossEntropyLoss(
ignore_index=tokenizer.pad_token_id, reduction="none"
)
self.span_ce_loss = torch.nn.CrossEntropyLoss(ignore_index=-1, reduction="none")
self.span_loss_lb = args.lambda_span_loss
self.text_span_loss = torch.nn.CrossEntropyLoss(ignore_index=-1, reduction="none")
self.tree_to_text = args.tree_to_text
# without loss, use at prediction time
# TODO: add previously computed y_rep
# y only has the node indices (not the spans)
# Used in eval only
def step(self, y, y_mask, x_reps, x_mask):
y_rep = self.bert(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
)[0]
y_mask_target = y_mask
lm_scores = self.lm_head(y_rep)
y_span_pre_b = y_rep
for hw in self.span_b_proj:
y_span_pre_b = hw(y_span_pre_b)
span_b_scores = (x_reps[:, None, :, :] * y_span_pre_b[:, :, None, :]).sum(dim=-1)
span_b_scores = (
span_b_scores + (1 - y_mask_target.type_as(span_b_scores))[:, :, None] * 1e9
)
y_span_pre_e = y_rep
for hw in self.span_e_proj:
y_span_pre_e = hw(y_span_pre_e)
span_e_scores = (x_reps[:, None, :, :] * y_span_pre_e[:, :, None, :]).sum(dim=-1)
span_e_scores = (
span_e_scores + (1 - y_mask_target.type_as(span_e_scores))[:, :, None] * 1e9
)
# text span prediction
# detach head
text_span_start_hidden_z = y_rep.detach()
text_span_end_hidden_z = y_rep.detach()
# get predicted values
text_span_start_out = self.text_span_start_head(text_span_start_hidden_z)
text_span_start_scores = (x_reps[:, None, :, :] * text_span_start_out[:, :, None, :]).sum(
dim=-1
)
text_span_start_scores = (
text_span_start_scores
+ (1 - y_mask_target.type_as(text_span_start_scores))[:, :, None] * 1e9
)
# text span end prediction
text_span_end_out = self.text_span_end_head(text_span_end_hidden_z)
text_span_end_scores = (x_reps[:, None, :, :] * text_span_end_out[:, :, None, :]).sum(
dim=-1
)
text_span_end_scores = (
text_span_end_scores
+ (1 - y_mask_target.type_as(text_span_end_scores))[:, :, None] * 1e9
)
res = {
"lm_scores": torch.log_softmax(lm_scores, dim=-1).detach(),
"span_b_scores": torch.log_softmax(span_b_scores, dim=-1).detach(),
"span_e_scores": torch.log_softmax(span_e_scores, dim=-1).detach(),
"text_span_start_scores": torch.log_softmax(text_span_start_scores, dim=-1).detach(),
"text_span_end_scores": torch.log_softmax(text_span_end_scores, dim=-1).detach(),
}
return res
def forward(self, y, y_mask, x_reps, x_mask):
if self.tree_to_text:
bert_model = self.bert(
input_ids=y,
attention_mask=y_mask,
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
)
y_rep = bert_model[0]
y_mask_target = y_mask.contiguous()
# language modeling
lm_scores = self.lm_head(y_rep)
lm_lin_scores = lm_scores.view(-1, lm_scores.shape[-1])
lm_lin_targets = y.contiguous().view(-1)
lm_lin_loss = self.lm_ce_loss(lm_lin_scores, lm_lin_targets)
lm_lin_mask = y_mask_target.view(-1)
lm_loss = lm_lin_loss.sum() / lm_lin_mask.sum()
res = {"lm_scores": lm_scores, "loss": lm_loss}
else:
model_out = self.bert(
input_ids=y[:, :-1, 0],
attention_mask=y_mask[:, :-1],
encoder_hidden_states=x_reps,
encoder_attention_mask=x_mask,
)
y_rep = model_out[0]
y_rep.retain_grad()
self.bert_final_layer_out = y_rep
y_mask_target = y_mask[:, 1:].contiguous()
# language modeling
lm_scores = self.lm_head(y_rep)
lm_lin_scores = lm_scores.view(-1, lm_scores.shape[-1])
lm_lin_targets = y[:, 1:, 0].contiguous().view(-1)
lm_lin_loss = self.lm_ce_loss(lm_lin_scores, lm_lin_targets)
lm_lin_mask = y_mask_target.view(-1)
lm_loss = lm_lin_loss.sum() / lm_lin_mask.sum()
# span prediction
## beginning of spans
y_span_pre_b = y_rep
for hw in self.span_b_proj:
y_span_pre_b = hw(y_span_pre_b)
span_b_scores = (x_reps[:, None, :, :] * y_span_pre_b[:, :, None, :]).sum(dim=-1)
span_b_scores = (
span_b_scores + (1 - y_mask_target.type_as(span_b_scores))[:, :, None] * 1e9
)
span_b_lin_scores = span_b_scores.view(-1, x_reps.shape[1])
span_b_lin_targets = y[:, 1:, 1].contiguous().view(-1)
span_b_lin_loss = self.span_ce_loss(span_b_lin_scores, span_b_lin_targets)
## end of spans
y_span_pre_e = y_rep
for hw in self.span_e_proj:
y_span_pre_e = hw(y_span_pre_e)
span_e_scores = (x_reps[:, None, :, :] * y_span_pre_e[:, :, None, :]).sum(dim=-1)
span_e_scores = (
span_e_scores + (1 - y_mask_target.type_as(span_e_scores))[:, :, None] * 1e9
)
span_e_lin_scores = span_e_scores.view(-1, span_e_scores.shape[-1])
span_e_lin_targets = y[:, 1:, 2].contiguous().view(-1)
span_e_lin_loss = self.span_ce_loss(span_e_lin_scores, span_e_lin_targets)
## joint span prediction
# TODO: predict full spans, enforce order
# combine
span_lin_loss = span_b_lin_loss + span_e_lin_loss
span_loss = span_lin_loss.sum() / (y[:, :, 1] >= 0).sum()
tot_loss = (1 - self.span_loss_lb) * lm_loss + self.span_loss_lb * span_loss
# text span prediction
# detach head
y_rep.retain_grad()
self.text_span_start_hidden_z = y_rep.detach()
self.text_span_end_hidden_z = y_rep.detach()
self.text_span_start_hidden_z.requires_grad = True
self.text_span_end_hidden_z.requires_grad = True
self.text_span_start_hidden_z.retain_grad()
self.text_span_end_hidden_z.retain_grad()
# get predicted values
self.text_span_start_out = self.text_span_start_head(self.text_span_start_hidden_z)
text_span_start_scores = (
x_reps[:, None, :, :] * self.text_span_start_out[:, :, None, :]
).sum(dim=-1)
text_span_start_lin_scores = text_span_start_scores.view(
-1, text_span_start_scores.shape[-1]
)
text_span_start_targets = y[:, 1:, 3].contiguous().view(-1)
text_span_start_lin_loss = self.text_span_loss(
text_span_start_lin_scores, text_span_start_targets
)
text_span_start_loss = text_span_start_lin_loss.sum() / (y[:, :, 3] >= 0).sum()
# text span end prediction
text_span_end_out = self.text_span_end_head(self.text_span_end_hidden_z)
text_span_end_scores = (x_reps[:, None, :, :] * text_span_end_out[:, :, None, :]).sum(
dim=-1
)
text_span_end_lin_scores = text_span_end_scores.view(
-1, text_span_end_scores.shape[-1]
)
text_span_end_targets = y[:, 1:, 4].contiguous().view(-1)
text_span_end_lin_loss = self.text_span_loss(
text_span_end_lin_scores, text_span_end_targets
)
text_span_end_loss = text_span_end_lin_loss.sum() / (y[:, :, 4] >= 0).sum()
text_span_lin_loss = text_span_start_loss + text_span_end_loss
text_span_loss = text_span_lin_loss.sum() / (y[:, :, 3] >= 0).sum()
res = {
"lm_scores": lm_scores,
"span_b_scores": span_b_scores,
"span_e_scores": span_e_scores,
"loss": tot_loss,
# TODO: placeholder for now
"text_span_start_scores": text_span_start_scores,
"text_span_end_scores": text_span_end_scores,
"text_span_loss": text_span_loss,
}
return res
# combines DecoderWithLoss with pre-trained BERT encoder
class EncoderDecoderWithLoss(nn.Module):
def __init__(self, encoder, decoder, args):
super(EncoderDecoderWithLoss, self).__init__()
self.encoder = encoder
self.decoder = decoder
self.train_encoder = args.train_encoder
def forward(self, x, x_mask, y, y_mask, x_reps=None):
if x_reps is None:
model = self.encoder(input_ids=x, attention_mask=x_mask)
x_reps = model[0]
if not self.train_encoder:
x_reps = x_reps.detach()
outputs = self.decoder(y, y_mask, x_reps, x_mask)
return outputs
# raw text input, tree output
# DEPRECATED: use beam search
def predict_tree(txt, model, tokenizer, dataset, ban_noop=False, noop_threshold=0.0):
model_device = model.decoder.lm_head.predictions.decoder.weight.device
# prepare batch
text, idx_maps = tokenize_mapidx(txt, tokenizer)
tree = [("<S>", -1, -1)]
text_idx_ls = [dataset.tokenizer._convert_token_to_id(w) for w in text.split()]
tree_idx_ls = [[dataset.tree_idxs[w], bi, ei] for w, bi, ei in tree]
pre_batch = [(text_idx_ls, tree_idx_ls, (text, txt, {}))]
batch = caip_collate(pre_batch, tokenizer)
batch = [t.to(model_device) for t in batch[:4]]
x, x_mask, y, y_mask = batch
y = y[:, :, 0]
x_reps = model.encoder(input_ids=x, attention_mask=x_mask)[0].detach()
res = [("<S>", -1, -1)]
next_id = -1
noop_predicted = False
for i in range(100):
if i > 0:
y = torch.cat([y, torch.LongTensor([[next_id]]).to(model_device)], dim=1)
y_mask = torch.cat(
[y_mask, torch.LongTensor([1]).unsqueeze(dim=0).to(model_device)], dim=1
)
outputs = model.decoder.step(y, y_mask, x_reps, x_mask)
# next word
lm_scores = outputs["lm_scores"]
s_lm_scores, s_lm_ids = lm_scores[0, -1].sort(dim=-1, descending=True)
next_id = s_lm_ids[0].item()
if "NOOP" in dataset.tree_voc[next_id]:
if ban_noop or s_lm_scores[0].item() < noop_threshold:
next_id = s_lm_ids[1].item()
noop_predicted = True
print("---- replacing NOOP with", dataset.tree_voc[next_id])
next_w = dataset.tree_voc[next_id]
# predicted span
span_b_scores = outputs["span_b_scores"]
span_e_scores = outputs["span_e_scores"]
_, s_sb_ids = span_b_scores[0, -1].sort(dim=-1, descending=True)
_, s_se_ids = span_e_scores[0, -1].sort(dim=-1, descending=True)
b_id = s_sb_ids[0].item()
e_id = s_se_ids[0].item()
res += [(next_w, b_id, e_id)]
if next_w == "</S>":
break
# only keep span predictions for span nodes, then map back to tree
res = [(w, b, e) if w.startswith("BE:") else (w, -1, -1) for w, b, e in res]
idx_rev_map = [(0, 0)] * len(text.split())
for line_id, idx_map in enumerate(idx_maps):
for pre_id, (a, b) in enumerate(idx_map):
idx_rev_map[a] = (line_id, pre_id)
idx_rev_map[b] = (line_id, pre_id)
idx_rev_map[-1] = idx_rev_map[-2]
res_tree, _ = seq_to_tree(dataset.full_tree, res[1:-1], idx_rev_map)
return (res_tree, noop_predicted, (text, res))
# beam prediction. Only uses node prediction scores (not the span scores)
def beam_search(txt, model, tokenizer, dataset, beam_size=5, well_formed_pen=1e2):
model_device = model.decoder.lm_head.predictions.decoder.weight.device
# prepare batch
text, idx_maps = tokenize_mapidx(txt, tokenizer)
idx_rev_map = [(0, 0)] * len(text.split())
for line_id, idx_map in enumerate(idx_maps):
for pre_id, (a, b) in enumerate(idx_map):
idx_rev_map[a] = (line_id, pre_id)
idx_rev_map[b] = (line_id, pre_id)
idx_rev_map[-1] = idx_rev_map[-2]
tree = [("<S>", -1, -1, -1, -1)]
text_idx_ls = [dataset.tokenizer._convert_token_to_id(w) for w in text.split()]
tree_idx_ls = [
[dataset.tree_idxs[w], bi, ei, text_span_bi, text_span_ei]
for w, bi, ei, text_span_bi, text_span_ei in tree
]
pre_batch = [(text_idx_ls, tree_idx_ls, (text, txt, {}))]
batch = caip_collate(pre_batch, tokenizer)
batch = [t.to(model_device) for t in batch[:4]]
x, x_mask, y, y_mask = batch
x_reps = model.encoder(input_ids=x, attention_mask=x_mask)[0].detach()
x_mask = x_mask.expand(beam_size, -1)
x_reps = x_reps.expand(beam_size, -1, -1)
# start decoding
y = torch.LongTensor([[dataset.tree_idxs["<S>"]] for _ in range(beam_size)]).to(
model_device
) # B x 1
beam_scores = torch.Tensor([-1e9 for _ in range(beam_size)]).to(model_device) # B
beam_scores[0] = 0
beam_seqs = [[("<S>", -1, -1, -1, -1)] for _ in range(beam_size)]
finished = [False for _ in range(beam_size)]
pad_scores = torch.Tensor([-1e9] * len(dataset.tree_voc)).to(model_device)
pad_scores[dataset.tree_idxs["[PAD]"]] = 0
for i in range(100):
outputs = model.decoder.step(y, y_mask, x_reps, x_mask)
# next word
lm_scores = outputs["lm_scores"][:, -1, :] # B x V
for i, fshed in enumerate(finished):
if fshed:
lm_scores[i] = pad_scores
beam_lm_scores = lm_scores + beam_scores[:, None] # B x V
beam_lm_lin = beam_lm_scores.view(-1)
s_scores, s_ids = beam_lm_lin.sort(dim=-1, descending=True)
s_beam_ids = s_ids // beam_lm_scores.shape[-1]
s_word_ids = s_ids % beam_lm_scores.shape[-1]
# re-order and add next token
beam_scores = s_scores[:beam_size]
n_beam_ids = s_beam_ids[:beam_size]
n_word_ids = s_word_ids[:beam_size]
n_words = [dataset.tree_voc[nw_id.item()] for nw_id in n_word_ids]
y = torch.cat([y[n_beam_ids], n_word_ids[:, None]], dim=1)
# find out which of the beams are finished
pre_finished = [finished[b_id.item()] for b_id in n_beam_ids]
new_finished = [w_id.item() == dataset.tree_idxs["</S>"] for w_id in n_word_ids]
finished = [p or n for p, n in zip(pre_finished, new_finished)]
n_mask = 1 - torch.Tensor(finished).type_as(y_mask)
y_mask = torch.cat([y_mask[n_beam_ids], n_mask[:, None]], dim=1)
# predicted span
span_b_scores = outputs["span_b_scores"][:, -1, :][n_beam_ids] # B x T
span_e_scores = outputs["span_e_scores"][:, -1, :][n_beam_ids] # B x T
span_be_scores = span_b_scores[:, :, None] + span_e_scores[:, None, :]
invalid_scores = torch.tril(torch.ones(span_be_scores.shape), diagonal=-1) * -1e9
span_be_scores += invalid_scores.type_as(span_be_scores)
span_be_lin = span_be_scores.view(span_be_scores.shape[0], -1)
_, s_sbe_ids = span_be_lin.sort(dim=-1, descending=True)
s_sb_ids = s_sbe_ids[:, 0] // span_b_scores.shape[-1]
s_se_ids = s_sbe_ids[:, 0] % span_b_scores.shape[-1]
beam_b_ids = [bb_id.item() for bb_id in s_sb_ids]
beam_e_ids = [be_id.item() for be_id in s_se_ids]
# predict text spans
text_span_start_scores = outputs["text_span_start_scores"][:, -1, :][n_beam_ids] # B x T
text_span_end_scores = outputs["text_span_end_scores"][:, -1, :][n_beam_ids] # B x T
text_span_scores = text_span_start_scores[:, :, None] + text_span_end_scores[:, None, :]
invalid_text_span_scores = (
torch.tril(torch.ones(text_span_scores.shape), diagonal=-1) * -1e9
)
text_span_scores += invalid_text_span_scores.type_as(text_span_scores)
text_span_lin_scores = text_span_scores.view(text_span_scores.shape[0], -1)
_, text_span_ids = text_span_lin_scores.sort(dim=-1, descending=True)
text_span_start_ids = text_span_ids[:, 0] // text_span_start_scores.shape[-1]
text_span_end_ids = text_span_ids[:, 0] % text_span_start_scores.shape[-1]
text_span_beam_start_ids = [bb_id.item() for bb_id in text_span_start_ids]
text_span_beam_end_ids = [be_id.item() for be_id in text_span_end_ids]
# update beam_seq
beam_seqs = [
beam_seqs[n_beam_ids[i].item()]
+ [
(
n_words[i],
beam_b_ids[i],
beam_e_ids[i],
text_span_beam_start_ids[i],
text_span_beam_end_ids[i],
)
]
for i in range(beam_size)
]
# penalize poorly formed trees
for i, seq in enumerate(beam_seqs):
if seq[-1][0] == "</S>":
_, well_formed = select_spans(seq)
if not well_formed:
beam_scores[i] -= well_formed_pen
# check whether all beams have reached EOS
if all(finished):
break
# only keep span predictions for span nodes, then map back to tree
beam_seqs = [
[
(w, b, e, -1, -1)
if w.startswith("BE:")
else (w, -1, -1, text_span_start, text_span_end)
for w, b, e, text_span_start, text_span_end in res
if w != "[PAD]"
]
for res in beam_seqs
]
beam_seqs = [
[
(w, -1, -1, text_span_start, text_span_end)
if w.startswith("TBE:")
else (w, b, e, -1, -1)
for w, b, e, text_span_start, text_span_end in res
if w != "[PAD]"
]
for res in beam_seqs
]
# delinearize predicted sequences into tree
beam_trees = [seq_to_tree(dataset.full_tree, res[1:-1], idx_rev_map)[0] for res in beam_seqs]
pre_res = [
(tree, score.item(), seq) for tree, score, seq in zip(beam_trees, beam_scores, beam_seqs)
]
# sort one last time to have well-formed trees on top
res = sorted(pre_res, key=lambda x: x[1], reverse=True)
return res
# util function for validation and selecting hard examples
def compute_accuracy(outputs, y):
if len(y.shape) == 2:
lm_targets = y
else:
lm_targets = y[:, 1:, 0]
lm_preds = outputs["lm_scores"].max(dim=-1)[1]
lm_acc = ((lm_preds == lm_targets) * (lm_targets > 6)).sum(dim=1) == (lm_targets > 6).sum(
dim=1
)
if "span_b_scores" in outputs:
sb_targets = y[:, 1:, 1]
sb_preds = outputs["span_b_scores"].max(dim=-1)[1]
sb_acc = ((sb_preds == sb_targets) * (sb_targets >= 0)).sum(dim=1) == (
sb_targets >= 0
).sum(dim=1)
se_targets = y[:, 1:, 2]
se_preds = outputs["span_e_scores"].max(dim=-1)[1]
se_acc = ((se_preds == se_targets) * (se_targets >= 0)).sum(dim=1) == (
se_targets >= 0
).sum(dim=1)
sp_acc = sb_acc * se_acc
full_acc = lm_acc * sp_acc
if "text_span_start_scores" in outputs:
text_span_b_targets = y[:, 1:, 3]
text_span_e_targets = y[:, 1:, 4]
text_span_b_pred = outputs["text_span_start_scores"].max(dim=-1)[1]
text_span_e_pred = outputs["text_span_end_scores"].max(dim=-1)[1]
text_span_b_acc = (
(text_span_b_pred == text_span_b_targets) * (text_span_b_targets >= 0)
).sum(dim=1) == (text_span_b_targets >= 0).sum(dim=1)
text_span_e_acc = (
(text_span_e_pred == text_span_e_targets) * (text_span_e_targets >= 0)
).sum(dim=1) == (text_span_e_targets >= 0).sum(dim=1)
text_span_acc = text_span_b_acc * text_span_e_acc
return (lm_acc, sp_acc, text_span_acc, full_acc)
else:
return (lm_acc, sp_acc, full_acc)
else:
return lm_acc
# --------------------------
# Custom wrapper for Adam optimizer,
# handles lr warmup and smaller lr for encoder fine-tuning
# --------------------------
class OptimWarmupEncoderDecoder(object):
def __init__(self, model, args):
self.encoder = model.encoder
self.decoder = model.decoder
self.lr = {
"encoder": args.encoder_learning_rate,
"decoder": args.decoder_learning_rate,
"text_span_decoder": args.decoder_learning_rate,
}
self.warmup_steps = {
"encoder": args.encoder_warmup_steps,
"decoder": args.decoder_warmup_steps,
"text_span_decoder": args.decoder_warmup_steps,
}
if args.optimizer == "adam":
self.optimizers = {
"encoder": Adam(model.encoder.parameters(), lr=self.lr["encoder"]),
"decoder": Adam(model.decoder.parameters(), lr=self.lr["decoder"]),
"text_span_decoder": Adam(
model.decoder.parameters(), lr=self.lr["text_span_decoder"]
),
}
elif args.optimizer == "adagrad":
self.optimizers = {
"encoder": Adagrad(model.encoder.parameters(), lr=self.lr["encoder"]),
"decoder": Adagrad(model.decoder.parameters(), lr=self.lr["decoder"]),
"text_span_decoder": Adam(
model.decoder.parameters(), lr=self.lr["text_span_decoder"]
),
}
else:
raise NotImplementedError
self._step = 0
def _update_rate(self, stack):
return self.lr[stack] * min(
(self._step / self.warmup_steps[stack]), (self._step / self.warmup_steps[stack]) ** 0.5
)
def zero_grad(self):
self.optimizer_decoder.zero_grad()
self.optimizer_encoder.zero_grad()
def step(self):
self._step += 1
for stack, optimizer in self.optimizers.items():
new_rate = self._update_rate(stack)
for param_group in optimizer.param_groups:
param_group["lr"] = new_rate
optimizer.step()
# --------------------------
# Label smoothing loss
# --------------------------
class LabelSmoothingLoss(nn.Module):
"""
With label smoothing,
KL-divergence between q_{smoothed ground truth prob.}(w)
and p_{prob. computed by model}(w) is minimized.
"""
def __init__(self, label_smoothing, tgt_vocab_size, ignore_index=-1):
assert 0.0 <= label_smoothing <= 1.0
super(LabelSmoothingLoss, self).__init__()
self.ignore_index = ignore_index
self.voc_size = tgt_vocab_size
if ignore_index >= 0:
self.smoothing = label_smoothing / (tgt_vocab_size - 2)
else:
self.smoothing = label_smoothing / (tgt_vocab_size - 1)
self.confidence = 1.0 - label_smoothing
def forward(self, output, target):
"""
output (FloatTensor): batch_size x n_classes
target (LongTensor): batch_size
"""
with torch.no_grad():
s_target = torch.zeros_like(output)
s_target.fill_(self.smoothing)
if self.ignore_index >= 0:
s_target[:, self.ignore_index] = 0
t_cap = target.masked_fill(target == self.ignore_index, 0)
s_target.scatter_(1, t_cap.unsqueeze(1), self.confidence)
kl_div = F.kl_div(output.log_softmax(dim=-1), s_target, reduction="none")
kl_mask = (target != self.ignore_index).type_as(kl_div).unsqueeze(1)
return (kl_div * kl_mask).sum(dim=-1)
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/utils_parsing.py |
import json
import math
import pickle
import torch
from transformers import AutoModel, AutoTokenizer, BertConfig
from utils_parsing import *
from utils_caip import *
from train_model import *
class TTADBertModel(object):
def __init__(self, model_dir, data_dir, model_name="caip_test_model"):
model_name = model_dir + model_name
args = pickle.load(open(model_name + "_args.pk", "rb"))
args.data_dir = data_dir
self.tokenizer = AutoTokenizer.from_pretrained(args.pretrained_encoder_name)
full_tree, tree_i2w = json.load(open(model_name + "_tree.json"))
self.dataset = CAIPDataset(
self.tokenizer, args, prefix="", full_tree_voc=(full_tree, tree_i2w)
)
enc_model = AutoModel.from_pretrained(args.pretrained_encoder_name)
bert_config = BertConfig.from_pretrained("bert-base-uncased")
bert_config.is_decoder = True
bert_config.vocab_size = len(tree_i2w) + 8
bert_config.num_hidden_layers = args.num_decoder_layers
dec_with_loss = DecoderWithLoss(bert_config, args, self.tokenizer)
self.encoder_decoder = EncoderDecoderWithLoss(enc_model, dec_with_loss, args)
map_location = None if torch.cuda.is_available() else torch.device("cpu")
self.encoder_decoder.load_state_dict(
torch.load(model_name + ".pth", map_location=map_location), strict=False
)
self.encoder_decoder = (
self.encoder_decoder.cuda()
if torch.cuda.is_available()
else self.encoder_decoder.cpu()
)
self.encoder_decoder.eval()
def parse(self, chat, noop_thres=0.95, beam_size=5, well_formed_pen=1e2):
btr = beam_search(
chat, self.encoder_decoder, self.tokenizer, self.dataset, beam_size, well_formed_pen
)
if btr[0][0].get("dialogue_type", "NONE") == "NOOP" and math.exp(btr[0][1]) < noop_thres:
tree = btr[1][0]
else:
tree = btr[0][0]
return tree
| craftassist-master | python/base_agent/ttad/ttad_transformer_model/query_model.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import os
from emnlp_model import *
from typing import Sequence, Dict
THIS_DIR = os.path.dirname(__file__)
class ActionDictBuilder(object):
def __init__(
self,
model_path=THIS_DIR + "/../../models/semantic_parser/ttad/ttad.pth",
embeddings_path=THIS_DIR + "/../../models/semantic_parser/ttad/ttad_ft_embeds.pth",
action_tree_path=THIS_DIR + "/../../models/semantic_parser/ttad/dialogue_grammar.json",
cuda=False,
):
model, loss, w2i, args = load_model(
model_path=model_path,
embeddings_path=embeddings_path,
action_tree_path=action_tree_path,
use_cuda=cuda,
)
self.model = model
self.loss = loss
self.w2i = w2i
self.args = args
def parse(self, chat_list: Sequence[str]):
action_dict = predict_tree(self.model, chat_list, self.w2i, self.args)
self._remove_not_implemented(action_dict)
return action_dict
def _remove_not_implemented(self, d: Dict):
c = d.copy()
for k, v in c.items():
if v == "NOT_IMPLEMENTED":
del d[k]
elif type(v) == dict:
self._remove_not_implemented(v)
| craftassist-master | python/base_agent/ttad/ttad_model/ttad_model_wrapper.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import argparse
import logging
import logging.handlers
import os
import pickle
TTAD_MODEL_DIR = os.path.dirname(os.path.realpath(__file__))
TTAD_DATA_DIR = os.path.join(TTAD_MODEL_DIR, "../data/ttad_model/")
from time import time
import torch.optim as optim
from emnlp_model import *
from ttad_model_wrapper import *
def main():
parser = argparse.ArgumentParser(description="Train text to action dictionary model")
parser.add_argument("-cuda", "--cuda", action="store_true", help="use GPU to train")
parser.add_argument(
"-mn",
"--model_name",
default=TTAD_DATA_DIR + "models/tree_model",
type=str,
metavar="S",
help="torch formatted model file to save",
)
parser.add_argument(
"-rp",
"--rephrase_proba",
default=0.4,
type=float,
metavar="D",
help="proportion of rephrased training data 0 <= r <= 1",
)
# data sampling arguments
parser.add_argument(
"-rsm",
"--resample_mode",
default="action-type",
type=str,
metavar="S",
help="re-sample train and valid data to match [none|action-type|tree-internal|tree-full] distribution",
)
parser.add_argument(
"-rst",
"--resample_type",
default="humanbot",
type=str,
metavar="S",
help="re-sample train and valid data to match [rephrased|prompts|humanbot|templated] distribution",
)
parser.add_argument(
"-hbp",
"--hard_buffer_proba",
default=0.3,
type=float,
metavar="D",
help="proportion of training batch examples from hard examples buffer 0 <= r <= 1",
)
parser.add_argument(
"-hbs",
"--hard_buffer_size",
default=2048,
type=int,
metavar="N",
help="proportion of training batch examples from hard examples buffer 0 <= r <= 1",
)
# file locations
parser.add_argument(
"-toe",
"--train_on_everything",
action="store_true",
help="train on validation and test set too",
)
parser.add_argument(
"-df",
"--data_file",
default=TTAD_DATA_DIR + "dialogue_data.json",
type=str,
metavar="S",
help="location of json file with all taining, valid and test data",
)
parser.add_argument(
"-atf",
"--action_tree_file",
default=TTAD_DATA_DIR + "dialogue_grammar.json",
type=str,
metavar="S",
help="action tree that covers all of the data (including OtherAction)",
)
parser.add_argument(
"-ftmf",
"--ft_model_file",
default=TTAD_DATA_DIR + "minecraft_newdct_ft_embeds.pth",
type=str,
metavar="S",
help="pre-trained pre-computed subword-aware fasttext embeddings and vocabulary",
)
# model arguments
parser.add_argument("-cn", "--collapse_nodes", action="store_true", help="parameter sharing")
parser.add_argument(
"-led",
"--learn_embed_dim",
default=0,
type=int,
metavar="N",
help="concatenate learned embeddings to FastText pretained of dimension",
)
parser.add_argument(
"-learn_embeds",
"--learn_embeds",
action="store_true",
help="learn word embeddings from scratch",
)
parser.add_argument(
"-rec",
"--recursion",
default="sentence-rec",
type=str,
help="type of recursion for the prediction model in"
"[none|top-down|dfs-intern|dfs-all|sentence-rec]",
)
parser.add_argument(
"-md", "--model_dim", default=256, type=int, metavar="N", help="model dimension"
)
parser.add_argument(
"-sh",
"--sent_heads",
default=4,
type=int,
metavar="N",
help="number of sentence attention heads",
)
parser.add_argument(
"-th",
"--tree_heads",
default=4,
type=int,
metavar="N",
help="number of tree context attention heads",
)
parser.add_argument(
"-sec",
"--sentence_encoder",
default="bigru",
type=str,
help="type of sentence encoder [convolution|bigru]",
)
parser.add_argument(
"-scl",
"--sent_conv_layers",
default=3,
type=int,
metavar="N",
help="convolutional layers for sentence encoder",
)
parser.add_argument(
"-scw",
"--sent_conv_window",
default=1,
type=int,
metavar="N",
help="window size (2k+1) for sentence encoder convolutions",
)
parser.add_argument(
"-sgl",
"--sent_gru_layers",
default=2,
type=int,
metavar="N",
help="BiGRU layers for sentence encoder",
)
# optimization arguments
parser.add_argument(
"-bs", "--batch_size", default=128, type=int, metavar="N", help="batch size"
)
parser.add_argument(
"-lr",
"--learning_rate",
default=5e-3,
type=float,
metavar="D",
help="learning rate factor",
)
parser.add_argument(
"-le", "--learning_epochs", default=10, type=int, metavar="N", help="number of epochs"
)
parser.add_argument(
"-nbpe",
"--batches_per_epoch",
default=1000,
type=int,
metavar="N",
help="number of batches per epoch",
)
parser.add_argument(
"-ls",
"--label_smoothing",
default=0.0,
type=float,
metavar="D",
help="label smoothing regularizer",
)
parser.add_argument(
"-do", "--dropout", default=0.3, type=float, metavar="D", help="dropout value in [0,1]"
)
parser.add_argument(
"-sn",
"--sentence_noise",
default=0.0,
type=float,
metavar="D",
help="train time probability of masking a word in [0,1]",
)
# continue training
parser.add_argument("-lm", "--load_model", action="store_true")
parser.add_argument(
"-lmf",
"--load_model_file",
default="",
type=str,
metavar="S",
help="torch formatted model file to load",
)
args = parser.parse_args()
# TODO: add print_freq to arguments
args.print_freq = 100
# short-hand for no pre-trained word embeddings
if args.learn_embed_dim < 0:
args.learn_embed_dim *= -1
args.learn_embeds = True
pickle.dump(args, open("%s.args.pk" % (args.model_name,), "wb"))
### set up logging
l_handler = logging.handlers.WatchedFileHandler(
os.environ.get("LOGFILE", "logs/%s.log" % args.model_name.split("/")[-1])
)
l_format = logging.Formatter(fmt="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S")
l_handler.setFormatter(l_format)
l_root = logging.getLogger()
l_root.setLevel(os.environ.get("LOGLEVEL", "INFO"))
l_root.addHandler(l_handler)
### Training data loading and training code
st_time = time()
# load make data
print("starting %.1f" % (time() - st_time,))
a_tree_pred, a_tree_loss, w2i = make_model(
args, args.ft_model_file, args.action_tree_file, args.cuda
)
optimizer = optim.Adagrad(a_tree_pred.parameters(), lr=args.learning_rate)
print("made model %.1f" % (time() - st_time,))
# load data
data_loader = DataLoader(args)
print("loaded training data: %.1f" % (time() - st_time,))
if args.load_model_file:
print("loading model to test....")
a_tree_pred.load_state_dict(torch.load(args.load_model_file))
a_tree_pred.eval()
# get numbers for validation set
for valid_type in data_loader.data["valid"]:
# accuracy
print(valid_type)
acc1 = compute_accuracy(a_tree_pred, data_loader.data["valid"][valid_type], w2i, args)
# # accuracy per action type
# acc2 = compute_accuracy_per_action_type(
# a_tree_pred, data_loader.data["valid"][valid_type], w2i, args
# )
# # precision, recall, f1
# precision_recall_stats = compute_precision_recall(
# a_tree_pred, data_loader.data["valid"][valid_type][:10], w2i, args
# )
print("----- VALID_FINAL_ACCURACIES %s %s" % (valid_type, str(acc1)))
# pprint(str(acc2))
# pprint(str(precision_recall_stats))
# print("-------" * 10)
print("----- TEST")
for test_type in data_loader.data["test"]:
# for internal only accuracy -> give : only_internal=True
# get accuracy
acc1 = compute_accuracy(a_tree_pred, data_loader.data["test"][test_type], w2i, args)
# # get accuracy per action type
# acc2 = compute_accuracy_per_action_type(
# a_tree_pred, data_loader.data["test"][test_type], w2i, args
# )
# # precision, recall, f1 stats
# precision_recall_stats = compute_precision_recall(
# a_tree_pred, data_loader.data["test"][test_type], w2i, args
# )
print("----- TEST_FINAL_ACCURACIES %s %s" % (test_type, str(acc1)))
# pprint(str(acc2))
# pprint(str(precision_recall_stats))
# print("------" * 10)
else:
# start training
for e in range(args.learning_epochs):
model_file_name = "%s_%d.pth" % (args.model_name, e)
# train on current slice
a_tree_pred.train()
print("----- TRAIN GENERATED", e)
logging.info("----- TRAIN GENERATED %d" % (e,))
run_epoch(
data_loader,
a_tree_pred,
a_tree_loss,
w2i,
args,
mode="train",
data_type="",
optimizer=optimizer,
)
# DEBUG
torch.save(a_tree_pred.to("cpu").state_dict(), model_file_name)
a_tree_pred.to("cuda:0")
a_tree_pred.eval()
# hard_buf_acc = compute_accuracy(a_tree_pred, data_loader.hard_buffer[:512], w2i, args)
# print("---- HARD_BUFFER_ACCURACY %s %s " % (e, hard_buf_acc))
# compute accuracy on valid
data_loader.reset_valid()
for valid_type in data_loader.data["valid"]:
print("----- VALID %s" % valid_type, e)
logging.info("----- VALID %s %d" % (valid_type, e))
run_epoch(
data_loader,
a_tree_pred,
a_tree_loss,
w2i,
args,
mode="valid",
data_type=valid_type,
optimizer=None,
)
acc = compute_accuracy(
a_tree_pred, data_loader.data["valid"][valid_type][:256], w2i, args
)
logging.info("----- VALID_ACCURACIES %d %s %.2f" % (e, valid_type, acc))
if __name__ == "__main__":
main()
| craftassist-master | python/base_agent/ttad/ttad_model/train_model.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/base_agent/ttad/ttad_model/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
import sys
import spacy
from spacy.lang.en import English
tokenizer = English().Defaults.create_tokenizer()
def tokenize(st):
return " ".join([str(x) for x in tokenizer(st)])
data_in_text_file = sys.argv[1]
data_out_json_file = sys.argv[2]
print("parsing text file")
res = []
exple = []
f_text = open(data_in_text_file)
for i, line in enumerate(f_text):
if line.strip() == "":
res += [(exple[:-1], json.loads(exple[-1]))]
exple = []
else:
if line.startswith('"'):
text = tokenize(line.strip()[1:-1])
exple += [text]
else:
exple += [line.strip()]
if i % 100000 == 0:
print("read %d lines, found %d examples" % (i, len(res)))
f_text.close()
# n_train = (9 * len(res)) // 10
n_train = len(res) - 10000
n_valid = 5000
# n_valid = len(res) // 20
data = {
"train": {"templated": res[:n_train]},
"valid": {"templated": res[n_train : n_train + n_valid]},
"test": {"templated": res[n_train + n_valid :]},
}
print("saving data dict")
json.dump(data, open(data_out_json_file, "w"))
| craftassist-master | python/base_agent/ttad/ttad_model/make_dataset.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
import sys
from pprint import pprint
from emnlp_model import *
data_file = sys.argv[1]
grammar_file = sys.argv[2]
print("loading", data_file)
data_dct = json.load(open(data_file))
print("loaded data")
a_tree = ActionTree()
for spl, spl_dct in data_dct.items():
for d_type, ls in spl_dct.items():
print("reading", spl, d_type)
a_tree.build_from_list([t for d, t in ls])
a_tree_dct = a_tree.to_dict()
json.dump(a_tree_dct, open(grammar_file, "w"))
pprint(a_tree_dct)
| craftassist-master | python/base_agent/ttad/ttad_model/make_action_grammar.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import copy
import math
import torch
import torch.nn as nn
##### Utility modules
# Produce n identical layers.
def clones(module, n):
return nn.ModuleList([copy.deepcopy(module) for _ in range(n)])
def xavier_init(module, mul=1.0):
for p in module.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p, mul)
else:
torch.nn.init.constant_(p, 0)
# Compute 'Scaled Dot Product Attention'
def attention(query, key, value, mask=None, dropout=None):
dim = query.size(-1)
scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(dim)
if mask is not None:
scores = scores.masked_fill(mask.unsqueeze(1) == 0, -1e9)
p_attn = torch.softmax(scores, dim=-1)
if dropout is not None:
p_attn = dropout(p_attn)
return torch.matmul(p_attn, value), p_attn
class MultiHeadedAttention(nn.Module):
def __init__(self, h, d_model, dropout=0.1):
"Take in model size and number of heads."
super(MultiHeadedAttention, self).__init__()
assert d_model % h == 0
# We assume d_v always equals d_k
self.d_k = d_model // h
self.h = h
self.linears = clones(nn.Linear(d_model, d_model), 4)
self.attn = None
self.dropout = nn.Dropout(p=dropout)
def forward(self, query, key, value, mask=None):
if mask is not None:
# Same mask applied to all h heads.
mask = mask.unsqueeze(1)
nbatches = query.size(0)
# 1) Do all the linear projections in batch from d_model => h x d_k
query, key, value = [
l(x).view(nbatches, -1, self.h, self.d_k).transpose(1, 2)
for l, x in zip(self.linears, (query, key, value))
]
# 2) Apply attention on all the projected vectors in batch.
x, self.attn = attention(query, key, value, mask=mask, dropout=self.dropout)
# 3) "Concat" using a view and apply a final linear.
x = x.transpose(1, 2).contiguous().view(nbatches, self.h * self.d_k)
return self.linears[-1](x)
def initialize(self, mul):
for lin in self.linears:
xavier_init(lin, mul)
# node sub-modules
# NodeSentRep attends to sentence representation (and possibly previously visited nodes)
# to get contextual representation vector for current node
# used to predict the presence of an internal node or the value of a categorical node
class NodeSentenceRep(nn.Module):
def __init__(self, tree, sent_attn, tree_attn, rec_cell):
super(NodeSentenceRep, self).__init__()
self.dim = tree.dim
self.do = nn.Dropout(tree.dropout)
# attending over the tree context first
self.tree_attn = tree_attn
self.sent_attn = sent_attn
self.rec_proj = nn.Linear(2 * self.dim, self.dim)
self.rec_cell = rec_cell
def initialize(self, mul):
self.tree_attn.initialize(mul)
self.sent_attn.initialize(mul)
xavier_init(self.rec_cell, mul)
xavier_init(self.rec_proj, mul)
def forward(self, node_vec, sentence_rep, tree_context):
sent_vecs, sent_mask = sentence_rep
prev_h, parent_h, context_rep, context_mask = tree_context
if prev_h is not None:
node_vec = node_vec + prev_h
if context_rep is not None:
node_rep = self._apply_tree_attn(node_vec, context_rep, context_mask)
else:
node_rep = node_vec
node_rep = self._apply_sen_attn(node_rep, sent_vecs, sent_mask)
return node_rep
# our (sentence + tree)-attention baseline
def _apply_tree_attn(self, node_vec, context_rep, context_mask):
# if recursive: attend over provided context
# to compute node representaiton
# else: just use node parameter
# attend over context
context_h = self.tree_attn(node_vec, context_rep, context_rep, mask=context_mask)
node_tree_rep = self.do(context_h + node_vec)
return node_tree_rep
# inplementing Seq2Tree from Dong & Lapata
def _apply_sen_attn(self, node_vec, sent_rep, sent_mask):
# predict presence and value based on previous hidden space
node_rep = self.sent_attn(node_vec, sent_rep, sent_rep, mask=sent_mask)
node_pred = self.do(node_vec + node_rep)
return node_pred
def _apply_recurrence(self, node_rep, prev_h, parent_h, on_mask):
# update hidden space based on node vector and previous and parent hidden space
if parent_h is None:
node_vec = node_rep
else:
node_vec = self.rec_proj(torch.cat([node_rep, parent_h], dim=-1))
node_h = self.rec_cell(node_vec, prev_h)
# only update hidden state for active nodes
node_h = on_mask[:, None] * node_h + (1 - on_mask[:, None]) * prev_h
return node_h
# Various internal node and leaf prediction heads
# sigmoid for presence scores
class PredictPresence(nn.Module):
def __init__(self, dim):
super(PredictPresence, self).__init__()
self.score_pres = nn.Linear(dim, 1)
def initialize(self, mul):
xavier_init(self.score_pres, mul)
def forward(self, x):
scores = self.score_pres(x).squeeze(dim=-1)
return scores
# softmax over class scores
class PredictCategorySingle(nn.Module):
def __init__(self, dim, n_vals):
super(PredictCategorySingle, self).__init__()
self.score_vals = nn.Linear(dim, n_vals)
def initialize(self, mul):
xavier_init(self.score_vals, mul)
def forward(self, x):
scores = self.score_vals(x)
scores = torch.log_softmax(scores, dim=-1)
return scores
# sigmoid for each class score
class PredictCategorySet(nn.Module):
def __init__(self, dim, n_vals):
super(PredictCategorySet, self).__init__()
self.score_vals = nn.Linear(dim, n_vals)
def initialize(self, mul):
xavier_init(self.score_vals, mul)
def forward(self, x):
scores = self.score_vals(x)
return scores
# softmax over indexes for start and end
class PredictSpanSingle(nn.Module):
def __init__(self, dim):
super(PredictSpanSingle, self).__init__()
self.score_start = nn.Linear(dim, dim)
self.score_end = nn.Linear(dim, dim)
def initialize(self, mul):
xavier_init(self.score_start, mul)
xavier_init(self.score_end, mul)
def forward(self, x, sentence_rep):
sen_vecs, sen_mask = sentence_rep
sen_start = self.score_start(sen_vecs) # B x T x D
scores_start = torch.matmul(sen_start, x.unsqueeze(-1)).squeeze(-1) # B x T
scores_start = scores_start.masked_fill(sen_mask == 0, -1e6)
sen_end = self.score_end(sen_vecs) # B x T x D
scores_end = torch.matmul(sen_end, x.unsqueeze(-1)).squeeze(-1) # B x T
scores_end = scores_end.masked_fill(sen_mask == 0, -1e6)
scores = scores_start.unsqueeze(-1) + scores_end.unsqueeze(-2) # B x T x T
bs, t = scores.shape[:2]
scores += torch.tril(-1e6 * torch.ones(t, t), diagonal=-1).unsqueeze(0).type_as(sen_vecs)
scores = scores.view(bs, -1)
scores = torch.log_softmax(scores, dim=-1)
scores = scores.view(bs, t, t)
return scores
# BIO tagging
# (no transition scores in thids implementation, TODO)
def log_sum_exp(bx):
bm = bx.max(dim=-1)[0]
return bm + torch.log(torch.exp(bx - bm.unsqueeze(-1)).sum(dim=-1))
class PredictSpanSet(nn.Module):
def __init__(self, dim):
super(PredictSpanSet, self).__init__()
self.score_b = nn.Linear(dim, dim)
self.score_i = nn.Linear(dim, dim)
self.score_o = nn.Linear(dim, dim)
def initialize(self, mul):
xavier_init(self.score_b, mul)
xavier_init(self.score_i, mul)
xavier_init(self.score_o, mul)
def forward(self, x, sentence_rep):
sen_vecs, sen_mask = sentence_rep
sen_b = self.score_b(sen_vecs) # B x T x D
scores_b = torch.matmul(sen_b, x.unsqueeze(-1)).squeeze(-1) # B x T
scores_b = scores_b.masked_fill(sen_mask == 0, -1e6)
sen_i = self.score_i(sen_vecs) # B x T x D
scores_i = torch.matmul(sen_i, x.unsqueeze(-1)).squeeze(-1) # B x T
scores_i = scores_i.masked_fill(sen_mask == 0, -1e6)
sen_o = self.score_o(sen_vecs) # B x T x D
scores_o = torch.matmul(sen_o, x.unsqueeze(-1)).squeeze(-1) # B x T
scores_o = scores_o.masked_fill(sen_mask == 0, 0)
scores_bio = torch.cat(
[scores_b.unsqueeze(-1), scores_i.unsqueeze(-1), scores_o.unsqueeze(-1)], dim=-1
) # B x T x 3
# alpha beta recursion
bs, bt = scores_o.shape
forward_scores = torch.zeros(bs, bt + 1).type_as(scores_o)
backward_scores = torch.zeros(bs, bt + 1).type_as(scores_o)
for t in range(1, bt + 1):
forward_scores[:, t] = log_sum_exp(
forward_scores[:, t - 1].unsqueeze(dim=-1) + scores_bio[:, t - 1]
)
backward_scores[:, -t - 1] = log_sum_exp(
backward_scores[:, -t].unsqueeze(dim=-1) + scores_bio[:, -t]
)
full_scores = forward_scores[:, -1]
span_scores = torch.zeros(bs, bt, bt).type_as(sen_vecs)
for s in range(bt):
for e in range(s, bt):
span_scores[:, e, s] = -1e3
span_scores[:, s, e] = (
scores_b[:, s]
+ scores_i[:, s:e].sum(dim=-1)
+ forward_scores[:, s]
+ backward_scores[:, e + 1]
- full_scores
)
if e < bt:
span_scores[:, s, e] += scores_o[:, e]
return span_scores
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/model_utils.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import math
import torch
import torch.nn as nn
class HighwayNetwork(nn.Module):
def __init__(self, in_dim, out_dim):
super(HighwayNetwork, self).__init__()
self.gate_proj = nn.Linear(in_dim, out_dim)
self.lin_proj = nn.Linear(in_dim, out_dim)
self.nonlin_proj = nn.Linear(in_dim, out_dim)
for p in self.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p)
else:
torch.nn.init.constant_(p, 0)
def forward(self, x):
gate = torch.sigmoid(self.gate_proj(x) - 2)
lin = self.lin_proj(x)
nonlin = torch.relu(self.nonlin_proj(x))
res = gate * nonlin + (1 - gate) * lin
return res
# simple sentence embedding usinf pre-trained fastText
# for debugging
class FastTextSentenceEmbedding(nn.Module):
def __init__(self, dim, l_dim, n_words, ft_embeds, init_embeds=True):
super(FastTextSentenceEmbedding, self).__init__()
self.dim = dim
self.ft_dim = 0 if ft_embeds is None else 300
self.l_dim = l_dim
self.ft_embed = False if ft_embeds is None else nn.Embedding.from_pretrained(ft_embeds)
if l_dim > 0:
self.learn_embed = nn.Embedding(n_words, l_dim)
for p in self.learn_embed.parameters():
torch.nn.init.constant_(p, 0)
self.proj = HighwayNetwork(self.ft_dim + self.l_dim, self.dim)
for p in self.proj.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p)
else:
torch.nn.init.constant_(p, 0)
if l_dim > 0:
if self.ft_embed:
for p in self.learn_embed.parameters():
torch.nn.init.constant_(p, 0)
else:
for p in self.learn_embed.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p)
else:
torch.nn.init.constant_(p, 0)
def forward(self, sent_ids, sent_mask=None, sent_len=None):
if self.ft_embed:
ft_embed = self.ft_embed(sent_ids).detach()
if self.l_dim > 0:
l_embed = self.learn_embed(sent_ids)
if self.ft_embed and self.l_dim > 0:
pre_embed = torch.cat([ft_embed, l_embed], dim=-1)
elif self.ft_embed:
pre_embed = ft_embed
else:
pre_embed = l_embed
return self.proj(pre_embed)
# Sinusoidal position encodings
class PositionalEncoding(nn.Module):
def __init__(self, dim, dropout, max_len=320):
super(PositionalEncoding, self).__init__()
self.dropout = nn.Dropout(dropout)
# Compute the positional encodings once in log space.
pe = torch.zeros(max_len, dim)
position = torch.arange(0, max_len).float().unsqueeze(1)
div_term = torch.exp(torch.arange(0, dim, 2).float() * -(math.log(10000.0) / dim))
pe[:, 0::2] = torch.sin(position * div_term)
pe[:, 1::2] = torch.cos(position * div_term)
pe = pe.unsqueeze(0)
def forward(self, x):
x = x + self.pe[:, : x.size(1)].detach()
return self.dropout(x)
# convolutional sentence encoder
class SentenceConvEncoder(nn.Module):
def __init__(self, word_embed, dim, k, n_layers, dropout=0.1):
super(SentenceConvEncoder, self).__init__()
self.word_embed = word_embed
self.conv_layers = nn.ModuleList(
[nn.Conv1d(dim, 2 * dim, 2 * k + 1, padding=k) for _ in range(n_layers)]
)
self.glu = nn.GLU()
self.do = nn.Dropout(dropout)
for p in self.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p)
else:
torch.nn.init.constant_(p, 0)
# don't initialize PE!
self.pe = PositionalEncoding(dim, dropout)
def forward(self, sent_ids, sent_mask, sent_len):
x = self.word_embed(sent_ids)
x = self.do(x)
for layer in self.conv_layers:
residual = x
x = layer(x.transpose(1, 2)).transpose(1, 2)
x = self.glu(x) + residual
x = x.masked_fill(sent_mask.unsqueeze(-1) == 0, 0)
x = self.do(x)
return x
# BiGRU sentence encoder
class SentenceBiGRUEncoder(nn.Module):
def __init__(self, word_embed, dim, n_layers, dropout=0.1):
super(SentenceBiGRUEncoder, self).__init__()
self.word_embed = word_embed
self.bigru = nn.GRU(
dim, dim, n_layers, batch_first=True, bidirectional=True, dropout=dropout
)
self.final_proj = nn.Linear(2 * dim, dim)
self.do = nn.Dropout(dropout)
for p in self.parameters():
if p.dim() > 1:
torch.nn.init.xavier_normal_(p)
else:
torch.nn.init.constant_(p, 0)
def forward(self, sent_ids, sent_mask, sent_len):
x = self.word_embed(sent_ids)
x = self.do(x)
lengths = sent_len
# TODO this is a temporary hotfix for unsorted padded sequence
if sent_mask.shape[0] > 1:
packed_x = nn.utils.rnn.pack_padded_sequence(
x, lengths, batch_first=True, enforce_sorted=False
)
else:
packed_x = nn.utils.rnn.pack_padded_sequence(x, lengths, batch_first=True)
packed_h, _ = self.bigru(packed_x)
h, _ = nn.utils.rnn.pad_packed_sequence(packed_h, batch_first=True)
h = self.do(h)
h = self.final_proj(h)
return h
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/sentence_encoder.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# define the grammar
from collections import OrderedDict
#####
## define node types
class SpanSingleLeaf:
def __init__(self, node_id, name):
self.node_type = "span-single"
self.name = name
self.node_id = node_id
def is_span(val):
try:
# previous version
# (b, c) = val
# return all([type(v) == int for v in [b, c]])
a, (b, c) = val
return all([type(v) == int for v in [a, b, c]])
except (ValueError, TypeError):
return False
def is_span_dialogue(val):
try:
a, (b, c) = val
return all([type(v) == int for v in [a, b, c]])
except (ValueError, TypeError):
return False
class SpanSetLeaf:
def __init__(self, node_id, name):
self.node_type = "span-set"
self.name = name
self.node_id = node_id
def is_span_list(val):
res = type(val) == list and len(val) > 0 and all([is_span(v) for v in val])
return res
class CategoricalSingleLeaf:
def __init__(self, node_id, name, choices=None):
self.node_type = "categorical-single"
self.name = name
self.node_id = node_id
self.choices = [] if choices is None else choices[:]
def is_cat(val):
return type(val) == str or val is True or val is False
class CategoricalSetLeaf:
def __init__(self, node_id, name, choices=None):
self.node_type = "categorical-set"
self.name = name
self.node_id = node_id
self.choices = [] if choices is None else choices[:]
def is_cat_list(val):
res = type(val) == list and len(val) > 0 and all([is_cat(v) for v in val])
return res
def make_leaf(node_id, name, value=None, node_type=""):
if (
type(value) == list
and len(value) == 2
and (type(value[0]) == int and type(value[1]) == int)
):
value = [0, value]
if node_type == "span-single" or is_span(value):
return SpanSingleLeaf(node_id, name)
elif node_type == "span-set" or is_span_list(value):
return SpanSetLeaf(node_id, name)
elif node_type == "categorical-single" or is_cat(value):
return CategoricalSingleLeaf(node_id, name)
elif node_type == "categorical-set" or is_cat_list(value):
return CategoricalSetLeaf(node_id, name)
else:
print("M", value)
raise NotImplementedError
class InternalNode:
def __init__(self, node_id, name):
self.node_type = "internal"
self.node_id = node_id
self.name = name
self.internal_children = OrderedDict()
self.leaf_children = OrderedDict()
self.children = OrderedDict()
def add_int_node(self, name):
new_node = InternalNode(self.node_id + "-" + name, name)
node = self.internal_children.get(name, new_node)
self.internal_children[name] = node
self.children[name] = node
return node
def add_leaf_node(self, name, value):
node_id = self.node_id + ":" + name
new_node = make_leaf(node_id, name, value=value)
node = self.leaf_children.get(name, new_node)
if is_cat(value) and value not in node.choices:
node.choices += [value]
elif is_cat_list(value):
for v in value:
if v not in node.choices:
node.choices += [v]
self.leaf_children[name] = node
self.children[name] = node
return node
def is_sub_tree(val):
return type(val) == dict
####
# make full tree
class ActionTree:
def __init__(self):
self.root = InternalNode("root", "root")
def _add_subtree_dict(self, node, sub_tree):
for k, val in sub_tree.items():
if is_sub_tree(val):
child_node = node.add_int_node(k)
self._add_subtree_dict(child_node, val)
else:
if k == "location":
print(sub_tree)
raise NotImplementedError
node.add_leaf_node(k, val)
def build_from_list(self, tree_list):
for i, parse_tree in enumerate(tree_list):
self._add_subtree_dict(self.root, parse_tree)
def _sub_to_dict(self, node):
res = OrderedDict()
for k, val in node.internal_children.items():
res[k] = (val.node_type, val.node_id, self._sub_to_dict(val))
for k, val in node.leaf_children.items():
res[k] = (
val.node_type,
val.node_id,
val.choices if "categorical" in val.node_type else "",
)
return res
def to_dict(self):
return self._sub_to_dict(self.root)
def _sub_from_dict(self, node, sub_tree):
for name, (node_type, node_id, value) in sub_tree.items():
if node_type == "internal":
child_node = node.add_int_node(name)
assert node_id == child_node.node_id
self._sub_from_dict(child_node, value)
else:
new_node = make_leaf(node_id, name, node_type=node_type)
if "categorical" in node_type:
new_node.choices = value
node.leaf_children[name] = new_node
node.children[name] = new_node
def from_dict(self, a_tree):
self._sub_from_dict(self.root, a_tree)
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/action_tree.py |
from .action_tree import *
from .data import *
from .sentence_encoder import *
from .prediction_model import *
from .my_optim import *
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
import math
import pickle
import torch
import torch.nn as nn
from .action_tree import *
from .model_utils import *
from .my_optim import *
from .sentence_encoder import *
##### Define tree modules
# Each node module computes a contextual node representation
# and predicts whether the node is present, as we as its
# categorical or span value for leaves
class NodePrediction(nn.Module):
def __init__(self, node_sen_rep, node, args):
super(NodePrediction, self).__init__()
self.dim = args.model_dim
self.dropout = nn.Dropout(args.dropout)
self.node_type = node.node_type
self.node_vec = nn.Parameter(torch.zeros(self.dim))
self.node_sen_rep = node_sen_rep
self.node_score_pres = PredictPresence(self.dim)
# have to define module outside of loop for pytorch reasons
n_values = len(node.choices) if "categorical" in self.node_type else 1
self.nsv_s_sin = PredictSpanSingle(self.dim)
self.nsv_s_set = PredictSpanSet(self.dim)
self.nsv_c_sin = PredictCategorySingle(self.dim, n_values)
self.nsv_c_set = PredictCategorySet(self.dim, n_values)
self.nvv = nn.Embedding(n_values, self.dim)
self.module_list = nn.ModuleList(
[
self.node_score_pres,
self.nsv_s_sin,
self.nsv_s_set,
self.nsv_c_sin,
self.nsv_c_set,
self.nvv,
]
)
if self.node_type == "internal":
self.node_score_val = None
elif self.node_type == "span-single":
self.node_score_val = self.nsv_s_sin
elif self.node_type == "span-set":
self.node_score_val = self.nsv_s_set
elif self.node_type == "categorical-single":
self.node_val_vec = self.nvv
self.node_score_val = self.nsv_c_sin
elif self.node_type == "categorical-set":
self.node_val_vec = self.nvv
self.node_score_val = self.nsv_c_set
else:
raise NotImplementedError
def forward(self, sentence_rep, tree_context, recursion, active, labels):
# compute node representation to be used in prediction
sent_rep, sent_mask = sentence_rep
node_vec = self.node_vec[None, :].expand(active.shape[0], self.dim).type_as(sent_rep)
node_rep = self.node_sen_rep(node_vec, sentence_rep, tree_context)
node_rep = self.dropout(node_rep)
if recursion == "seq2tree-rec":
node_x = node_vec
else:
node_x = node_rep
# predict whether the node is on
# uses labels if available or predicted value otherwise
# for recurrence / recursion update
pres_score = self.node_score_pres(node_rep)
if labels is None:
on_mask = ((pres_score > 0).long() * active).type_as(sent_rep)
else:
on_mask = (labels["pres_labels"] * active).type_as(sent_rep)
on_mask *= active.type_as(sent_rep)
# predict node value for leaves
span_score = None
cat_score = None
if self.node_type == "internal":
pass
elif self.node_type in ["span-single", "span-set"]:
span_score = self.node_score_val(node_rep, sentence_rep)
elif self.node_type in ["categorical-single", "categorical-set"]:
cat_score = self.node_score_val(node_rep)
if self.node_type == "categorical-single":
if labels is None:
cat_val = cat_score.max(dim=-1)[1]
else:
cat_val = labels["cat_labels"].type_as(sent_mask)
cat_rep = self.node_val_vec(cat_val)
node_x = node_x + cat_rep
else:
print(self.node_type)
raise NotImplementedError
# if using recurrence, update hidden state
if recursion in ["seq2tree-rec", "sentence-rec"]:
prev_h, parent_h, _, _ = tree_context
node_h = self.node_sen_rep._apply_recurrence(node_x, prev_h, parent_h, on_mask)
elif recursion in ["none", "top-down", "dfs-intern", "dfs-all"]:
node_h = None
else:
raise NotImplementedError
return {
"pres_score": pres_score,
"cat_score": cat_score,
"span_score": span_score,
"node_rep": node_rep,
"node_h": node_h,
}
def to(self, *args, **kwargs):
self = super().to(*args, **kwargs)
self.node_vec = self.node_vec.to(*args, **kwargs)
self.node_score_pres = self.node_score_pres.to(*args, **kwargs)
if self.node_score_val is not None:
self.node_score_val = self.node_score_val.to(*args, **kwargs)
return self
# xavier initialization for most parameters
def initialize(self, mul=1.0):
torch.nn.init.normal_(self.node_vec, mul / math.sqrt(self.dim))
self.node_score_pres.initialize(mul)
if self.node_score_val is not None:
self.node_score_val.initialize(mul)
##### Define full tree
class ActionTreePrediction(nn.Module):
def __init__(self, sentence_embed, action_tree_path, args):
super(ActionTreePrediction, self).__init__()
self.args = args
self.dim = args.model_dim
self.dropout = args.dropout
action_tree = ActionTree()
action_tree.from_dict(json.load(open(action_tree_path)))
self.action_tree = action_tree
self.root_node = self.action_tree.root
self.sentence_rep = sentence_embed
# make tree-wide module parameters
sent_attn = MultiHeadedAttention(args.sent_heads, self.dim, self.dropout)
tree_attn = MultiHeadedAttention(args.tree_heads, self.dim, self.dropout)
rec_cell = nn.GRUCell(self.dim, self.dim)
self.node_sen_rep = NodeSentenceRep(self, sent_attn, tree_attn, rec_cell)
self.start_h = nn.Parameter(torch.zeros(self.dim))
# initialize list of nodes
self.module_dict = {}
self.collapse = args.collapse_nodes # use same parameters for nodes with the same name
self.node_list = []
self.make_modules()
self.module_list = nn.ModuleList([node.predictor for node in self.node_list])
# index node to easily access representation and mask
for i, node in enumerate(self.node_list):
node.tree_index = i + 1
self.tree_size = len(self.node_list) + 1
self.context_rep = None
self.context_mask = None
def to(self, *args, **kwargs):
self = super().to(*args, **kwargs)
self.start_h = self.start_h.to(*args, **kwargs)
self.node_sen_rep = self.node_sen_rep.to(*args, **kwargs)
for node in self.node_list:
node.predictor = node.predictor.to(*args, **kwargs)
return self
def initialize(self, mul=1.0):
torch.nn.init.constant_(self.start_h, 0)
self.node_sen_rep.initialize(mul)
for node in self.node_list:
node.predictor.initialize(mul)
return self
def device(self):
return self.start_h.device
# create Internal-, Categorical-, and Span-Prediction
# modules to match the structure of self.action_tree
def make_modules(self):
self._make_modules_recursion(self.root_node)
def _make_modules_recursion(self, node):
# print(len(self.node_list), node.name, node.node_type, node.node_id)
if self.collapse and node.name in self.module_dict:
node.predictor = self.module_dict[node.name]
else:
node.predictor = NodePrediction(self.node_sen_rep, node, self.args)
if self.collapse:
self.module_dict[node.name] = node.predictor
self.node_list.append(node)
for k, chld in node.leaf_children.items():
if self.collapse and chld.name in self.module_dict:
chld.predictor = self.module_dict[chld.name]
else:
chld.predictor = NodePrediction(self.node_sen_rep, chld, self.args)
if self.collapse:
self.module_dict[chld.name] = chld.predictor
self.node_list.append(chld)
for k, chld in node.internal_children.items():
self._make_modules_recursion(chld)
def _make_tree_context(self, node_h, node_path):
prev_h, parent_h = node_h
if node_path:
c_rep = torch.cat([node.out["node_rep"].unsqueeze(dim=1) for node in node_path], dim=1)
c_mask = torch.cat([node.mask.unsqueeze(dim=1) for node in node_path], dim=1)
return (prev_h, parent_h, c_rep, c_mask)
else:
return (prev_h, parent_h, None, None)
# compute internal, categorical and span scores
# (they have different losses, hence the split)
# stores scores in the node.out field
def forward(self, sent_ids, sent_mask, sent_len, recursion="none", prediction=False):
# compute sentence representation
sent_rep = self.sentence_rep(sent_ids, sent_mask, sent_len)
sentence_rep = (sent_rep, sent_mask)
# initialize root node
if prediction:
for node in self.node_list:
node.active = torch.zeros(sent_rep.shape[0]).type_as(sent_mask)
self.root_node.active = torch.ones(sent_rep.shape[0]).type_as(sent_mask)
self.root_node.mask = torch.ones(sent_rep.shape[0]).type_as(sent_mask)
self.root_node.out = {}
self.root_node.out["node_rep"] = self.start_h[None, :].expand(sent_rep.shape[0], self.dim)
self.root_node.labels = {"pres_labels": self.root_node.mask}
# prepare node path and recurrent state
node_path = None
prev_h = None
parent_h = None
context_rep = None
context_mask = None
if recursion in ["top-down", "dfs-intern", "dfs-all"]:
node_path = [self.root_node]
if recursion in ["seq2tree-rec", "sentence-rec"]:
prev_h = torch.zeros(sent_rep.shape[0], self.dim).type_as(sent_rep)
# prev_h = prev_h + self.start_h
parent_h = torch.zeros(sent_rep.shape[0], self.dim).type_as(sent_rep)
node_h = (prev_h, parent_h)
# launch recursion
_ = self._forward_recursion(
self.root_node, sentence_rep, node_h, node_path, recursion, prediction
)
# TODO: add set prediction leaves
node_scores = [
node.out for node in self.node_list if any(node.active) and node.name != "root"
]
return node_scores
# different types of recursion:
# - 'none': no tree context
# - 'top-down': only see context from ancestors
# - 'dfs-intern': sees all internal nodes in DFS order
# - 'dfs-all': sees all nodes in DFS order
# - 'seq2tree-rec': Recurrent model following Dong&Lapata
# - 'sentence-rec': same but recurrent update depends on sentence
def _forward_recursion(self, node, sentence_rep, node_h, node_path, recursion, prediction):
prev_h, parent_h = node_h
# start by predicting presence of current node
node.out = node.predictor(
sentence_rep,
self._make_tree_context(node_h, node_path),
recursion,
node.active,
None if prediction and node.name != "root" else node.labels,
)
if recursion == "dfs-all":
node_path += [node]
if prediction and node.name != "root":
node.mask = node.active * (node.out["pres_score"] > 0).type_as(node.active)
else:
node.mask = node.active * node.labels["pres_labels"].type_as(node.active)
if node.node_type == "internal":
# don't waste time on inactive nodes
if node.mask.sum().item() == 0:
node_h = (node.out["node_h"], parent_h)
return (node_path, node_h)
# add current node to path for attention-based recursion
if recursion in ["top-down", "dfs-intern"]:
node_path += [node]
# predict the state of all children in DFS order
node_h = (node.out["node_h"], node.out["node_h"])
for k, chld in node.children.items():
chld.active = node.mask
if recursion in ["dfs-intern", "dfs-all", "seq2tree-rec", "sentence-rec"]:
node_path, node_h = self._forward_recursion(
chld, sentence_rep, node_h, node_path, recursion, prediction
)
elif recursion in ["none", "top-down"]:
_, _ = self._forward_recursion(
chld, sentence_rep, node_h, node_path, recursion, prediction
)
else:
raise NotImplementedError
node_h = (node.out["node_h"], parent_h)
return (node_path, node_h)
# run through the batch of trees (list of dicts) once to identify nodes that
# are active in this batch and create labels
# results are stored in the node.labels and node.active fields
def make_labels(self, tree_list, cuda=False):
batch_size = len(tree_list)
# initialize context_rep and context_mask
for node in self.node_list:
node.active = torch.LongTensor([0 for _ in tree_list]).to(self.device())
self.root_node.active = torch.LongTensor([1 for _ in tree_list]).to(self.device())
self.root_node.mask = torch.LongTensor([1 for _ in tree_list]).to(self.device())
self._make_labels_recursion(self.root_node, tree_list, self.root_node.active)
# FIXME: set nodes
active_node_list = [
node
for node in self.node_list
if node.active.sum().item() > 0
and node.name != "root"
and node.node_type != "span-set"
]
return active_node_list
def _make_labels_recursion(self, node, sub_tree_list, active):
# aggregate subtrees
node.active = active
node.mask = torch.LongTensor([1 if st else 0 for st in sub_tree_list]).to(self.device())
cat_labels = None
span_labels = None
if node.node_type == "internal":
pass
elif node.node_type == "categorical-single":
cat_labels = torch.LongTensor(
[node.choices.index(val) if val else 0 for val in sub_tree_list]
).to(self.device())
elif node.node_type == "categorical-set":
# TODO: FIXME
# currently predicting one value at random
cat_labels = torch.LongTensor(
[
node.choices.index(val[0]) if val and len(val) > 0 else 0
for val in sub_tree_list
]
).to(self.device())
elif node.node_type == "span-single":
span_labels = torch.LongTensor(
[(val[0], val[1]) if val else (0, 0) for val in sub_tree_list]
).to(self.device())
node.labels = {
"pres_labels": node.mask,
"cat_labels": cat_labels,
"span_labels": span_labels,
}
# check whether we even need to go down and continue
if node.node_type == "internal" and any(sub_tree_list):
for k, chld in node.children.items():
st_list = [t.get(k, False) if t else False for t in sub_tree_list]
self._make_labels_recursion(chld, st_list, node.mask)
# predict tree for single-sentence batch
def predict_tree(self, sent_ids, sent_mask, sent_len, recursion):
for node in self.node_list:
node.active = torch.LongTensor([0 for _ in range(sent_ids.shape[0])]).to(self.device())
self.root_node.active = torch.LongTensor([1 for _ in range(sent_ids.shape[0])]).to(
self.device()
)
self.root_node.mask = torch.LongTensor([1 for _ in range(sent_ids.shape[0])]).to(
self.device()
)
self.root_node.labels = {
"pres_labels": torch.LongTensor([1 for _ in range(sent_ids.shape[0])]).to(
self.device()
)
}
_ = self.forward(sent_ids, sent_mask, sent_len, recursion=recursion, prediction=True)
res = self._predict_tree_recursion(self.root_node)
return res
def _predict_tree_recursion(self, node):
res = {}
for k, chld in node.children.items():
if chld.node_type == "internal":
if chld.mask.item() == 1:
res[k] = self._predict_tree_recursion(chld)
elif chld.node_type == "categorical-single":
if chld.mask.item() == 1:
cat_index = chld.out["cat_score"].max(dim=-1)[1][0].item()
res[k] = chld.choices[cat_index]
elif chld.node_type == "categorical-set":
# FIXME: currently only / always predicting one
if chld.mask.item() == 1:
cat_index = chld.out["cat_score"].max(dim=-1)[1][0].item()
res[k] = [chld.choices[cat_index]]
elif chld.node_type == "span-single":
if chld.mask.item() == 1:
sp_index = chld.out["span_score"].view(1, -1).max(dim=-1)[1][0].item()
start_index = sp_index // chld.out["span_score"].shape[-1]
end_index = sp_index % chld.out["span_score"].shape[-1]
res[k] = (0, (start_index, end_index))
else:
# TODO: add set prediction
# raise NotImplementedError
res[k] = "NOT_IMPLEMENTED"
return res
################# utility
def make_model(args, embeddings_path, action_tree_path, use_cuda):
map_location = "cpu" if not torch.cuda.is_available() else None
ft_dict = torch.load(embeddings_path, map_location=map_location)
i2w = [w for w, c in ft_dict["vocabulary"]]
w2i = dict([(w, i) for i, w in enumerate(i2w)])
# make model
if args.learn_embeds:
word_embed = FastTextSentenceEmbedding(
args.model_dim, args.learn_embed_dim, len(i2w), None
)
else:
word_embed = FastTextSentenceEmbedding(
args.model_dim, args.learn_embed_dim, len(i2w), ft_dict["embeddings"]
)
if args.sentence_encoder == "convolution":
sent_embed = SentenceConvEncoder(
word_embed, args.model_dim, args.sent_conv_window, args.sent_conv_layers, args.dropout
)
elif args.sentence_encoder == "bigru":
sent_embed = SentenceBiGRUEncoder(
word_embed, args.model_dim, args.sent_gru_layers, args.dropout
)
else:
raise NotImplementedError
# load action tree
# TODO: add initializer multiplier to arguments
a_tree_pred = ActionTreePrediction(sent_embed, action_tree_path, args)
a_tree_pred.initialize(mul=1.0)
a_tree_loss = TreeLoss(args)
if use_cuda:
print("moving to cuda")
a_tree_pred.to("cuda:0")
a_tree_loss.to("cuda:0")
return (a_tree_pred, a_tree_loss, w2i)
def load_model(model_path, embeddings_path=None, action_tree_path=None, use_cuda=False, epoch=-1):
model_name = model_path.split(".pth")[0].strip()
with open("%s.args.pk" % (model_name,), "rb") as f:
args = pickle.load(f)
args.cuda = use_cuda
args.collapse_nodes = False # TODO fix
a_tree_pred, a_tree_loss, w2i = make_model(args, embeddings_path, action_tree_path, use_cuda)
map_location = None if use_cuda and torch.cuda.is_available() else "cpu"
if epoch < 0:
a_tree_pred.load_state_dict(
torch.load("%s.pth" % (model_name,), map_location=map_location)
)
print("loaded %s.pth" % (model_name,))
else:
a_tree_pred.load_state_dict(
torch.load("%s_%d.pth" % (model_name, epoch), map_location=map_location)
)
print("loaded %s_%d.pth" % (model_name, epoch))
a_tree_pred = a_tree_pred.eval()
return (a_tree_pred, a_tree_loss, w2i, args)
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/prediction_model.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
import numpy as np
from random import choice, random, randint, seed, shuffle
import torch
from .action_tree import *
def tree_to_action_type(tr):
a_type = tr["action_type"]
if a_type == "Build" and "reference_object" in tr:
return "Build-Copy"
else:
return a_type
def tree_to_nodes(tr, all_nodes=False):
if "action" in tr:
return "++".join(
[tr["action"]["action_type"]] + sorted(set(tree_to_nodes_rec(tr, all_nodes, "")))
)
else:
return "++".join([tr["dialogue_type"]] + sorted(set(tree_to_nodes_rec(tr, all_nodes, ""))))
def tree_to_nodes_rec(tr, all_nodes, ancestor_path):
res = []
for k, v in tr.items():
if type(v) == dict:
node_path = ancestor_path + "-" + k
res += [node_path] + tree_to_nodes_rec(v, all_nodes, node_path)
elif all_nodes:
node_path = ancestor_path + ":" + k
res += [node_path]
return res
# data loader that samples training and validation examples
# according to test distribution
class DataLoader:
def __init__(self, args):
seed(1111)
np.random.seed(1111)
# load data
# self.data is a mapping of data split and data type to list of examples
# e.g. self.data['train']['templated'] = [(description, tree) for _ in range(#train_templated)]
# it needs to have at least 'train'-'templated' and 'train'-'rephrased' if args.rephrase_proba > 0
self.data = json.load(open(args.data_file))
if args.train_on_everything:
for spl in ["valid", "test"]:
for data_type in self.data[spl]:
self.data["train"]["rephrases"] += self.data[spl][data_type][:]
self.data["train"]["templated"] += self.data[spl][data_type][:]
print("loaded data")
# organize data so we can resample training set
self.resample_base = "templated"
self.resample_mode = args.resample_mode
self.resample_target = args.resample_type
if args.resample_mode == "none":
self.tree_rep = lambda tr: "CONST"
elif args.resample_mode == "action-type":
self.tree_rep = lambda tr: tree_to_action_type(tr)
elif args.resample_mode == "tree-internal":
self.tree_rep = lambda tr: tree_to_nodes(tr, all_nodes=False)
elif args.resample_mode == "tree-full":
self.tree_rep = lambda tr: tree_to_nodes(tr, all_nodes=True)
else:
raise NotImplementedError
self.data_map = {}
for spl, spl_dict in self.data.items():
self.data_map[spl] = {}
for d_type, d_list in spl_dict.items():
print("mapping", spl, d_type)
self.data_map[spl][d_type] = {}
self.data_map[spl][d_type]["<ALL>"] = d_list[:]
for desc, tr in d_list:
trep = self.tree_rep(tr)
self.data_map[spl][d_type][trep] = self.data_map[spl][d_type].get(trep, [])
self.data_map[spl][d_type][trep] += [(desc, tr)]
# prepare for sampling without replacement
all_keys = [
trep
for spl, spl_dict in self.data_map.items()
for d_type, t_reps in spl_dict.items()
for trep in t_reps
]
all_keys = sorted(set(all_keys))
base_probas = [
len(self.data_map["train"][self.resample_base].get(k, []))
for i, k in enumerate(all_keys)
]
base_probas = [x / sum(base_probas) for x in base_probas]
target_probas = [
len(self.data_map["valid"][self.resample_target].get(k, []))
if base_probas[i] > 0
else 0
for i, k in enumerate(all_keys)
]
target_probas = [x / sum(target_probas) for x in target_probas]
self.sample_keys = all_keys
self.sample_prob = 0.2 * np.array(base_probas) + 0.8 * np.array(target_probas)
self.buffer_size = args.hard_buffer_size
self.buffer_prob = args.hard_buffer_proba
self.hard_buffer = self.data["train"]["templated"][: self.buffer_size]
self.rephrase_prob = args.rephrase_proba
# keep track of which examples have been used
self.data_log = {}
for spl, spl_dict in self.data_map.items():
self.data_log[spl] = {}
for d_type, trep_to_list in spl_dict.items():
self.data_log[spl][d_type] = {}
for trep in trep_to_list:
self.data_log[spl][d_type][trep] = 0
# pre-sample keys
print("pre-computing samples")
self.pre_sampled = np.random.choice(self.sample_keys, 128000, p=self.sample_prob)
self.sample_id = 0
print("pre-computed samples")
def next_batch(self, batch_size, mode, src, resample=False):
batch = []
for i in range(batch_size):
if mode == "train":
if random() < self.buffer_prob:
batch += [choice(self.hard_buffer)]
continue
elif random() < self.rephrase_prob:
src_choice = "rephrases"
else:
src_choice = "templated"
else:
src_choice = src
if mode == "train" or resample:
key_choice = self.pre_sampled[self.sample_id]
self.sample_id = (self.sample_id + 1) % len(self.pre_sampled)
if key_choice not in self.data_log[mode][src_choice]:
key_choice = "<ALL>"
if self.sample_id == 0:
self.pre_sampled = np.random.choice(
self.sample_keys, 128000, p=self.sample_prob
)
else:
key_choice = "<ALL>"
key_index = self.data_log[mode][src_choice][key_choice]
batch += [self.data_map[mode][src_choice][key_choice][key_index]]
# cycle through data and shuffle training data when it runs out
self.data_log[mode][src_choice][key_choice] += 1
if self.data_log[mode][src_choice][key_choice] >= len(
self.data_map[mode][src_choice][key_choice]
):
if mode == "train":
shuffle(self.data_map[mode][src_choice][key_choice])
self.data_log[mode][src_choice][key_choice] = 0
# print('restarts', src_choice, act_choice)
return batch
def update_buffer(self, mistakes):
for i, mistake in enumerate(mistakes):
b_idx = randint(0, self.buffer_size - 1)
self.hard_buffer[b_idx] = mistake
# always use the same resampled validation set
def reset_valid(self):
seed(1111)
np.random.seed(1111)
for d_type, trep_map in self.data_log["valid"].items():
for trep in trep_map:
self.data_log["valid"][d_type][trep] = 0
# utility functions to concatenate chats
def join_chats(desc_action_list):
res = []
for c_ls_ordered, tree in desc_action_list:
if type(c_ls_ordered) == str: # for other data sources
c_list = [c_ls_ordered]
else:
# NOTE: this will be deprectaed soon
# c_list = [" ".join(c_ls_ordered[-i - 1].split()[1:]) for i in range(len(c_ls_ordered))]
c_list = [c_ls_ordered[-i - 1] for i in range(len(c_ls_ordered))]
index_map = {}
tot_words = 0
for c_idx, c in enumerate(c_list):
for w_idx, w in enumerate(c.split()):
index_map[(c_idx, w_idx)] = tot_words
tot_words += 1
tot_words += 1
joined_c = " <s> ".join(c_list)
mapped_tree = map_spans(tree, index_map)
res += [(joined_c, mapped_tree)]
return res
def map_spans(tree, index_map):
for k, v in tree.items():
if is_span(v):
l, (s, e) = v
tree[k] = (index_map[(l, s)], index_map[(l, e)])
elif is_span_list(v):
tree[k] = [(index_map[(l, s)], index_map[(l, e)]) for l, (s, e) in v]
elif is_sub_tree(v):
tree[k] = map_spans(v, index_map)
else:
continue
return tree
# takes list of (description, action_tree) pairs and makes a batch to send to the model
def make_batch(desc_action_list, w2i, cuda=False, sentence_noise=0.0):
processed_list = join_chats(desc_action_list)
sentences = [s.strip() for s, a_tree in processed_list]
tree_list = [a_tree for s, a_tree in processed_list]
# sen_tabs = [['<s>'] + s.split() + ['</s>'] for s in sentences]
sen_tabs = [s.split() for s in sentences]
max_s_len = max([len(s) for s in sen_tabs])
sen_tabs_padded = [s + ["<pad>"] * (max_s_len - len(s)) for s in sen_tabs]
unk_id = w2i["<unk>"]
# each word is replaced by <unk> with probability sentence_noise
sent_ids = torch.LongTensor(
[
[w2i.get(w, unk_id) if random() >= sentence_noise else unk_id for w in s]
for s in sen_tabs_padded
]
)
sent_mask = torch.LongTensor([[0 if w == "<pad>" else 1 for w in s] for s in sen_tabs_padded])
sent_lengths = torch.LongTensor([len(s) for s in sen_tabs])
if cuda:
sent_ids = sent_ids.cuda()
sent_mask = sent_mask.cuda()
sent_lengths = sent_lengths.cuda()
return sent_ids, sent_mask, sent_lengths, tree_list
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/data.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import logging
from collections import OrderedDict
from time import time
import torch
import torch.nn as nn
import copy
from torch.nn.modules.loss import _Loss
from .data import *
class LabelSmoothingBCE(nn.Module):
def __init__(self, smoothing=0.0):
super(LabelSmoothingBCE, self).__init__()
self.criterion = nn.BCEWithLogitsLoss(reduction="none")
self.confidence = 1.0 - smoothing
self.smoothing = smoothing
def forward(self, x, target):
smooth_target = target.clone().masked_fill(target == 1, self.confidence)
smooth_target = smooth_target.masked_fill(target == 0, self.smoothing)
return self.criterion(x, smooth_target)
class LabelSmoothingCE(nn.Module):
def __init__(self, smoothing=0.0):
super(LabelSmoothingCE, self).__init__()
self.smoothing = smoothing
def forward(self, x, target):
lprobs = torch.log_softmax(x, dim=-1)
nll_loss = -lprobs.gather(dim=-1, index=target.unsqueeze(-1)).squeeze(-1)
smooth_loss = -lprobs.clamp(0, 100).sum(
dim=-1
) # hacky way to deal with sentence position padding
smooth_val = self.smoothing / x.size(-1)
loss = (1.0 - self.smoothing) * nll_loss + smooth_val * smooth_loss
scores = loss
return scores
class TreeLoss(_Loss):
def __init__(self, args):
super(TreeLoss, self).__init__()
self.label_smoothing = args.label_smoothing
if args.label_smoothing > 0:
self.bce_loss = LabelSmoothingBCE(args.label_smoothing)
self.ce_loss = LabelSmoothingCE(args.label_smoothing)
else:
self.bce_loss = nn.BCEWithLogitsLoss(reduction="none")
self.ce_loss = nn.CrossEntropyLoss(reduction="none")
def forward(self, node_list):
# go through list of node scores, labels, and per-batch activity
# to compute loss and accuracy
# internal nodes: (node_scores, (node_labels, node_active))
pres_list = []
span_list = []
cat_list = []
for node in node_list:
pres_scores = node.out["pres_score"]
pres_labels = node.labels["pres_labels"].type_as(pres_scores)
node_active = node.active.type_as(pres_scores)
pres_loss = self.bce_loss(pres_scores, pres_labels) * node_active
# print('>>>>>>', node.name)
# print(node.name, pres_scores, pres_labels)
pres_accu = ((pres_scores > 0) == (pres_labels > 0.5)).type_as(pres_scores)
# print(pres_accu)
pres_list += [(pres_loss, pres_accu, node_active)]
if node.node_type == "internal":
continue
elif node.node_type in ["categorical-single", "categorical-set"]:
# FIXME: currently predicting single value for set
cat_scores = node.out["cat_score"]
cat_labels = node.labels["cat_labels"]
cat_loss = self.ce_loss(cat_scores, cat_labels) * node_active * pres_labels
cat_accu = (1 - pres_labels) + pres_labels * (
cat_scores.argmax(dim=-1) == cat_labels
).type_as(pres_scores)
cat_list += [(cat_loss, cat_accu, node_active)]
elif node.node_type == "span-single":
span_pre_scores = node.out["span_score"] # B x T x T
span_pre_labels = node.labels["span_labels"] # B x 2
span_scores = span_pre_scores.view(span_pre_scores.shape[0], -1)
span_labels = (
span_pre_scores.shape[-1] * span_pre_labels[:, 0] + span_pre_labels[:, 1]
)
span_loss = self.ce_loss(span_scores, span_labels) * node_active * pres_labels
span_accu = (1 - pres_labels) + pres_labels * (
span_scores.argmax(dim=-1) == span_labels
).type_as(pres_scores)
span_list += [(span_loss, span_accu, node_active)]
else:
# continue
# TODO fix span-set and categorical-set
raise NotImplementedError
# from pprint import pprint
# pprint(pres_list, width=230)
pres_loss = torch.cat([l.unsqueeze(1) for l, a, act in pres_list], dim=1)
pres_loss = pres_loss.sum(dim=1)
pres_accu = torch.cat(
[((a * act) == act).unsqueeze(1).type_as(a) for l, a, act in pres_list], dim=1
)
pres_accu = pres_accu.sum(dim=1) == len(pres_list)
# categorical
cat_loss = torch.cat([l.unsqueeze(1) for l, a, act in cat_list], dim=1)
cat_loss = cat_loss.sum(dim=1)
cat_accu = torch.cat(
[((a * act) == act).unsqueeze(1).type_as(a) for l, a, act in cat_list], dim=1
)
cat_accu = cat_accu.sum(dim=1) == len(cat_list)
# spans
span_loss = torch.cat([l.unsqueeze(1) for l, a, act in span_list], dim=1)
span_loss = span_loss.sum(dim=1)
span_accu = torch.cat(
[((a * act) == act).unsqueeze(1).type_as(a) for l, a, act in span_list], dim=1
)
span_accu = span_accu.sum(dim=1) == len(span_list)
# aggregate
res = OrderedDict()
res["loss"] = span_loss + pres_loss + cat_loss
res["accuracy"] = (span_accu.long() + pres_accu.long() + cat_accu.long()) == 3
res["presence_loss"] = pres_loss
res["categorical_loss"] = cat_loss
res["span_loss"] = span_loss
res["presence_accuracy"] = pres_accu
res["categorical_accuracy"] = cat_accu
res["span_accuracy"] = span_accu
# from pprint import pprint
# pprint(res, width=230)
return res
# send a tensor or nested lists of tensors to cpu
def to_cpu(obj):
if type(obj) in [list, tuple]:
return [to_cpu(o) for o in obj]
else:
return obj.detach().cpu()
# runs the model over provided data. trains if optimizer is not None
def run_epoch(data_loader, model, loss, w2i, args, mode="train", data_type="", optimizer=None):
st_time = time()
n_batches = args.batches_per_epoch if mode == "train" else 4
tot_ct = 0
acc_ct = 0
global_dct = OrderedDict()
local_dct = OrderedDict()
res_list = []
for i in range(n_batches):
st_time = time()
batch_list = data_loader.next_batch(args.batch_size, mode, data_type)
# print("time for next batch: %r" % (time() - st_time))
st_time = time()
batch_list_cp = copy.deepcopy(batch_list)
# print("time for copy: %r" % (time() - st_time))
st_time = time()
# make batch on the deepcopy
s_ids, s_mask, s_len, t_list = make_batch(
batch_list_cp,
w2i,
args.cuda,
sentence_noise=args.sentence_noise if mode == "train" else 0.0,
)
# print("time for make batch: %r" % (time() - st_time))
st_time = time()
# make labels and active mask
active_nodes = model.make_labels(t_list, args.cuda)
# print("time for make labels: %r" % (time() - st_time))
st_time = time()
# run model
active_nodes_scores = model(s_ids, s_mask, s_len, recursion=args.recursion)
# print("time for fwd pass: %r" % (time() - st_time))
st_time = time()
# compute loss
loss_dct = loss(active_nodes)
# print("time for computing loss: %r" % (time() - st_time))
st_time = time()
loss_val = loss_dct["loss"].sum() / loss_dct["loss"].shape[0]
# print("time for computing loss val: %r" % (time() - st_time))
st_time = time()
if optimizer is not None:
optimizer.zero_grad()
loss_val.backward(retain_graph=True)
# print("time for loss backward: %r" % (time() - st_time))
st_time = time()
optimizer.step()
# print("time for opt step: %r" % (time() - st_time))
st_time = time()
data_loader.update_buffer(
[
example
for j, example in enumerate(batch_list)
if loss_dct["accuracy"][j].item() == 0
]
)
# print("time for update buffer: %r" % (time() - st_time))
for k, v in loss_dct.items():
global_dct[k] = global_dct.get(k, 0.0) + v.sum().item()
local_dct[k] = local_dct.get(k, 0.0) + v.sum().item()
tot_ct += loss_dct["loss"].shape[0]
acc_ct += loss_dct["loss"].shape[0]
# print the stats
if i % args.print_freq == 0:
tot_loss = global_dct["loss"]
tot_accu = global_dct["accuracy"]
logging.info("---- %d" % (i,))
print("---- %d" % (i,))
print(
"GLOBAL --- loss %.2f --- accu %d of %d --- time %.1f"
% (global_dct["loss"] / tot_ct, global_dct["accuracy"], tot_ct, time() - st_time)
)
print(
"LOCAL --- loss %.2f --- accu: full %d of %d -- intern %d -- cat %d -- span %d"
% (
local_dct["loss"] / acc_ct,
local_dct["accuracy"],
acc_ct,
local_dct["presence_accuracy"],
local_dct["categorical_accuracy"],
local_dct["span_accuracy"],
)
)
acc_ct = 0
for k in local_dct:
local_dct[k] = 0.0
print(
"EPOCH GLOBAL --- loss %.2f --- accu %d of %d = %.2f --- time %.1f"
% (
global_dct["loss"] / tot_ct,
global_dct["accuracy"],
tot_ct,
global_dct["accuracy"] / tot_ct,
time() - st_time,
)
)
logging.info(
"EPOCH GLOBAL --- loss %.2f --- accu %d of %d = %.2f --- time %.1f"
% (
global_dct["loss"] / tot_ct,
global_dct["accuracy"],
tot_ct,
global_dct["accuracy"] / tot_ct,
time() - st_time,
)
)
# end-to-end prediction
def predict_tree(model, sentence_list, w2i, args):
s_ids, s_mask, s_len, t_list = make_batch(
[(sentence_list, {})], w2i, args.cuda, sentence_noise=0.0
)
tree = model.predict_tree(s_ids, s_mask, s_len, args.recursion)
# map span indices back
if type(sentence_list) == str:
c_list = [sentence_list]
else:
# c_list = [" ".join(sentence_list[-i - 1].split()[1:]) for i in range(len(sentence_list))]
c_list = [sentence_list[-i - 1] for i in range(len(sentence_list))]
index_map = {}
tot_words = 0
for c_idx, c in enumerate(c_list):
for w_idx, w in enumerate(c.split()):
index_map[tot_words] = (c_idx, w_idx)
tot_words += 1
tot_words += 1
tree = reverse_map_spans(tree, index_map)
return tree
def reverse_map_spans(tree, span_map):
for k, v in tree.items():
if is_span(v):
l, (s, e) = v
l1, ls = span_map[s] if s in span_map else span_map[s + 1]
l2, le = span_map[e] if e in span_map else span_map[e - 1]
if l2 > l1:
le = ls + 1
tree[k] = (l1, (ls, le))
elif is_sub_tree(v):
tree[k] = reverse_map_spans(v, span_map)
else:
continue
return tree
def tree_equal(ground_truth, prediction, only_internal=False):
ground_truth.pop("has_attribute", None)
prediction.pop("has_attribute", None)
is_eq = all([k in ground_truth for k in prediction]) and all(
[k in prediction for k in ground_truth]
)
if not is_eq:
return is_eq
for k, v in ground_truth.items():
if only_internal:
if type(v) == dict: # internal node accuracy
is_eq = is_eq and tree_equal(v, prediction[k], only_internal)
else:
if type(v) == dict: # internal node accuracy
is_eq = is_eq and tree_equal(v, prediction[k])
elif type(v) == str:
is_eq = is_eq and (v == prediction[k])
elif type(v) in [list, tuple]:
if len(v) == 2 and type(v[0]) == int:
a, (b, c) = prediction[k] # prediction
# y, z = v
x, (y, z) = v # ground truth
is_eq = is_eq and ((a, b, c) == (x, y, z))
return is_eq
def compute_accuracy(model, examples, w2i, args, only_internal=False):
predicted = [
(sentence, ground_truth, predict_tree(model, sentence, w2i, args))
for sentence, ground_truth in examples
]
num_correct = len(
[
sentence
for sentence, ground_truth, prediction in predicted
if tree_equal(ground_truth, prediction, only_internal)
]
)
return num_correct / len(predicted)
def compute_accuracy_per_action_type(model, examples, w2i, args, only_internal=False):
predicted = [
(sentence, ground_truth, predict_tree(model, sentence, w2i, args))
for sentence, ground_truth in examples
]
action_type_stats = {}
for sentence, ground_truth, prediction in predicted:
action_type = ground_truth["action_type"]
# compute accuracy for each action type
if action_type not in action_type_stats:
action_type_stats[action_type] = [0.0, 0.0]
action_type_stats[action_type][1] += 1 # total
if tree_equal(ground_truth, prediction, only_internal):
action_type_stats[action_type][0] += 1 # correct
out = {}
for key in action_type_stats.keys():
val = action_type_stats[key][0] / action_type_stats[key][1]
out[key] = "{0:.3f}".format(val)
return out
def compute_stats(
ground_truth,
prediction,
total_internal,
correct_internal,
total_str,
correct_str,
total_span,
correct_span,
):
# only by value type
for k, v in ground_truth.items():
if type(v) == dict: # internal node accuracy
total_internal += 1
if k in prediction:
if type(prediction[k]) == dict:
# true positive
correct_internal += 1
(
total_internal,
correct_internal,
total_str,
correct_str,
total_span,
correct_span,
) = compute_stats(
v,
prediction[k],
total_internal,
correct_internal,
total_str,
correct_str,
total_span,
correct_span,
)
else:
(
total_internal,
correct_internal,
total_str,
correct_str,
total_span,
correct_span,
) = compute_stats(
v,
{},
total_internal,
correct_internal,
total_str,
correct_str,
total_span,
correct_span,
)
elif type(v) == str:
total_str += 1
if k not in prediction:
continue
if type(prediction[k]) == str:
correct_str += 1
elif type(v) in [list, tuple]:
total_span += 1
if k not in prediction:
continue
if type(prediction[k]) in [list, tuple]:
correct_span += 1
return total_internal, correct_internal, total_str, correct_str, total_span, correct_span
def compute_precision_recall(model, examples, w2i, args):
predicted = [
(sentence, ground_truth, predict_tree(model, sentence, w2i, args))
for sentence, ground_truth in examples
]
final_stats = {}
final_stats["intern"] = [0.0, 0.0, 0.0]
final_stats["str"] = [0.0, 0.0, 0.0]
final_stats["span"] = [0.0, 0.0, 0.0]
micro_stats_total = {}
micro_stats_total["intern"] = [0.0, 0.0, 0.0]
micro_stats_total["str"] = [0.0, 0.0, 0.0]
micro_stats_total["span"] = [0.0, 0.0, 0.0]
for sentence, ground_truth, prediction in predicted: # each example
(
total_intern_recall,
tp_intern_recall,
total_str_recall,
tp_str_recall,
total_span_recall,
tp_span_recall,
) = compute_stats(ground_truth, prediction, 0, 0, 0, 0, 0, 0)
(
total_intern_prec,
tp_intern_prec,
total_str_prec,
tp_str_prec,
total_span_prec,
tp_span_prec,
) = compute_stats(prediction, ground_truth, 0, 0, 0, 0, 0, 0)
stats_map = {}
stats_map["intern"] = [
tp_intern_prec,
total_intern_prec,
tp_intern_recall,
total_intern_recall,
]
stats_map["str"] = [tp_str_prec, total_str_prec, tp_str_recall, total_str_recall]
stats_map["span"] = [tp_span_prec, total_span_prec, tp_span_recall, total_span_recall]
# compute prec, recall and f1
vals = [0, 0, 0]
for key, val in stats_map.items():
# sum up tp, fp and fn for each key
tp = val[0] # or val[2]
fp = val[1] - val[0] # total_prec - tp
fn = val[3] - val[0] # total_recall - tp
micro_stats_total[key] = [x + y for x, y in zip(micro_stats_total[key], [tp, fp, fn])]
# now compute macro stats
if val[0] == 0 and val[1] == 0 and val[3] == 0:
vals = [1.0, 1.0, 1.0]
elif val[0] == 0 and (val[1] > 0 or val[3] > 0):
vals = [0.0, 0.0, 0.0]
else:
precision = val[0] / val[1]
recall = val[2] / val[3]
f1 = (2 * precision * recall) / (precision + recall)
vals = [precision, recall, f1]
final_stats[key] = [x + y for x, y in zip(final_stats[key], vals)]
macro_stats = {
key: ["{0:.3f}".format(item / len(examples)) for item in val]
for key, val in final_stats.items()
}
# compute micro stats
micro_stats = {}
for key, val in micro_stats_total.items():
tp, fp, fn = val
if tp == 0 and fp == 0 and fn == 0:
vals = [1.0, 1.0, 1.0]
elif tp == 0.0 and (fp > 0 or fn > 0):
vals = [0.0, 0.0, 0.0]
else:
precision = tp / (tp + fp)
recall = tp / (tp + fn)
f1 = (2 * precision * recall) / (precision + recall)
vals = [precision, recall, f1]
micro_stats[key] = ["{0:.3f}".format(x) for x in vals]
return macro_stats, micro_stats
| craftassist-master | python/base_agent/ttad/ttad_model/emnlp_model/my_optim.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from copy import deepcopy
# from pprint import pprint
import csv
import json
from spacy.lang.en import English
tokenizer = English().Defaults.create_tokenizer()
def word_tokenize(st):
return [(x.text, x.idx) for x in tokenizer(st)]
rephrases = []
for j in range(5):
with open("rephrase_%d.csv" % (j,)) as csvfile:
g_reader = csv.reader(csvfile)
for i, row in enumerate(g_reader):
if i > 0:
rephrases += [row[-2:]]
brackets = [("(", ")"), ("{", "}"), ("[", "]"), ("*", "*"), ("$", "$"), ("#", "#")]
bracket_chars = ["(", ")", "{", "}", "[", "]", "*", "$", "#"]
def remove_brackets(br_sen):
br_found = []
for bs, be in brackets:
if bs in br_sen:
idx_s = br_sen.index(bs)
br_right = br_sen[idx_s + 1 :]
# idx_s -= sum([c in bracket_chars for c in br_sen[:idx_s]])
idx_e = br_right.index(be)
# idx_e -= sum([c in bracket_chars for c in br_sen[:idx_e]])
br_pre = br_right[:idx_e]
if False:
br_str = " ".join([x[0] for x in word_tokenize(br_pre)])
else:
br_str = br_pre
br_found += [(idx_s + 1, idx_s + 1 + idx_e, br_str, bs)]
no_br = br_sen
for c in bracket_chars:
no_br = no_br.replace(c, " ")
sen_ls = [x for x in word_tokenize(no_br) if x[0].strip() != ""]
word_spans = []
for id_s, id_e, br_st, b in br_found:
idw_s = [n for w, n in sen_ls].index(id_s)
if sen_ls[-1][1] <= id_e:
idw_e = len(sen_ls) - 1
else:
idw_e = [n > id_e for w, n in sen_ls].index(True) - 1
word_spans += [(idw_s, idw_e, b, br_st)]
return (" ".join([w for w, n in sen_ls]), word_spans)
rep_processed = []
for i, (orig, rep) in enumerate(rephrases):
try:
rep_processed += [(orig, remove_brackets(orig), remove_brackets(rep))]
except:
print("MISSED", i)
# make trees for rephrased data
orig_valid = json.load(open("../bracketted_valid.json"))
rephrases = rep_processed
orig_dict = dict([(x[1], x) for x in orig_valid])
rephrase_trees = []
for i, (orig_br, (orig_nobr, orig_br_lst), (rep_nobr, rep_br_lst)) in enumerate(rephrases):
try:
orig_valid_nobr, orig_valid_br, orig_valid_br_lst, orig_valid_tree = orig_dict[orig_br]
rep_tree = deepcopy(orig_valid_tree)
list(rep_tree.values())[0]["description"] = rep_nobr
br_to_span = dict([(b, (id_b, id_e)) for id_b, id_e, b, _ in rep_br_lst])
for b, (node_path, span) in orig_valid_br_lst:
node = rep_tree
tag_path = node_path.split(" > ")
for k in tag_path[:-1]:
node = node[k]
node[tag_path[-1]] = br_to_span[b]
rephrase_trees += [(rep_nobr, rep_tree)]
except:
print("MISSED", i)
json.dump(rephrase_trees, open("../valid_rephrase_02_15.json", "w"))
| craftassist-master | python/base_agent/ttad/ttad_model/processing_scripts/read_rephrased.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
from pprint import pprint
from random import choice
from models import *
def read_generations(f_name):
res = []
f = open(f_name)
for line in f:
if line[0] == "{":
try:
a_tree = ActionTree()
a_tree_dict = json.loads(line.strip())
a_desc = list(a_tree_dict.values())[0]["description"]
del list(a_tree_dict.values())[0]["description"]
a_tree.read_tree_dict(a_tree_dict)
a_node = a_tree.root
read_dict(a_node, a_tree)
a_td = sorted(
write_top_down(a_node, len(a_desc.split())), key=lambda x: len(x["context"])
)
a_dfs = write_dfs(a_node)
a_mrf = write_mrf(a_node)
res += [
{
"action_description": a_desc,
"action_tree_dict": a_tree_dict,
"action_tree": a_tree,
"action_top_down": a_td,
"action_s2s_dfs": a_dfs,
"action_global_mrf": a_mrf,
}
]
except Exception as e:
print(e)
print(line)
break
f.close()
return res
generated_data = read_generations("example_trees.txt")
pprint(choice(generated_data), width=248)
| craftassist-master | python/base_agent/ttad/ttad_model/processing_scripts/read_data.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import json
import matplotlib.pyplot
import numpy as np
from scipy.ndimage import imread
import visdom
import pickle
# vis = visdom.Visdom(server ='http://localhost')
home_dir = '/private/home/aszlam'
f = open(home_dir + '/minecraft_specs/block_images/css_chunk.txt')
r = f.readlines()
l = r[0]
q = l.split('.items-28-')
g = open(home_dir + '/minecraft_specs/block_images/html_chunk.txt')
s = g.readlines()
name_to_bid = {}
bid_to_name = {}
for line in s:
c = line.find('"id">')
if c > 0:
d = line.find('<', c)
idlist = line[c+5:d].split(':')
if len(idlist) == 1:
idlist.append('0')
c = line.find('"name">')
if c > 0:
d = line.find('<', c)
name = line[c+7:d].lower()
bid = (int(idlist[0]), int(idlist[1]))
name_to_bid[name] = bid
bid_to_name[bid] = name
bid_to_offsets = {}
for line in q:
s = line.find('png)')
if s > 0:
t = line.find('no-')
offsets = line[s+5:t].replace('px','').split()
int_offsets = [int(offsets[0]), int(offsets[1])]
t = line.find('{')
ids = line[:t].split('-')
bid = (int(ids[0]), int(ids[1]))
bid_to_offsets[bid] = int_offsets
big_image = matplotlib.pyplot.imread(home_dir + '/minecraft_specs/block_images/all_blocks')
bid_to_image = {}
name_to_image = {}
for name in name_to_bid:
bid = name_to_bid[name]
offsets = bid_to_offsets[bid]
small_image = big_image[-offsets[1]:-offsets[1]+32,
-offsets[0]:-offsets[0]+32, :].copy()
bid_to_image[bid] = small_image
name_to_image[name] = small_image
out = {'bid_to_image':bid_to_image,
'name_to_image':name_to_image,
'bid_to_name':bid_to_name,
'name_to_bid':name_to_bid}
f.close()
g.close()
f = open(home_dir + '/minecraft_specs/block_images/block_data','wb')
pickle.dump(out, f)
f.close()
COLOR_NAMES = ['aqua', 'black', 'blue', 'fuchsia', 'green', 'gray', 'lime',
'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal',
'white', 'yellow', 'orange', 'brown', 'sienna', 'pink','light yellow',
'dark yellow','dark yellow', 'gold', 'gold']
COLORS = np.array((
(0.0, 1.0, 1.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
(1.0, 0.0, 1.0),
(0.0, .5, 0.0),
(.5, .5, .5),
(0.0, 1.0, 0.0),
(.5, 0.0, 0.0),
(0.0, 0.0, .5),
(.5, .5, 0.0),
(.5, 0, .5),
(1.0, 0.0, 0.0),
(.75, .75, .75),
(0.0, .5, .5),
(1.0, 1.0, 1.0),
(1.0, 1.0, 0.0),
(1.0, .65, 0.0),
(139/255, 69/255, 19/255),
(160/255, 82/255, 45/255),
(255/255, 192/255, 203/255),
(200/255, 200/255, 50/255),
(200/255, 200/255, 50/255),
(255/255, 255/255, 130/255),
(255/255, 215/255, 40/255),
(255/255, 215/255, 0/255)))
COLOR_NORMS = np.linalg.norm(COLORS, axis=1)**2
CMAP = {
'aqua': 'blue',
'black': 'black',
'blue': 'blue',
'fuchsia': 'purple',
'green': 'green',
'gray': 'gray',
'lime': 'green',
'maroon': 'red',
'navy': 'blue',
'olive': 'green',
'purple': 'purple',
'red': 'red',
'pink': 'pink',
'silver': 'silver',
'teal': 'blue',
'white': 'white',
'yellow': 'yellow',
'orange': 'orange',
'brown': 'brown',
'sienna': 'brown',
'gold': 'yellow',
'light yellow':'yellow',
'dark yellow':'yellow'
}
def get_colors(im):
cim = im[:,:,:3].astype('float32')
cim = cim.reshape(1024,3)
alpha = im[:,:,3].astype('float32')
alpha = alpha.reshape(1024)
cim /= 255
alpha /= 255
dists = np.zeros((1024, COLORS.shape[0]))
for i in range(1024):
for j in range(COLORS.shape[0]):
dists[i,j] = ((COLORS[j] - cim[i])**2).sum()
idx = dists.argmin(axis=1)
colors = {}
for i in range(1024):
if alpha[i] >.2:
if colors.get(COLOR_NAMES[idx[i]]) is None:
colors[COLOR_NAMES[idx[i]]] = 1
else:
colors[COLOR_NAMES[idx[i]]] += 1
if alpha.mean() < .4:
colors['translucent'] = True
return colors
name_to_colors = {}
colors_to_name = {}
name_to_simple_colors = {}
simple_colors_to_name = {}
# for i in name_to_image:
# c = get_colors(name_to_image[i])
# for j in c:
# if c[j] > 100:
# if name_to_colors.get(i) is None:
# name_to_colors[i] = [j]
# else:
# name_to_colors[i].append(j)
# if name_to_simple_colors.get(i) is None:
# name_to_simple_colors[i] = [CMAP[j]]
# else:
# name_to_simple_colors[i].append(CMAP[j])
# if colors_to_name.get(j) is None:
# colors_to_name[j] = [i]
# else:
# colors_to_name[j].append(i)
# if simple_colors_to_name.get(CMAP[j]) is None:
# simple_colors_to_name[CMAP[j]] = [i]
# else:
# simple_colors_to_name[CMAP[j]].append(i)
# out = {'name_to_colors':name_to_colors,
# 'name_to_simple_colors':name_to_simple_colors,
# 'colors_to_name':colors_to_name,
# 'simple_colors_to_name':simple_colors_to_name,
# 'cmap':CMAP}
# f = open(home_dir + '/minecraft_specs/block_images/color_data','wb')
# pickle.dump(out, f)
# f.close()
with open(home_dir + '/minecraft_specs/block_images/block_property_data.json') as f:
block_property_data = json.load(f)
name_to_properties = {}
properties_to_name = {}
for name in name_to_image:
if name in block_property_data:
properties = block_property_data[name]['properties']
for property in properties:
if name_to_properties.get(name) is None:
name_to_properties[name] = [property]
else:
name_to_properties[name].append(property)
if properties_to_name.get(property) is None:
properties_to_name[property] = [name]
else:
properties_to_name[property].append(name)
out = {'name_to_properties': name_to_properties,
'properties_to_name': properties_to_name}
f = open(home_dir + '/minecraft_specs/block_images/block_property_data','wb')
pickle.dump(out, f)
f.close()
with open(home_dir + '/minecraft_specs/block_images/mob_property_data.json') as f:
mob_property_data = json.load(f)
name_to_properties = {}
properties_to_name = {}
for name in name_to_image:
if name in mob_property_data:
properties = mob_property_data[name]['properties']
for property in properties:
if name_to_properties.get(name) is None:
name_to_properties[name] = [property]
else:
name_to_properties[name].append(property)
if properties_to_name.get(property) is None:
properties_to_name[property] = [name]
else:
properties_to_name[property].append(name)
out = {'name_to_properties': name_to_properties,
'properties_to_name': properties_to_name}
f = open(home_dir + '/minecraft_specs/block_images/mob_property_data','wb')
pickle.dump(out, f)
f.close()
'''
COLORS = {
'aqua': np.array((0.0, 1.0, 1.0)),
'black': np.array((0.0, 0.0, 0.0)),
'blue': np.array((0.0, 0.0, 1.0)),
'fuchsia': np.array((1.0, 0.0, 1.0)),
'green': np.array((0.0, .5, 0.0)),
'gray': np.array((.5, .5, .5)),
'lime': np.array((0.0, 1.0, 0.0)),
'maroon': np.array((.5, 0.0, 0.0)),
'navy': np.array((0.0, 0.0, .5)),
'olive': np.array((.5, .5, 0.0)),
'purple': np.array((.5, 0, .5)),
'red': np.array((1.0, 0.0, 0.0)),
'silver': np.array((.75, .75, .75)),
'teal': np.array((0.0, .5, .5)),
'white': np.array((1.0, 1.0, 1.0)),
'yellow': np.array((1.0, 1.0, 0.0)),
'orange': np.array((1.0, .65, 0.0)),
'brown': np.array((139/255 69/255 19/255)),
'sienna': np.array((160/255, 82/255, 45/255)),
'pink': np.array((255/255, 192/255, 203/255))
}
'''
| craftassist-master | minecraft_specs/block_images/read_images.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.