This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Sparrowhawk 1.0, with new serialization.
- Loading branch information
Showing
58 changed files
with
3,368 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+317 KB
documentation/grammars/en_toy/verbalize_serialization/CARDINAL_NUMBER_NAME
Binary file not shown.
Binary file added
BIN
+323 KB
documentation/grammars/en_toy/verbalize_serialization/ORDINAL_NUMBER_NAME
Binary file not shown.
69 changes: 69 additions & 0 deletions
69
documentation/grammars/en_toy/verbalize_serialization/date.grm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import '../byte.grm' as b; | ||
import '../util.grm' as u; | ||
import 'numbers.grm' as n; | ||
|
||
# quotation mark | ||
q = u.q; | ||
|
||
# Used to allow for different numbers of spaces coming out of the serializer. | ||
s = u.s; | ||
|
||
month = b.kAlpha+; | ||
|
||
day = n.ORDINAL; | ||
|
||
d = b.kDigit; | ||
D = b.kDigit - "0"; | ||
|
||
two_digit = | ||
((D d) @ n.CARDINAL) | ||
| ("0" : "oh ") (D @ n.CARDINAL) | ||
| ("00" : "hundred") | ||
; | ||
|
||
# Years are not read as cardinals, generally: | ||
year = | ||
(("19" @ n.CARDINAL) u.I[" "] two_digit) | ||
| (("20" @ n.CARDINAL) u.I[" "] ((D d) @ two_digit)) | ||
| (("200" d) @ n.CARDINAL) | ||
; | ||
|
||
# Remove these if they occur | ||
|
||
field = (b.kAlpha | "_")+; | ||
preserve_order = "preserve_order:true"; | ||
field_order = "field_order:" field; | ||
field_order_specs = (preserve_order | field_order)*; | ||
|
||
# Verbalization for MDY | ||
mdy = | ||
u.D["date"] | ||
u.D["|month:"] | ||
month | ||
u.I[" the "] | ||
u.D["|day:"] | ||
day | ||
u.I[" "] | ||
u.D["|year:"] | ||
year | ||
u.D[field_order_specs]? | ||
u.D["|"] | ||
; | ||
|
||
# Verbalization for DMY | ||
dmy = | ||
u.D["date"] | ||
u.I["the "] | ||
u.D["|day:"] | ||
day | ||
u.I[" of "] | ||
u.D["|month:"] | ||
month | ||
u.D["|year:"] | ||
u.I[" "] | ||
year | ||
u.D[field_order_specs]? | ||
u.D["|"] | ||
; | ||
|
||
export DATE = Optimize[mdy | dmy]; |
39 changes: 39 additions & 0 deletions
39
documentation/grammars/en_toy/verbalize_serialization/measure.grm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import '../byte.grm' as b; | ||
import '../util.grm' as u; | ||
import 'numbers.grm' as n; | ||
|
||
# Except with exactly 1, the plural form is used, so we map to that form, and | ||
# then singularize below. | ||
measures = | ||
("centimeter" : "centimeters") | ||
| ("kilogram" : "kilograms") | ||
| ("degree" : "degrees") | ||
; | ||
|
||
# quotation mark | ||
q = u.q; | ||
|
||
# Used to allow for different numbers of spaces coming out of the serializer. | ||
s = u.s; | ||
|
||
# Removes the markup (allowing for various spacing possibilities in the | ||
# serialization) and verbalizes the remainder. | ||
measure = | ||
u.D["measure"] | ||
u.D["|integer_part:"] | ||
n.CARDINAL | ||
(u.D["|fractional_part:"] | ||
u.I[" point "] | ||
n.DIGITS)? | ||
u.I[" "] | ||
u.D["|units:"] | ||
measures | ||
u.D["|"] | ||
; | ||
|
||
sigstar = b.kBytes*; | ||
|
||
# Uses the singular form after exactly "one". | ||
singularize = CDRewrite[Invert[measures], "[BOS]one ", "", sigstar]; | ||
|
||
export MEASURE = Optimize[measure @ singularize]; |
Oops, something went wrong.