liboleg-2010.1.10.0: An evolving collection of Oleg Kiselyov's Haskell modules

Lambda.CCG

Description

Combinatorial Categorical Grammar (CCG)

http://okmij.org/ftp/gengo/NASSLLI10

Synopsis

Documentation

data S Source

Syntactic categories: non-terminals of CCG

Instances

Show (JA S) 

data NP Source

data b :/ a Source

data b :\\ a Source

class Symantics repr whereSource

This class defines the syntax of our fragment (the grammar, essentially). Its instances will show interpretations of the grammar, or semantics

Methods

john :: repr NPSource

mary :: repr NPSource

like :: repr ((NP :\\ S) :/ NP)Source

(/) :: repr (b :/ a) -> repr a -> repr bSource

(\\) :: repr a -> repr (a :\\ b) -> repr bSource

Instances

Symantics JA

The following works but is unsatisfactory: we wish slashes to be interpreted only as concatenation!

Symantics EN 
Lambda lrepr => Symantics (Sem lrepr) 

data EN a Source

show the inferred types, as well as the inferred types for phrases like

The first sample sentence, or CCG derivation The inferred type is S. So, sen1 is a derivations of a complete sentence.

We now define the first interpretation of a CCG derivations: We interpret the derivation to give the parsed string. That is, we generate a yield of a CCG derivation, in English.

We represent each node in the derivation tree by an English phrase

Constructors

EN 

Fields

unEN :: String
 

Instances

Quantifier EN

But how to put a quantifier in an object position?

Symantics EN 
Show (EN a) 

type family Tr synt :: *Source

Show the English form of sen1

We now define semantics of a phrase represented by a derivation. It is a different interpretation of the phrase and its types.

We first interpret syntactic types (NP, slashes, etc) in terms of the types of the language of logic formulas. The type class Lambda defines the language of logic formulas (STT, or higher-order logic) with types Entity, Bool, and the arrows.

data Sem lrepr a Source

Constructors

Sem 

Fields

unSem :: lrepr (Tr a)
 

Instances

Lambda lrepr => Quantifier (Sem lrepr) 
Lambda lrepr => Symantics (Sem lrepr) 
Show (Sem (P C) a) 
Show (Sem C a) 

data JA a Source

We can now see the semantics of sen1

Computing the yield in Japanese

The type family TJ defines the types of sentential forms corresponding to syntactic categories.

We represent each node in the derivation tree by a Japanese phrase or a Japanese sentential form (that is, a phrase with holes). Contrast with the EN interpreter above.

Constructors

JA 

Fields

unJA :: TJ a
 

Instances

Quantifier JA

Japanese is challenging: like semantics

The expression for quantifiers ensures that no inverse reading is possible. Only linear reading.

Symantics JA

The following works but is unsatisfactory: we wish slashes to be interpreted only as concatenation!

Show (JA S) 

type family TJ a :: *Source

type QNP = S :/ (NP :\\ S)Source

The translation is certainly different: like corresponds to an adjective in Japanese.

Adding quantification; one way

class Symantics repr => Quantifier repr whereSource

We extend our earlier fragment with quantifiers everyone, someone We also add a combinator for raising the first argument of a TV

Methods

everyone :: repr QNPSource

someone :: repr QNPSource

lift_vt :: repr ((NP :\\ S) :/ NP) -> repr ((NP :\\ S) :/ QNP)Source

Instances

Quantifier JA

Japanese is challenging: like semantics

The expression for quantifiers ensures that no inverse reading is possible. Only linear reading.

Quantifier EN

But how to put a quantifier in an object position?

Lambda lrepr => Quantifier (Sem lrepr)