nltk.sem.glue module

class nltk.sem.glue.GlueFormula[source]

Bases: object

__init__(meaning, glue, indices=None)[source]
applyto(arg)[source]

self = (x.(walk x), (subj -o f)) arg = (john , subj) returns ((walk john), f)

make_VariableExpression(name)[source]
make_LambdaExpression(variable, term)[source]
lambda_abstract(other)[source]
compile(counter=None)[source]

From Iddo Lev’s PhD Dissertation p108-109

simplify()[source]
class nltk.sem.glue.GlueDict[source]

Bases: dict

__init__(filename, encoding=None)[source]
read_file(empty_first=True)[source]
to_glueformula_list(depgraph, node=None, counter=None, verbose=False)[source]
lookup(node, depgraph, counter)[source]
add_missing_dependencies(node, depgraph)[source]
get_semtypes(node)[source]

Based on the node, return a list of plausible semtypes in order of plausibility.

get_glueformulas_from_semtype_entry(lookup, word, node, depgraph, counter)[source]
get_meaning_formula(generic, word)[source]
Parameters
  • generic – A meaning formula string containing the parameter “<word>”

  • word – The actual word to be replace “<word>”

initialize_labels(expr, node, depgraph, unique_index)[source]
find_label_name(name, node, depgraph, unique_index)[source]
get_label(node)[source]

Pick an alphabetic character as identifier for an entity in the model.

Parameters

value (int) – where to index into the list of characters

lookup_unique(rel, node, depgraph)[source]

Lookup ‘key’. There should be exactly one item in the associated relation.

get_GlueFormula_factory()[source]
class nltk.sem.glue.Glue[source]

Bases: object

__init__(semtype_file=None, remove_duplicates=False, depparser=None, verbose=False)[source]
train_depparser(depgraphs=None)[source]
parse_to_meaning(sentence)[source]
get_readings(agenda)[source]
parse_to_compiled(sentence)[source]
dep_parse(sentence)[source]

Return a dependency graph for the sentence.

Parameters

sentence (list(str)) – the sentence to be parsed

Return type

DependencyGraph

depgraph_to_glue(depgraph)[source]
get_glue_dict()[source]
gfl_to_compiled(gfl)[source]
get_pos_tagger()[source]
class nltk.sem.glue.DrtGlueFormula[source]

Bases: nltk.sem.glue.GlueFormula

__init__(meaning, glue, indices=None)[source]
make_VariableExpression(name)[source]
make_LambdaExpression(variable, term)[source]
class nltk.sem.glue.DrtGlueDict[source]

Bases: nltk.sem.glue.GlueDict

get_GlueFormula_factory()[source]
class nltk.sem.glue.DrtGlue[source]

Bases: nltk.sem.glue.Glue

__init__(semtype_file=None, remove_duplicates=False, depparser=None, verbose=False)[source]
get_glue_dict()[source]
nltk.sem.glue.demo(show_example=- 1)[source]