Assignment Task
1. Question concerns CFGs and their parsing
- (a) Assume the following outline of a CHART class:
- class CHART {
- public:
- /* a member ’chart’ such that chart[i][k] is the chart’s content concerning
- start = i, length = k */
- Grammar g;
- vector<string> input; // sequence to parse
- void initialize(); // set chart dimensions then put in length 1 entries
- void do_cell(int i, int k); // fill in all entries at chart[i][k]
- bool is_there(int i, int k, Category c); // check for c at chart[i][k]
- void add_edge(int i, int k, Category c); // add c to chart[i][k] if not there
- };
- The CHART::chart member is left underspecified: it must encode a 2-dimensional
- start-vs-length table, each slot of which represents a collection of Category objects.
- After CHART::initialize() has added all the length 1 entries,
- CHART::do_cell(i,k) is the central method of the CKY algorithm, repeatedly called
- in a nested loop structure. For start position i, length k, it should put every category
- C into chart[i][k] which is implied by rules applied to existing entries for shorter
- lengths k
- 0
- at appropriate positions. Provide an implementation of this method
- (assuming is there(..) and add edge(..) are already implemented). [15 marks]
- (b) Assuming the underspecified CHART::chart member is actually declared
- vector<vector<vector<Category>>> chart;
- give implementations of CHART::is there(..) and CHART::add(..). [7 marks]
- (c) let G1 be the grammar:
- initial(vp)
- vp --> va,np,[to],vp
- vp --> vb,np
- va --> [order]
- vb --> [find]
- np --> [it]
- np --> [him]
- i. The backtracking version of the top-down parser will accept ‘order him to find it’.
- Give its sequence of words+stack configurations (including some commentary on
- backtracking). [5 marks]
- ii. Give an example of a left-recursive grammar and a trace of an execution of the
- top-down algorithm failing to terminate when using it.
This IT Assignment has been solved by our IT Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment Experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.