我正在开发一个项目,需要帮助为Simile构建一个无上下文语法(词性)。如果有人能告诉我从哪里开始或给我一些提示!
完成的工作
grammar = CFG.fromstring("""
S -> NP "like" NP | "JJ" "like" "NP" | NP V "like" NP | "EX" "like" "NN" | NP "as" "JJ" "as" NP | V "as" "JJ" "as" NP | "as" NP "as"| OTH
NP -> N | "JJ" N | "DT" NP | "NNS" N
N -> "NNP" | "PRP" | "NN"
V -> "VBD" | "VB" | "VBG"
OTH -> "OTH" "PUNC" "FW" "WDT" "TO" "RB" "VBD" "VBG" "LS" "VBN" "NN" "IN" "S" "EX" "VB" "CC" "UH" "PRP" "MD"
""")
这是用蛮力方法制作的,