Add a special-case pattern rule for mmultiscripts
- Dominant language
- Rust
- Stars
- 114
- Forks
- 85
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 42
Description
Currently, mmultiscripts can't be handled in generality because there can be an arbitrary number of pre-/post-scripts. The code handles 2 prescripts and 4 postscripts and sort of punts by dumping out the rest without proper speech. No one ever writes that many scripts, so really the main problem is the ugliness of handling (2+4)*2 (sub/super) cases.
One way to deal with this is to add a special pattern match rule like:
```
-tag: mmultiscripts
- mmultiscripts:
base: xpath
prescript-sub: xpath
prescript-super: xpath
postscript-sub: xpath
postscript-super: xpath
```
I think that is most cases, only the positions matter. The xpath might in some cases need to check the number of pre/postscripts, if an entry is none, if the preceeding/following is none, or it is the first/only of scripts, but that is still doable and likely not too bad. Potentially `$Subscript` and `$Superscript` are defined to match the current pair so they can be referenced.
Internally the code would process the base first, then the prescripts (sub followed by super), and then do the same for the postscripts.
I have not checked to make sure this ordering works in all cases. If not, maybe some `process-order` key could be added that specifies the order.
Here's an example of handling prescripts taken from "en":
```
- test:
if: "not($Prescripts[1][self::m:none])"
then:
- x: "$PreSubscript"
- x: "$Prescripts[1]"
- test:
if: "not($Prescripts[1][self::m:none] or $Prescripts[2][self::m:none])"
then: [t: "and"] # phrase(10 is greater than 8 'and' less than 15)
- test:
if: "not($Prescripts[2][self::m:none])"
then:
- x: "$PreSuperscript"
- x: "$Prescripts[2]"
- pause: short
```
`$Prescripts` is a vector of all the prescripts.
`$PreSubscript` is either 'pre subscript' or 'pre sub', depending on verbosity.
This rule gets _copied_ for all the supported number of prescripts. A similar thing is done (and copied) for all the postscripts. This is what this new special-case would eliminate
With this pattern rule, this could be simply:
```
prescript-sub:
- test:
- if: "not($Subscript[self::m:none])"
then:
- x: "$PreSubscript"
- x: "$Subscript"
prescript-super:
- test:
if: "not($Subscript[self::m:none] or $Superscript[self::m:none] )"
then: [t: "and"]
- test:
- if: "not($Superscript[self::m:none])"
then:
- x: "$PreSuperscript"
- x: "$Superscript"
- pause: short
```
where the rule defines two variables `Subscript` and `Superscript` that refer to the current sub/sup pair.
_All_ prescripts would be handled by the above pattern. A similar thing would be done for the postscripts.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.