mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
test with numerals
This commit is contained in:
34
lib/resource-0.6/abstract/Numerals.gf
Normal file
34
lib/resource-0.6/abstract/Numerals.gf
Normal file
@@ -0,0 +1,34 @@
|
||||
-- numerals from 1 to 999999 in decimal notation
|
||||
|
||||
abstract Numerals = {
|
||||
|
||||
flags startcat=Numeral ;
|
||||
|
||||
cat
|
||||
Numeral ; -- 0..
|
||||
Digit ; -- 2..9
|
||||
Sub10 ; -- 1..9
|
||||
Sub100 ; -- 1..99
|
||||
Sub1000 ; -- 1..999
|
||||
Sub1000000 ; -- 1..999999
|
||||
|
||||
fun
|
||||
num : Sub1000000 -> Numeral ;
|
||||
|
||||
n2, n3, n4, n5, n6, n7, n8, n9 : Digit ;
|
||||
|
||||
pot01 : Sub10 ; -- 1
|
||||
pot0 : Digit -> Sub10 ; -- d * 1
|
||||
pot110 : Sub100 ; -- 10
|
||||
pot111 : Sub100 ; -- 11
|
||||
pot1to19 : Digit -> Sub100 ; -- 10 + d
|
||||
pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9
|
||||
pot1 : Digit -> Sub100 ; -- d * 10
|
||||
pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n
|
||||
pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99
|
||||
pot2 : Sub10 -> Sub1000 ; -- m * 100
|
||||
pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n
|
||||
pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999
|
||||
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
|
||||
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
|
||||
}
|
||||
5
lib/resource-0.6/abstract/TestResourceNum.gf
Normal file
5
lib/resource-0.6/abstract/TestResourceNum.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
abstract TestResourceNum = TestResource, Numerals ** {
|
||||
|
||||
fun UseNumeral : Numeral -> Num ;
|
||||
|
||||
} ;
|
||||
31
lib/resource-0.6/english/NumeralsEng.gf
Normal file
31
lib/resource-0.6/english/NumeralsEng.gf
Normal file
@@ -0,0 +1,31 @@
|
||||
concrete NumeralsEng of Numerals = open NumeralsResEng in {
|
||||
|
||||
lincat Digit = {s : DForm => Str} ;
|
||||
lincat Sub10 = {s : DForm => Str} ;
|
||||
|
||||
lin num x = x ;
|
||||
lin n2 = mkNum "two" "twelve" "twenty" ;
|
||||
lin n3 = mkNum "three" "thirteen" "thirty" ;
|
||||
lin n4 = mkNum "four" "fourteen" "forty" ;
|
||||
lin n5 = mkNum "five" "fifteen" "fifty" ;
|
||||
lin n6 = regNum "six" ;
|
||||
lin n7 = regNum "seven" ;
|
||||
lin n8 = mkNum "eight" "eighteen" "eighty" ;
|
||||
lin n9 = regNum "nine" ;
|
||||
|
||||
lin pot01 = {s = table {f => "one"}} ;
|
||||
lin pot0 d = {s = table {f => d.s ! f}} ;
|
||||
lin pot110 = ss "ten" ;
|
||||
lin pot111 = ss "eleven" ;
|
||||
lin pot1to19 d = {s = d.s ! teen} ;
|
||||
lin pot0as1 n = {s = n.s ! unit} ;
|
||||
lin pot1 d = {s = d.s ! ten} ;
|
||||
lin pot1plus d e = {s = d.s ! ten ++ "-" ++ e.s ! unit} ;
|
||||
lin pot1as2 n = n ;
|
||||
lin pot2 d = {s = d.s ! unit ++ "hundred"} ;
|
||||
lin pot2plus d e = {s = d.s ! unit ++ "hundred" ++ "and" ++ e.s} ;
|
||||
lin pot2as3 n = n ;
|
||||
lin pot3 n = {s = n.s ++ "thousand"} ;
|
||||
lin pot3plus n m = {s = n.s ++ "thousand" ++ m.s} ;
|
||||
|
||||
}
|
||||
12
lib/resource-0.6/english/NumeralsResEng.gf
Normal file
12
lib/resource-0.6/english/NumeralsResEng.gf
Normal file
@@ -0,0 +1,12 @@
|
||||
resource NumeralsResEng = {
|
||||
|
||||
param DForm = unit | teen | ten ;
|
||||
|
||||
oper mkNum : Str -> Str -> Str -> {s : DForm => Str} =
|
||||
\two -> \twelve -> \twenty ->
|
||||
{s = table {unit => two ; teen => twelve ; ten => twenty}} ;
|
||||
oper regNum : Str -> {s : DForm => Str} =
|
||||
\six -> mkNum six (six + "teen") (six + "ty") ;
|
||||
oper ss : Str -> {s : Str} = \s -> {s = s} ;
|
||||
|
||||
}
|
||||
7
lib/resource-0.6/english/TestResourceNumEng.gf
Normal file
7
lib/resource-0.6/english/TestResourceNumEng.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
--# -path=.:../abstract:../../prelude
|
||||
|
||||
concrete TestResourceNumEng of TestResourceNum = TestResourceEng, NumeralsEng ** {
|
||||
|
||||
lin UseNumeral n = {s = \\_ => n.s} ; ---- Case
|
||||
|
||||
} ;
|
||||
Reference in New Issue
Block a user