100 likes | 189 Views
Bottom-up Syntactic Recognition and Chart Parsing. Chart Parsing. Well-Formed Substring Table WFST The main idea is the following: Once we have found a component of language it doesn’t have to be found again .
E N D
Chart Parsing Well-Formed Substring Table WFST • The main idea is the following: • Once we have found a component of language it doesn’t have to be found again. • A WFST is a mechanism enabling a parser to keep record of structures it has already found.
Syntactic ambiguity S VP NP NP PP NP Vt Pron Det Noun Prop Det Noun They hear the report on the travel
Syntactic ambiguity S VP NP PP NP NP Vt Pron Det Noun Prop Det Noun They hear the report on the travel
The active chart … ? VP vt NP S needing VP NP vt det noun they hear the report … 0 1 2 3 4 We can represent the chart as a list of structures of the form: <0,1, they.>, <0,1, NP they.>, <0,1,SNP.VP>, …
The fundamental rule of chart parsing Fundamental Rule If the chart contains edges: <i, j, AW1. B W2> and <j, k, BW3.> where A and B are categories and W1, W2 and W3 are (possible empty) sequences of categories or words, then add edge: <i, k, AW1 B. W2> to the chart.
Rule invocation Bottom-up Rule If you are adding edge <i, j, CW1. > to the chart, then for every rule in the grammar of the form B C W2, add and edge <i, i, B.C W2> to the chart.
Prolog implementation of chart parsing Edges edge(Start, Finish, Label, ToFind, Found). Initial Chart start_chart(V0, V0,[]). start_chart(V0, Vn, [Word| Words]) :- V1 is V0+1, foreach(word(Category,Word), add_edge(V0, V1, Category, [], [Word, Category])), start_chart(V1, Vn, Words).
Prolog implementation of chart parsing add_edge(V0, V1, Category, Categories, Parse) :- edge(V0, V1, Category, Categories, Parse), !. add_edge(V1, V2, Category1, [], Parse) :- asserta(edge(V1, V2, Category1, [], Parse), foreach(rule(Category2, [Category1|Categories]), add_edge(V1, V1, Category2, [Category1|Categories], [Category2])). Fundamental Rule foreach(edge(V0, V1, Category1, [Category1|Categories], Parses), add_edge(V0, V2, Category2, Categories, [Parse | Parses])). add_edge(V0, V1, Category1, [Cagegory2 | Categories], Parses) :- asserta(edge(V0, V1, Category1, [Category2 | Categories] , Parses)), foreach(edge(V1, V2, Category2, [], Parse), add_edge(V0, V2, Category1, Categories, [Parse | Parses])).
Prolog implementation of chart parsing test test(String) :- V0 is 1, Start_chart(V0, Vn, String), foreach(edge(V0, Vn, Symbol, [], Parse), write(Parse)), retractall(edge(_,_,_,_,_)).