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]

Returns all the possible categories for a word


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)}

  • token (string)

  • categ (string)

  • semantics (Expression)

__init__(token, categ, semantics=None)[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.


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


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


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.


Parse the subscripts for a primitive category