Attention: Maintenance on monday 19.04.2021 from 07:00 - 13:00 (Gitlab and Mattermost are offline!)

Commit c09b7db9 authored by jfschaefer's avatar jfschaefer

reduced number of parse trees in GF and added another example sentence

parent 2927e316
......@@ -4,48 +4,60 @@ abstract MathLex = Cat ** {
MathExpr;
MathBinRel; -- binary relation
MathBinOp; -- binary operator
MathUnOp; -- unary operator
MathPrefixedAdj; -- like "_-dimensional"
fun
positive_A : A ;
prime_A : A ;
cartesian_A : A ;
element_N : N ;
integer_N : N ;
product_N : N ;
space_N : N ;
set_N : N ;
dimensional_MPA : MathPrefixedAdj;
three_PN : PN;
call_V2A : V2A; -- we call it prime
call_V3 : V3; -- we call it an integer
iff_Subj : Subj;
appo : N -> MathNP -> N;
AdvSInEnd : Adv -> S -> S;
-- for the Math Grammar
mathPrefixAdj : MathNP -> MathPrefixedAdj -> A;
applyRel : MathBinRel -> MathExpr -> MathExpr -> MathExpr;
applyOp : MathBinOp -> MathExpr -> MathExpr -> MathExpr;
mathIndex : MathExpr -> MathExpr -> MathExpr;
exprToMathNP : MathExpr -> MathNP; -- an integer $i$
exprToCl : MathExpr -> Cl; -- since $m = n$
exprToN : MathExpr -> N; -- for all $n \in A$
divides_MathBinRel : MathBinRel;
power_MathBinOp : MathBinOp;
xtimes_MathBinOp : MathBinOp;
lessThan_MathBinRel : MathBinRel;
equals_MathBinRel : MathBinRel;
i_MathExpr : MathExpr;
n_MathExpr : MathExpr;
m_MathExpr : MathExpr;
ldots_MathExpr : MathExpr;
bigA_MathExpr : MathExpr;
one_MathExpr : MathExpr;
cartesian_A : A ;
positive_A : A ;
ordered_A : A ;
finite_A : A ;
total_A : A ;
prime_A : A ;
even_A : A ;
permutation_N : N;
element_N : N ;
integer_N : N ;
product_N : N ;
space_N : N ;
sign_N : N ;
set_N : N ;
dimensional_MPA : MathPrefixedAdj;
three_PN : PN;
call_V2A : V2A; -- we call it prime
call_V3 : V3; -- we call it an integer
iff_Subj : Subj;
else_Adv : Adv;
otherwise_Adv : Adv;
-- appo : N -> MathNP -> N;
AdvSInEnd : Adv -> S -> S;
-- for the Math Grammar
mathPrefixAdj : MathNP -> MathPrefixedAdj -> A;
applyRel : MathBinRel -> MathExpr -> MathExpr -> MathExpr;
applyBinOp : MathBinOp -> MathExpr -> MathExpr -> MathExpr;
applyUnOp : MathUnOp -> MathExpr -> MathExpr;
mathIndex : MathExpr -> MathExpr -> MathExpr;
exprToMathNP : MathExpr -> MathNP; -- an integer $i$
exprToCl : MathExpr -> Cl; -- since $m = n$
exprToN : MathExpr -> N; -- for all $n \in A$
divides_MathBinRel : MathBinRel;
power_MathBinOp : MathBinOp;
xtimes_MathBinOp : MathBinOp;
neg_MathUnOp : MathUnOp;
lessThan_MathBinRel : MathBinRel;
equals_MathBinRel : MathBinRel;
i_MathExpr : MathExpr;
n_MathExpr : MathExpr;
m_MathExpr : MathExpr;
sigma_MathExpr : MathExpr;
ldots_MathExpr : MathExpr;
bigA_MathExpr : MathExpr;
one_MathExpr : MathExpr;
}
......@@ -11,17 +11,24 @@ lincat
MathExpr = Str;
MathBinRel = Str;
MathBinOp = Str;
MathUnOp = Str;
MathPrefixedAdj = A;
lin
cartesian_A = regA "cartesian" ;
positive_A = regA "positive" ;
ordered_A = regA "ordered";
finite_A = regA "finite" ;
total_A = regA "total" ;
prime_A = regA "prime" ;
cartesian_A = regA "cartesian" ;
even_A = regA "even" ;
permutation_N = regN "permutation" ;
integer_N = regN "integer" ;
element_N = regN "element" ;
product_N = regN "product" ;
space_N = regN "space" ;
sign_N = regN "sign" ;
set_N = regN "set" ;
dimensional_MPA = regA "dimensional" ;
......@@ -31,17 +38,24 @@ lin
call_V2A = mkV2A (mkV "call" "calls" "called" "called" "calling") noPrep ;
call_V3 = mkV3 "call" ;
iff_Subj = mkSubj "iff";
else_Adv = mkAdv "else";
otherwise_Adv = mkAdv "otherwise";
appo n a = lin N {s = \\x,y => n.s ! x ! y ++ a; g=n.g};
-- appo n a = lin N {s = \\x,y => n.s ! x ! y ++ a; g=n.g};
AdvSInEnd a s = lin S { s = s.s ++ a.s } ;
-- for the Math Grammar
mathPrefixAdj mathnp adj = lin A { s = \\x => mathnp ++ "-" ++ adj.s ! x };
applyRel rel a b = a ++ rel ++ b; -- e.g. "m < n"
applyOp op a b = a ++ op ++ b; -- e.g. "m + n"
applyBinOp op a b = a ++ op ++ b; -- e.g. "m + n"
applyUnOp op a = op ++ a; -- e.g. "- n"
exprToMathNP expr = "$" ++ expr ++ "$";
mathIndex a b = a ++ "_" ++ b;
exprToCl expr = { s = table { _ => table { _ => table { _ => table { _=> "$" ++ expr ++ "$" } } } } }; --TODO: At least exclude negative polarity!!
exprToCl expr = { s = table {
Pres => table {
Simul => table { CPos => table { _ => "$" ++ expr ++ "$" }; _ => table { _ => "???" } };
_ => table { _ => table { _ => "???" } } };
_ => table { _ => table { _ => table { _ => "???" } } } } };
exprToN expr = lin N { s = table { _ => table { _ => "$" ++ expr ++ "$" } } ; g = Neutr };
-- N = {s : Number => Case => Str ; g : Gender} ;
......@@ -51,9 +65,11 @@ lin
equals_MathBinRel = "=";
power_MathBinOp = "^";
xtimes_MathBinOp = "\\times";
neg_MathUnOp = "-";
i_MathExpr = "i";
n_MathExpr = "n";
m_MathExpr = "m";
sigma_MathExpr = "\\sigma";
ldots_MathExpr = "\\ldots";
bigA_MathExpr = "A";
one_MathExpr = "1";
......
import MathEng.gf
parse "we call a positive integer $ n $ prime , iff there is no integer $ 1 < m < n $ such that $ m \\divides n $"
parse "the empty set is the set withouth elements"
parse "the empty set is the set without elements"
parse "we call a set empty , iff it is the empty set"
-- Warning: the following sentence has very many parse trees! (last time I checked: 467712)
-- Warning: the following sentences have very many parse trees!
-- parse "we call an $ n $ - dimensional cartesian product $ A _ 1 \\times \\ldots \\times A _ n $ an $ n $ - dimensional cartesian space , iff $ A _ i = A $ for some set $ A $ for all $ i $"
-- parse "the sign of a permutation $ \\sigma $ of a finite totally ordered set is $ 1 $ if $ \\sigma $ is even and $ 1 $ else"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment