def pcfg(sentence): pcfg = PCFG() pcfg.readCFGRules(FilePath.ROOT + "rules.txt") #pcfg.showRules() pcfg.parse(sentence) pcfg.showTrees() pass
# !/usr/bin/env python3 # -*- coding: utf-8 -*- # -------------------------------------------# # main.py # # author: sean lee # # qq: 929325776 # # email: [email protected] # #--------------------------------------------# from pcfg import PCFG parser = PCFG() parser.fit('./corpus/toy/train.txt') parser.parse("the man saw the dog") ''' print(parser.N_dict) print(parser.NR_dict) print(parser.TR_dict) '''