+ All Categories
Home > Documents > Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 ·...

Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 ·...

Date post: 08-Jul-2020
Category:
Upload: others
View: 18 times
Download: 0 times
Share this document with a friend
42
Combinatory Categorial Grammar (CCG) 11-711 Algorithms for NLP 30 November 2017 (With thanks to Alan W Black)
Transcript
Page 1: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

CombinatoryCategorialGrammar(CCG)

11-711AlgorithmsforNLP

30November2017

(WiththankstoAlanWBlack)

Page 2: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

GoalsofCCG

• Simplifythe(combinatory)rules• Movecomplexityfromrulesto(categorial)lexicalentries

• Moretightlycouplewithsemantics,particularlylambdacalculus

• One-to-onerelationshipbetweensyntacticandsemanticconstituents

Page 3: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Five(5)rules!

• Application:– Forward:A/B+B=A– Backward:B+A\B=A

• Composition:– A/B+B/C=A/C

• Coordination:– X CONJX’=X”

• Typeraising:– A=X/(X\A)

Page 4: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

John = np (an argument category)Mary = nplikes = (s\np)/np (a functor category)

Forward applicationX/Y Y => XBackward applicationY X\Y => X

Thus:John likes Marynp (s\np)/np np

--------------- Forwards\np

------------- Backwards

Page 5: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

a,the np/nold n/nin (np\np)/npman,ball,park nkicked (s\np)/np

the old man kicked a ball in the parknp/n n/n n (s\np)/np np/n n (np\np)/np np/n n

------n

Page 6: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

a,the np/nold n/nin (np\np)/npman,ball,park nkicked (s\np)/np

the old man kicked a ball in the parknp/n n/n n (s\np)/np np/n n (np\np)/np np/n n

------ ------- -------n np np

----------np

Page 7: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

a,the np/nold n/nin (np\np)/npman,ball,park nkicked (s\np)/np

the old man kicked a ball in the parknp/n n/n n (s\np)/np np/n n (np\np)/np np/n n

------ ------- -------n np np

---------- ------------------np np\np

-------------------------np

Page 8: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

a,the np/nold n/nin (np\np)/npman,ball,park nkicked (s\np)/np

the old man kicked a ball in the parknp/n n/n n (s\np)/np np/n n (np\np)/np np/n n

------ ------- -------n np np

---------- ------------------np np\np

-------------------------np

--------------------------s\np

--------------------------------s

Page 9: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

HandlingCoordination

• ConstituentCoordination– JohnandMarylikebooks

(NPandNP)VP– Johnlikesfishinganddislikesbaseball.

NP(VPandVP)• Non-constituentcoordination

– JohnlikesandMarydislikessports.???

Page 10: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

X CONJ X’ => X’’

John likes Mary and dislikes Bobnp (s\np)/np np conj (s\np)/np np

---------------FA ----------------FAs\np s\np

Coordination

Page 11: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

X CONJ X’ => X’’

John likes Mary and dislikes Bobnp (s\np)/np np conj (s\np)/np np

--------------FA --------------FAs\np s\np

---------------------------------------CONJs\np

---------------------------------------------BAs

Coordination

Page 12: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

TypeRaisingTR: X => Y/(Y\X)COMP: A/B + B/C => A/C

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR -------TRs/(s\np) s/(s\np)

Page 13: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

TypeRaisingTR: X => Y/(Y\X)COMP: A/B + B/C => A/C

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR -------TRs/(s\np) s/(s\np)-----------------COMP -----------------COMP

s/np s/np

Page 14: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

TypeRaisingTR: X => Y/(Y\X)COMP: A/B + B/C => A/C

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR -------TRs/(s\np) s/(s\np)------------------COMP ------------------COMP

s/np s/np---------------------------------------------- CONJ

s/np

Page 15: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

TypeRaisingTR: X => Y/(Y\X)COMP: A/B + B/C => A/C

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR -------TRs/(s\np) s/(s\np)------------------COMP ------------------COMP

s/np s/np--------------------------------------------- CONJ

s/np--------------------------------------------------

s

Page 16: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

TypeRaising

• Computationallyunbounded:– couldhappenforanycategory– makesparsingintractable

• Controlledtyperaising– needstobeguarded– only(some)lexicalitems

Page 17: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

CCGSemantics

• Remembergoals:–Moretightlycouplewithsemantics,particularlylambdacalculus

– One-to-onerelationshipbetweensyntacticandsemanticconstituents

• AddsemanticstoCCGrules– Lambdacalculus(again)

• “Montaguesemantics”

Page 18: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

A/B:S + B:T = A:S.TB:T + A\B:S = A:S.TJohn np:jwalks s\np: 𝜆X.walks(X)

John walksnp:j s\np: 𝜆X.walks(X)--------------------------

s : walks(j)

B:T + A\B:S = A:S . Tnp:j + s\np: 𝜆X.walks(X)s : 𝜆X.walks(X) . js : walks(j)

Page 19: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

A/B:S + B:T = A:S.TB:T + A\B:S = A:S.TJohn np:jwalks s\np: 𝝀X.walks(X)

John walksnp:j s\np: 𝜆X.walks(X)--------------------------

s : walks(j)

B:T + A\B:S = A:S . Tnp:j + s\np: 𝜆X.walks(X)s : 𝜆X.walks(X) . js : walks(j)

Page 20: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

A/B:S + B:T = A:S.TB:T + A\B:S = A:S.TJohn np:jwalks s\np: 𝜆X.walks(X)

John walksnp:j s\np: 𝝀X.walks(X)---------------------------

s : walks(j)

B:T + A\B:S = A:S . Tnp:j + s\np: 𝜆X.walks(X)s : 𝜆X.walks(X) . js : walks(j)

Page 21: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

A/B:S + B:T = A:S.TB:T + A\B:S = A:S.TJohn np:jwalks s\np: 𝜆X.walks(X)

John walksnp:j s\np: 𝜆X.walks(X)--------------------------

s : walks(j)

B:T + A\B:S = A:S . Tnp:j + s\np: 𝜆X.walks(X)s : 𝝀X.walks(X) . js : walks(j)

Page 22: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

John np:jMary np:mlikes (s\np)/np: 𝝀Y.𝝀X.likes(X,Y)

John likes Marynp:j (s\np)/np:𝜆Y.𝜆X.likes(X,Y) 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) . jlikes(j,m)

Page 23: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

John np:jMary np:mlikes (s\np)/np: 𝜆Y.𝜆X.likes(X,Y)

John likes Marynp:j (s\np)/np:𝝀Y.𝝀X.likes(X,Y) 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) . jlikes(j,m)

Page 24: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

John np:jMary np:mlikes (s\np)/np: 𝜆Y.𝜆X.likes(X,Y)

John likes Marynp:j (s\np)/np:𝜆Y.𝜆X.likes(X,Y) 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) . jlikes(j,m)

Page 25: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝝀S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝜆Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝜆R.(R . a)

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR ------TRs/(s\np) s/(s\np)-----------------COMP ------------------COMP

s/np s/np--------------------------------- CONJ

s/np---------------------------------

s

Page 26: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝜆S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝝀Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝜆R.(R . a)

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR ------TRs/(s\np) s/(s\np)-----------------COMP ------------------COMP

s/np s/np--------------------------------- CONJ

s/np---------------------------------

s

Page 27: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝜆S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝜆Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝝀R.(R . a)

John likes and Mary dislikes Bobnp (s\np)/np conj np (s\np)/np np------TR ------TRs/(s\np) s/(s\np)-----------------COMP ------------------COMP

s/np s/np--------------------------------- CONJ

s/np---------------------------------

s

Page 28: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝜆S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝝀Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝝀R.(R . a)

John likes ...np:j (s\np)/np: 𝝀Y.𝝀X.likes(X,Y)---TRs/(s\np): 𝝀R.(R . j)--------------------------COMPs/np:𝜆Q.( A . ( B . Q))𝜆Q.((𝜆R.(R . j)) . (𝜆Y.𝜆X.likes(X,Y) . Q))𝜆Q.((𝜆R.(R . j)) . ( 𝜆X.likes(X,Q) ))𝜆Q.( 𝜆X.likes(X,Q) . j )𝜆Q.( likes(j,Q) )

Page 29: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝜆S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝜆Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝜆R.(R . a)

... Mary dislikes ...np:m (s\np)/np:𝜆Y.𝜆X.dislikes(X,Y)---TRs/(s\np): 𝜆R.(R . m)--------------------------COMP

s/np:𝜆Q.( A . ( B . Q))𝜆Q.((𝜆R.(R . m)) . (𝜆Y.𝜆X.dislikes(X,Y) . Q))𝜆Q.((𝜆R.(R . m)) . (𝜆X.dislikes(X,Q) ))𝜆Q.( 𝜆X.dislikes(X,Q) . m )𝜆Q.( dislikes(m,Q) )

Page 30: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Coordination:X:A CONJ X’:A’ = X’’: 𝝀S.(A . S & A’. S)

Composition:X/Y:A Y/Z:B => X/Z: 𝜆Q.( A . (B . Q))

Type raising:NP:a -> T/(T\NP): 𝜆R.(R . a)

