# Create CNF Grammar cnf_ = CFG(start=Nonterminal('SIGMA'), productions=newrules) # In[25]: f = open('cnf_grammar.pkl', 'wb') pickle.dump(cnf_, f) f.close() # In[26]: # Check CNF print(cnf_.is_chomsky_normal_form()) # In[27]: # CNF Rules fin = list(cnf_.productions()) fin.sort(key=left_) # In[28]: f = open('atis_cnf.pkl', 'wb') pickle.dump(fin, f) f.close() # In[29]: