是否有带有非终端符号参数的 BNF



在使用Prolog DCG解析输入时,最好有一个语法的伴随BNF。

例如:

生物固氮

<Sentence> ::= <Noun_phrase> <Verb_phrase>
<Noun_phrase> ::= <Determiner> <Noun>
<Verb_phrase> ::= <Verb> <Phrase>
<Determiner> ::= a
<Determiner> ::= the
<Noun> ::= cat
<Noun> ::= mouse
<Verb> ::= scares
<Verb> ::= hates

作为Prolog DCG

sentence --> noun_phrase, verb_phrase.
verb_phrase --> verb, noun_phrase.
noun_phrase --> determiner, noun.
determiner --> [a].
determiner --> [the].
noun --> [cat].
noun --> [mouse].
verb --> [scares].
verb --> [hates].

然而,Prolog DCG也可以有参数作为
在此示例中,Number用于singularplural

sentence(Number) --> noun_phrase(Number), verb_phrase(Number).
verb_phrase(Number) --> verb(Number), noun_phrase(Number).
noun_phrase(Number) --> determiner(Number), noun(Number).
determiner(singular) --> [a].
determiner(singular) --> [the].
determiner(plural) --> [the].
noun(singular) --> [cat].
noun(plural) --> [cats].
noun(singular) --> [mouse].
noun(plural) --> [mice].
verb(singular) --> [scares].
verb(plural) --> [scare].
verb(singular) --> [hates].
verb(plural) --> [hate].

是否有一个标准或公认的 BNF 扩展,其中包括非终端的参数?

如果是这样,我需要它的链接。

我怀疑ATN(增强过渡网络)在球场上,可能是唯一的标准答案,但我希望是线性文本而不是某种形式的顶点/边缘图。

我认为特征结构的概念就是你正在寻找的;你在例子中展示的参数的共享是更一般的特征结构统一方法的一个特例。

我不知道 BNF 的具体特征结构扩展,但有合理接受的符号将它们添加到其他语法形式中。NLTK(Python 自然语言处理库)的文档在这里有一个他们使用的符号示例。以下是他们的一些规则,大致对应于示例中的前几个产品:

S -> NP[CASE=nom, AGR=?a] VP[AGR=?a]
VP[AGR=?a] -> TV[OBJCASE=?c, AGR=?a] NP[CASE=?c]
NP[CASE=?c, AGR=?a] -> Det[CASE=?c, AGR=?a] N[CASE=?c, AGR=?a]

?x是逻辑变量的表示法。NLTK手册的整个章节都包含了对特征结构的一般描述,并包括一些文献参考。

最新更新