John likes and Mary dislikes Bob.... CONJ .... np:b

--------COMP --------COMPs/np: 𝜆Q.(likes(j,Q))

s/np: 𝜆Q.( dislikes(m,Q) )---------------------------- CONJ

s/np: 𝜆S.( 𝜆Q.(likes(j,Q)) . S &𝜆Q.(dislikes(m,Q)) . S )

s/np: 𝜆S.( likes(j,S) &dislikes(m,S) )

-----------------------COMPs: 𝜆S.( likes(j,S) & dislikes(m,S) ) . bs: likes(j,b) & dislikes(m,b)

Page 31: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

CompositionalityandIncrementality

• Compositionality:– allconstituentshaveadenotation

• Incrementality:– allinitialsubstringshaveadenotation– allsubstringshaveadenotation(stronger)

Page 32: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

CategoricalUnificationGrammar

• Extendingtheformalismtoallowfeatures:– agreement,grammaticalrelations

• EmbeddingCCGtechniquesinotherformalisms– SUBCAT,predicate/arguments

Page 33: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

the np/nboy nboys nwalk s\npwalks s\np

Forward applicationX/Y Y => XBackward applicationY X\Y => X

Thusthe boy walksnp/n n s\np----- FAnp----------- BA

s

Page 34: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

the [cat: np]/[cat: n]boy [cat: n]boys [cat: n]walk [cat: s]\[cat: np]walks [cat: s]\[cat: np]

Forward applicationX/Y Y => XBackward applicationY X\Y => X

Thusthe boy walks[cat: np]/[cat: n] [cat: n] [cat: s]\[cat: np]

----------------- FA[cat: np]

----------------- BA[cat: s]

Page 35: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

the [cat: np num: !X]/[cat: n num: !X]

boy [cat: n num: sg]boys [cat: n num: pl]walk [cat: s]\

[cat: np num: pl]walks [cat: s]\

[cat: np num: sg]

the boys walk[cat: np [cat: n [cat: s]\num: !X]/ num: pl] [cat: np

[cat: n num: pl]num: !X]

------------------- FA[cat: npnum: pl]

------------------------ BA[cat: s]

Page 36: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

the [cat: np num: !X]/[cat: n num: !X]

boy [cat: n num: sg]boys [cat: n num: pl]walk [cat: s]\

[cat: np num: pl]walks [cat: s]\

[cat: np num: sg]

the boy walks[cat: np [cat: n [cat: s]\num: !X]/ num: sg] [cat: np

[cat: n num: sg]num: !X]

------------------- FA[cat: npnum: sg]

------------------------ BA[cat: s]

Page 37: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

the [cat: np num: !X]/[cat: n num: !X]

boy [cat: n num: sg]boys [cat: n num: pl]walk [cat: s]\

[cat: np num: pl]walks [cat: s]\

[cat: np num: sg]

the boys walks[cat: np [cat: n [cat: s]\num: !X]/ num: pl] [cat: np

[cat: n num: sg]num: !X]

------------------- FA[cat: npnum: pl]

----------------- *****

Page 38: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

SUBCATFeature

• InGPSGandHPSG– SUBCATfeatureidentifiesfeaturesofarguments:

[SUBCAT[NP]]like+npfeatureinpreviouslecture

• ThisisactuallyCCG-like– S\NPisverblookingforoneargument– (S\NP)/NPisverblookingfortwoarguments

• CanbeextendedtofullSUBCATfeature– requiredPPs,VCOMP,etc.

Page 39: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Someproperties

• Mildlycontextsensitive• WeaklyequivalenttoLTAG(LexicalizedTAG)• Derived/gappedcategoriespreventnon-projectiveparses

• Complexity:– unrestrictedtyperaising:unbounded– restrictedtyperaising:O(n3)• (alsowithoutgeneralCoordination)

Page 40: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

Someotherpointsofinterest

• Freewordorderlanguages:“|”• Relationshiptointonation(Steedman 1991)• ExtensiontoLambek calculustoallowchangesinargumentorderandrealincr.processing

• CCGBank:JuliaHockenmaier andSteedman– CCGversionofPennTreebank

• PCCG:LukeZettlemoyer andCollins– Learntoproducelogicalformstatistically

Page 41: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,
Page 42: Combinatory Categorial Grammar (CCG)tbergkir/11711fa17/Combinatory Categorial... · 2017-11-30 · Categorical Unification Grammar •Extending the formalism to allow features: –agreement,

LearningaPCCG

• SeeslidesandvideoscourtesyofYoav Artzi,NicholasFitzGeraldandLukeZettlemoyer

• http://yoavartzi.com/tutorial/


Recommended