nltk.ccg.lexicon module

CCG Lexicons

class nltk.ccg.lexicon.CCGLexicon[source]

Bases: object

Class representing a lexicon for CCG grammars.

  • primitives: The list of primitive categories for the lexicon

  • families: Families of categories

  • entries: A mapping of words to possible categories

__init__(start, primitives, families, entries)[source]
categories(word)[source]

Returns all the possible categories for a word

start()[source]

Return the target category for the parser

class nltk.ccg.lexicon.Token[source]

Bases: object

Class representing a token.

token => category {semantics} e.g. eat => Svar[pl]/var {x y.eat(x,y)}

  • token (string)

  • categ (string)

  • semantics (Expression)

__init__(token, categ, semantics=None)[source]
categ()[source]
semantics()[source]
nltk.ccg.lexicon.augParseCategory(line, primitives, families, var=None)[source]

Parse a string representing a category, and returns a tuple with (possibly) the CCG variable for the category

nltk.ccg.lexicon.fromstring(lex_str, include_semantics=False)[source]

Convert string representation into a lexicon for CCGs.

nltk.ccg.lexicon.matchBrackets(string)[source]

Separate the contents matching the first set of brackets from the rest of the input.

nltk.ccg.lexicon.nextCategory(string)[source]

Separate the string for the next portion of the category from the rest of the string

nltk.ccg.lexicon.parseApplication(app)[source]

Parse an application operator

nltk.ccg.lexicon.parsePrimitiveCategory(chunks, primitives, families, var)[source]

Parse a primitive category

If the primitive is the special category ‘var’, replace it with the correct CCGVar.

nltk.ccg.lexicon.parseSubscripts(subscr)[source]

Parse the subscripts for a primitive category