【问题标题】:Is there a BNF with arguments for non-terminal symbols?是否有带有非终结符号参数的 BNF?
【发布时间】:2017-01-10 17:54:53
【问题描述】:

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

例如:

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 也可以有参数为
在此示例中,Numbersingularplural

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(增强转换网络)在球场上,可能是唯一的标准答案,但我希望是线性文本而不是某种形式的顶点/边图。

【问题讨论】:

标签: prolog nlp grammar bnf dcg


【解决方案1】:

我认为feature structures 的概念是您正在寻找的;您在示例中展示的参数共享是更通用的特征结构统一方法的一个特例。

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

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

【讨论】:

  • 我发现有趣的是,我越是寻找标准方法来做到这一点,我就越相信 Prolog DCG 可能是在线性文本中表示这些概念的更好方法。我确实认为边/顶点图更好,但是当以纯文本方式(例如使用源代码)记录时,图表不起作用,因此需要。你的回答帮助我学习。
  • 感兴趣的:Feature Structure Unification Grammars - FSUGs are very compact and abstract in comparison to DCGs and the difference is even more marked when compared to CFGs.
  • 感兴趣的:Feature Structures & Unification - 有很好的文本表示和统一跟踪示例。搜索Unification trace:
  • 现在我将只使用 Prolog DCG。在研究细节的过程中,我学到了一些东西。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-09
  • 1970-01-01
  • 2018-01-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多