def exhaustively_and_nonprobabilistically_export(self, nonterminal, filename):
"""Append to a tab-separated file lines specifying each of the templated lines of dialogue that
may be yielded by each of the possible terminal expansions of nonterminal.
"""
all_possible_expansions_of_this_symbol = (
self.exhaustively_and_nonprobabilistically_expand(nonterminal=nonterminal)
)
with open(filename, 'a') as export_tsv_file:
row_writer = csv.writer(
export_tsv_file, delimiter='\t', quotechar='|', quoting=csv.QUOTE_MINIMAL
)
for intermediate_derivation_object in all_possible_expansions_of_this_symbol:
row_writer.writerow(
[nonterminal, str(intermediate_derivation_object.expansion),
'^'.join(str(annotation) for annotation in list(intermediate_derivation_object.markup)),
['N/A', 'N/A']] # We write 'N/A' here to indicate that we did not expand probabilistically
)
评论列表
文章目录