eta.lf.LF

class LF(formula)[source]

Bases: object

Defines an abstract logical form.

A logical form (whether ULF or ELF) must contain a formula, variable bindings, functions for binding/unbinding variables, for replacing variables, and for getting the formula (or a natural language representation thereof) after making all variable assignments.

Parameters:

formula (str or s-expr) – The formula for this logical form (an S-expression or LISP-formatted string representation thereof).

formula

The formula for this logical form.

Type:

s-expr

bindings

A mapping from variables to bound values.

Type:

dict

Methods

bind

Bind the given variable symbol to the given value.

get_formula

Get the formula, applying any variable assignments first.

replacevar

Replace the first variable symbol with the second variable symbol throughout the logical form.

to_nl

Convert the formula to a natural language string.

unbind

Unbind the given variable symbol.

bind(var, val)[source]

Bind the given variable symbol to the given value.

unbind(var)[source]

Unbind the given variable symbol.

replacevar(var1, var2)[source]

Replace the first variable symbol with the second variable symbol throughout the logical form.

get_formula()[source]

Get the formula, applying any variable assignments first.

to_nl()[source]

Convert the formula to a natural language string.

__str__()[source]

Return str(self).