是否有带有非终结符参数的BNF? [英] Is there a BNF with arguments for non-terminal symbols?

查看:90
本文介绍了是否有带有非终结符参数的BNF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在与Prolog DCG一起解析输入时,很高兴有相应的语法BNF.

In working with Prolog DCG to parse input it is nice to have an accompaning BNF of the grammar.

例如:

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

as 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

However Prolog DCG can also have arguments as
in this example Number for singular or plural

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是否有包含非终结点参数的标准或公认扩展?

Is there a standard or accepted extension to BNF that includes arguments for non-terminals?

如果是这样,我需要一个链接.

If so I need a link to it.

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

I suspect that ATN (Augmented Transition Networks) are in the ball park and may be the only standard answer, but I am hoping for something that is linear text as opposed to some form vertex/edge graph.

推荐答案

我认为功能结构的概念是您要找的东西;在示例中显示的参数共享是更通用的特征结构统一方法的特例.

I think the concept of feature structures is what you're looking for; the sharing of arguments you show in your example is a special case of the more general feature structure unification approach.

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

I'm not aware of feature structure extensions for BNF specifically, but there are reasonably accepted notations for adding them to other grammar formalisms. The documentation for NLTK (a Python natural language processing library) has an example here of the notation they use. Here are some of their rules that correspond roughly to the first few productions from your example:

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手册的整个章节都包含对特征结构的一般描述,并提供了一些文献参考.

The ?x is their notation for logic variables. That entire chapter of the NLTK manual contains a general desciption of feature structures and includes some literature references.

这篇关于是否有带有非终结符参数的BNF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