GATE JAPE 规则优先级不受尊重

GATE JAPE rule priorities not respected

我有以下文字:

1 hwb wert: 330 kWh

第一步,以下映射为定位点:

330 kWh 映射为:Lookup.major = "unit"

hwb wert映射为:Lookup.major = "keyword"

JAPE 规则:

Phase: composedUnits
Input: Token Lookup
Options: control=appelt debug=true

Rule: TableRow
Priority:10
 (
  ({Lookup.majorType == "keyword"})
  ({Token.kind == punctuation})[0,4]
  ({Lookup.majorType == "unit"})
 )

Rule: ReversedTableRow
Priority: -2
(
 ({Token.kind == number})
 ({Lookup.majorType == "keyword"})
)

我不明白为什么匹配 ReversedTableRow-规则而不匹配 TableRow

appelt 优先级仅适用于相同的文本区域(例如较早的比赛获胜和较长的比赛获胜)。前面的规则使用的文本不能被后面的规则匹配...

来自the documentation

With the appelt style, only one rule can be fired for the same region of text, according to a set of priority rules. Priority operates in the following way.

  1. From all the rules that match a region of the document starting at some point X, the one which matches the longest region is fired.
  2. If more than one rule matches the same region, the one with the highest priority is fired
  3. If there is more than one rule with the same priority, the one defined earlier in the grammar is fired.

...

Note also that depending on the control style, firing a rule may ‘consume’ that part of the text, making it unavailable to be matched by other rules. This can be a problem for example if one rule uses context to make it more specific, and that context is then missed by later rules, having been consumed due to use of for example the ‘Brill’ control style.



规则TableRow可以通过以下修改赢得更长的时间,注意我添加了:tableRow标签,其中不包括前导数字标记。

(
 ({Token.kind == number})?
 (
  ({Lookup.majorType == "keyword"})
  ({Token.kind == punctuation})[0,4]
  ({Lookup.majorType == "unit"})
 ):tableRow
)