Combinatory Categorial Grammar (CCG) 11-711 Algorithms for NLP 22 October 2019 (With thanks to Alan W Black)
Goals of CCG • Simplify the ( combinatory ) rules • Move complexity from rules to ( categorial ) lexical entries • More tightly couple with semantics, particularly lambda calculus • One-to-one relationship between syntactic and semantic constituents
Five (5) rules! • Application: – Forward: A/B + B = A – Backward: B + A\B = A • Composition: – A/B + B/C = A/C • Coordination: – X CONJ X’ = X” • Type raising: – A = X/(X\A)
John = np (an argument category) Mary = np likes = (s\np)/np (a functor category) Forward application Forward application X/Y X/Y Y => X => X Backward application Backward application Y X Y X\Y => X Y => X Thus: Thus: John likes Mary np (s\np)/np np --------------- Forward s\np ------------- Backward s
a,the np/n old ld n/ n/n in (np\np)/np man,ball,park n kicked (s\np)/np the old old man kicked a ball in the park np/n n/n n/n n (s\np)/np np/n n (np\np)/np np/n n ---- ---- -- n
a,t ,the he np/n p/n old n/n in (np\np)/np man,ball,park n kicked (s\np)/np the he old man kicked a ball in the he park np/ p/n n/n n (s\np)/np np/n /n n (np\np)/np np/ p/n n ------ --- ----- ---- --- ----- ---- n np np np np ----- ----- ---- --- np np
a,the np/n old n/n in n ( (np np\np) p)/np /np man,ball,park n kicked (s\np)/np the old man kicked a ball in in the park np/n n/n n (s\np)/np np/n n (np (np\np) p)/n /np p np/n n ------ ------- ------- n np np ---------- --- ----- ----- ---- ---- ----- ----- --- np np\np np np ---- ---- ---- ---- ---- -- --- ----- ----- ---- ---- --- np np
a,the np/n old n/n in (np\np)/np man,ball,park n kic icked ked (s (s\np) p)/n /np the old man kicked a ball in the park np/n n/n n (s\np)/np np/n n (np\np)/np np/n n ------ ------- ------- n np np ---------- ------------------ np np\np ------------ ------------- np
Handling Coordination • Constituent Coordination – John and Mary like books (NP and NP) VP – John likes fishing and dislikes baseball. NP (VP and VP) • Non-constituent coordination – John likes and Mary dislikes sports. ???
Coordination X CONJ X’ => X’’ John lik likes es Mary Mary and dis dislikes likes Bob Bob np (s (s\np)/n np)/np np np conj (s (s\np)/np np)/np np np -------------- ------ --------FA FA ---- -------- ---- ------- --------FA FA s\np np s\np np
Coordination X CONJ X’ => X’’ John likes Mary and nd dislikes Bob np (s\np)/np np conj conj (s\np)/np np --------------FA --------- -----FA s\np s\np -------------- ------ --------------- --------------- ------------ ---- ---- ----CON CONJ s\np np ------------------------------------------- --BA s
Type Raising TR: X = TR: X => Y/(Y Y/(Y\X) X) COMP: A COMP: A/B + B/C B + B/C => A/C => A/C John John likes and Mary Mary dislikes Bob np np (s\np)/np conj np np (s\np)/np np ------ ------TR TR ------- ------TR TR s/(s s/(s\np np) s/(s s/(s\np np)
Type Raising TR: X = TR: X => Y/(Y Y/(Y\X) X) COMP: A COMP: A/B + B/C B + B/C => A/C => A/C John li John likes es and Mary d Mary dislikes islikes Bob np (s\np)/np conj np (s\np)/np np ------TR -------TR s/(s\np) s/(s\np) ------- --------------- ---------COMP COMP -- --------- --------------- -------COMP OMP s/np s/np s/np s/np
Type Raising TR: X = TR: X => Y/(Y Y/(Y\X) X) COMP: A COMP: A/B + B/C B + B/C => A/C => A/C John likes and and Mary dislikes Bob np (s\np)/np conj conj np (s\np)/np np ------TR -------TR s/(s\np) s/(s\np) ------------------COMP ------------------ COMP s/np s/np ------- --------------- --------------- --------------- --------------- ------------ ----
Type Raising TR: X = TR: X => Y/(Y Y/(Y\X) X) COMP: A COMP: A/B + B/C B + B/C => A/C => A/C John likes and Mary dislikes Bob Bob np (s\np)/np conj np (s\np)/np np np ------TR -------TR s/(s\np) s/(s\np) ------------------COMP ------------------ COMP s/np s/np --------------------------------------------
Type Raising • Computationally unbounded: – could happen for any category – makes parsing intractable • Controlled type raising – needs to be guarded – only allowed for some lexical items
CCG Semantics • Remember goals: – More tightly couple with semantics, particularly lambda calculus – One-to-one relationship between syntactic and semantic constituents • Add semantics to CCG rules – Lambda calculus (again) • “Montague semantics”
A/B:S A/B:S + B:T + B:T = A = A:S.T S.T B:T + A B:T + A\B:S = :S = A:S.T A:S.T John np:j walks s\np: 𝜇 X.walks(X) John walks s\np: 𝜇 X.walks(X) np:j -------------------------- s : walks(j) B:T + A\B:S = A:S . T np:j + s\np: 𝜇 X.walks(X) s : 𝜇 X.walks(X) . j s : walks(j)
A/B:S + B:T = A:S.T B:T + A\B:S = A:S.T John John np:j np:j np: 𝝁 X.walk walks walks s\np: alks(X s(X) John walks s\np: 𝜇 X.walks(X) np:j -------------------------- s : walks(j) B:T + A\B:S = A:S . T np:j + s\np: 𝜇 X.walks(X) s : 𝜇 X.walks(X) . j s : walks(j)
A/B:S + B:T = A:S.T B:T + A\B:S = A:S.T John np:j walks s\np: 𝜇 X.walks(X) John walks alks np: 𝝁 X.walks( np:j s\np: lks(X) -------------- --------------------------- ------------- s : : wal walks(j s(j) B:T + A\B:S = A:S . T np:j + s\np: 𝜇 X.walks(X) s : 𝜇 X.walks(X) . j s : walks(j)
A/B:S + B:T = A:S.T B:T + A\B:S = A:S.T John np:j walks s\np: 𝜇 X.walks(X) John walks s\np: 𝜇 X.walks(X) np:j -------------------------- s : walks(j) B:T + A\B:S = A:S . T np:j + s\np: 𝜇 X.walks(X) s : 𝝁 X.wa s : X.walks(X ks(X) . j ) . j s : walks(j) s : walks(j)
John np:j Mary np:m : 𝝁 Y. Y. 𝝁 X.li likes likes (s\np np)/ )/np np: X.likes(X,Y kes(X,Y) John likes Mary (s\np)/np: 𝜇 Y. 𝜇 X.likes(X,Y) np:j m ------------------------------- ------- s\np: 𝜇 X.likes(X,m) ----------------------------------------- s likes(j,m) 𝜇 Y. 𝜇 X.likes(X,Y) . m 𝜇 X.likes(X,m) 𝜇 X.likes(X,m) . j
John np:j Mary np:m likes (s\np)/np: 𝜇 Y. 𝜇 X.likes(X,Y) John likes likes Mary p)/np: 𝝁 Y. 𝝁 X.likes np:j (s (s\np)/np: likes(X,Y) X,Y) m -- --------- --------------- --------------- -------------- ------ ------- ------- np: 𝝁 X.l s\np: X.likes(X ikes(X,m) ------------------------------------------ s likes(j,m) 𝜇 Y. 𝜇 X.likes(X,Y) . m 𝜇 X.likes(X,m) 𝜇 X.likes(X,m) . j
John np:j Mary np:m likes (s\np)/np: 𝜇 Y. 𝜇 X.likes(X,Y) John likes likes Mary (s\np)/np: 𝜇 Y. 𝜇 X.likes(X,Y) m np:j -------------------------------- ------ np: 𝝁 X.li s\np: X.likes(X, kes(X,m) ------- --------------- --------------- --------------- --------------- ---------- -- s like s likes(j,m j,m) 𝜇 Y. 𝜇 X.likes(X,Y) . m 𝜇 X.likes(X,m) 𝜇 X.likes(X,m) . j
Coordi Coordination: tion: CONJ X’:A’ = X’’: 𝝁 S.( X:A CONJ S.(A . S & A’. S) S) Composi Composition: ion: X/Y:A Y/Z:B => X/Z: 𝜇 Q.( A . (B . Q)) Type ra Type raising: sing: NP:a -> T/(T\NP): 𝜇 R.(R . a) John likes and Mary dislikes Bob np (s\np)/np conj np (s\np)/np np ------TR ------TR s/(s\np) s/(s\np) -----------------COMP ------------------COMP s/np s/np --------------------------------- CONJ s/np --------------------------------- s
Coordi Coordination: tion: X:A CONJ X’:A’ = X’’: 𝜇 S.(A . S & A’. S) Composi Composition: ion: X/Y:A Y/Z:B => X/Z: 𝝁 Q. Q.( A . (B . Q)) Type ra Type raising: sing: NP:a -> T/(T\NP): 𝜇 R.(R . a) John likes and Mary dislikes Bob np (s\np)/np conj np (s\np)/np np ------TR ------TR s/(s\np) s/(s\np) -----------------COMP ------------------COMP s/np s/np --------------------------------- CONJ s/np --------------------------------- s
Coordi Coordination: tion: X:A CONJ X’:A’ = X’’: 𝜇 S.(A . S & A’. S) Composi Composition: ion: X/Y:A Y/Z:B => X/Z: 𝜇 Q.( A . (B . Q)) Type ra Type raising: sing: NP:a -> T/(T\NP): 𝝁 R.(R R.(R . a) John likes and Mary dislikes Bob np (s\np)/np conj np (s\np)/np np ------TR ------TR s/(s\np) s/(s\np) -----------------COMP ------------------COMP s/np s/np --------------------------------- CONJ s/np --------------------------------- s
Recommend
More recommend