Commit a825c1b4 authored by jfschaefer's avatar jfschaefer
Browse files

work-in-progress: Rework MObj. TODO: Figure out definite noun phrases

parent 17d4de27
......@@ -10,7 +10,7 @@ abstract FGrammar = MCats ** {
fstatement_to_statement : FStatement -> Statement;
fcomplexidentifier_to_mathcn : FComplexIdentifier -> MathCN; -- mi ( n ) => $ mi ( cn )
fexpr_fbinrel_fcid_fbinrel_fexpr_to_mathcn : -- introduces one identifier (like in 1 < n < 10)
FExpression -> FBinRelation -> FComplexIdentifier -> FBinRelation -> FExpression -> MathCN;
fcomplexidentifier_to_identifer : FComplexIdentifier -> Identifier; -- mi ( n ) => $ mi ( cn ) $
fexpr_fbinrel_fcid_fbinrel_fexpr_to_identifier : -- introduces one identifier (like in 1 < n < 10)
FExpression -> FBinRelation -> FComplexIdentifier -> FBinRelation -> FExpression -> Identifier;
}
......@@ -17,7 +17,8 @@ concrete FGrammarEng of FGrammar = MCatsEng, CatEng ** open ParadigmsEng, ResEng
_ => table { _ => table { _ => "???" } } };
_ => table { _ => table { _ => table { _ => "???" } } } } };
fcomplexidentifier_to_mathcn fci = mkMathCN_sg ("$" ++ fci ++ "$");
fexpr_fbinrel_fcid_fbinrel_fexpr_to_mathcn a r1 b r2 c =
mkMathCN_sg ("$" ++ (wrap_mml "mrow" (a ++ (wrap_mml "mo" r1) ++ b ++ (wrap_mml "mo" r2) ++ c)) ++ "$");
fcomplexidentifier_to_identifer fci = { s = "$" ++ fci ++ "$" }; -- mkMathCN_sg ("$" ++ fci ++ "$");
fexpr_fbinrel_fcid_fbinrel_fexpr_to_identifier a r1 b r2 c =
{ s = "$" ++ (wrap_mml "mrow" (a ++ (wrap_mml "mo" r1) ++ b ++ (wrap_mml "mo" r2) ++ c)) ++ "$" };
-- mkMathCN_sg ("$" ++ (wrap_mml "mrow" (a ++ (wrap_mml "mo" r1) ++ b ++ (wrap_mml "mo" r2) ++ c)) ++ "$");
}
......@@ -24,4 +24,5 @@ abstract MCats = {
FStatement; -- statement
MathCN; -- math common noun (e.g. $ mo ( n ) $)
Identifier; -- identifier (more restricted than MathCN)
}
concrete MCatsEng of MCats = open SyntaxEng in {
concrete MCatsEng of MCats = open SyntaxEng, ParamX in {
param
boolean = true | false;
lincat
-- natural language
PosNegPol = Pol;
DefMObj = NP;
MObj = CN;
MObj = {
core : CN; -- core of the declaration (e.g. "continuous function")
suffix : Number => Str; -- suffix (usually starting with a preposition, e.g. "on the real numbers") (number required for relative clauses)
prep1 : Str; -- preposition 1 (e.g. StrSome("from"))
prep2 : Str; -- preposition 2 (e.g. StrSom("to"))
hasp1 : boolean;
hasp2 : boolean;
};
MObjProp = AP;
Statement = Cl;
-- statement as sentence or relative sentence ("such that ...")
......@@ -22,4 +33,5 @@ concrete MCatsEng of MCats = open SyntaxEng in {
FStatement = Str;
MathCN = CN;
Identifier = { s : Str };
}
......@@ -4,26 +4,27 @@ abstract NGrammar = MCats, Grammar, Extra, ExtraEngAbs ** {
PosPol : PosNegPol;
NegPol : PosNegPol;
no_identifier : Identifier;
restrict_mobj : MObjProp -> MObj -> MObj; -- "even" -> "integer" -> "even integer"
mobj_such_that : MObj -> StatementFin -> MObj; -- "integer such that ..."
def_descr_mobj : MObj -> DefMObj; -- "cube" -> "the cube"
appo_mobj : MObj -> MathCN -> MObj; -- "an integer $ mi ( n ) $
it_pron_defmobj : DefMObj; -- "it"
exists_statement : MObj -> Statement; -- "integer" -> "there is an integer"
not_exists_statement : MObj -> Statement; -- "integer" -> "there is no integer"
eq_defmobj_defmobj : DefMObj -> DefMObj -> Statement; -- "the largest element is the maximum"
-- def_descr_mobj : MObj -> DefMObj; -- "cube" -> "the cube"
-- appo_mobj : MObj -> MathCN -> MObj; -- "an integer $ mi ( n ) $
-- it_pron_defmobj : DefMObj; -- "it"
--
exists_statement : MObj -> Identifier -> Statement; -- "integer" -> "there is an integer"
not_exists_statement : MObj -> Identifier -> Statement; -- "integer" -> "there is no integer"
-- eq_defmobj_defmobj : DefMObj -> DefMObj -> Statement; -- "the largest element is the maximum"
--
state : Statement -> PosNegPol -> StatementFin;
iff_statementfin : StatementFin -> StatementFin -> StatementFin;
and_statementfin : StatementFin -> StatementFin -> StatementFin;
or_statementfin : StatementFin -> StatementFin -> StatementFin;
def_defmobj_defmobj : DefMObj -> DefMObj -> Statement; -- "the empty set is the set without elements"
-- iff_statementfin : StatementFin -> StatementFin -> StatementFin;
-- and_statementfin : StatementFin -> StatementFin -> StatementFin;
-- or_statementfin : StatementFin -> StatementFin -> StatementFin;
-- def_defmobj_defmobj : DefMObj -> DefMObj -> Statement; -- "the empty set is the set without elements"
def_mobj_mobjprop : MObj -> MObjProp -> Definition; -- "an integer is called prime"
def_mobj_mobjprop : MObj -> Identifier -> MObjProp -> Definition; -- "an integer is called prime"
iff_definition : Definition -> StatementFin -> Definition; -- "... is called ... iff ..."
def_appo_is_mobj : MObj -> MathCN -> MObj -> Definition; -- "an alphabet $A$ is a finite set
def_mobj_is_mobj : MObj -> MObj -> Definition; -- "an alphabet $A$ is a finite set
utter_statement : StatementFin -> Utterance; -- essentially identity
utter_definition : Definition -> Utterance; -- essentially identity
......
concrete NGrammarEng of NGrammar = MCatsEng, GrammarEng, ExtraEng ** open SyntaxEng, ParadigmsEng in {
concrete NGrammarEng of NGrammar = MCatsEng, GrammarEng, ExtraEng ** open SyntaxEng, ParadigmsEng, UtilsEng, ResEng, ParamX in {
oper
call_V2A : V2A = mkV2A (mkV "call" "calls" "called" "called" "calling") noPrep;
lin
PosPol = GrammarEng.PPos;
NegPol = GrammarEng.PNeg;
no_identifier = { s = ""};
restrict_mobj prop obj = mkCN prop obj;
def_descr_mobj obj = mkNP the_Art obj;
mobj_such_that obj restr = mkCN obj restr.rs; -- (mkRS pol (mkRCl restr));
appo_mobj obj mcn = lin CN { s = \\number,case_ => obj.s ! number ! case_ ++ mcn.s ! number ! case_; g = obj.g };
it_pron_defmobj = mkNP it_Pron;
exists_statement obj = mkCl obj | ExistsNP (mkNP aSg_Det obj);
not_exists_statement obj = mkCl (mkNP no_Quant obj) | ExistsNP (mkNP no_Quant obj);
eq_defmobj_defmobj a b = mkCl a b;
restrict_mobj prop obj = mobjPrepMObjProp obj prop;
mobj_such_that obj restr = mobjAddSuffix obj restr.rs;
-- def_descr_mobj obj = mkNP the_Art obj;
-- appo_mobj obj mcn = lin CN { s = \\number,case_ => obj.s ! number ! case_ ++ mcn.s ! number ! case_; g = obj.g };
-- it_pron_defmobj = mkNP it_Pron;
--
exists_statement obj id = mkCl (DetCN aSg_Det (mobjToCN obj id)) | ExistsNP (DetCN aSg_Det (mobjToCN obj id)); -- ExistsNP (mkNP aSg_Det obj);
not_exists_statement obj id = mkCl (DetCN (DetQuant no_Quant NumSg) (mobjToCN obj id)) |
ExistsNP (DetCN (DetQuant no_Quant NumSg) (mobjToCN obj id));
-- eq_defmobj_defmobj a b = mkCl a b;
--
state stmt pol = { s = mkS pol stmt; rs = mkRS pol (mkRCl stmt) };
iff_statementfin a b = { s = mkS (mkConj "iff") a.s b.s; rs = mkRS (mkConj "iff") a.rs b.rs };
and_statementfin a b = { s = mkS (mkConj "and") a.s b.s; rs = mkRS (mkConj "and") a.rs b.rs };
or_statementfin a b = { s = mkS (mkConj "or") a.s b.s; rs = mkRS (mkConj "or") a.rs b.rs };
def_mobj_mobjprop obj prop = mkS (mkCl
(mkNP aSg_Det obj)
-- iff_statementfin a b = { s = mkS (mkConj "iff") a.s b.s; rs = mkRS (mkConj "iff") a.rs b.rs };
-- and_statementfin a b = { s = mkS (mkConj "and") a.s b.s; rs = mkRS (mkConj "and") a.rs b.rs };
-- or_statementfin a b = { s = mkS (mkConj "or") a.s b.s; rs = mkRS (mkConj "or") a.rs b.rs };
--
def_mobj_mobjprop obj id prop = mkS (mkCl
(DetCN aSg_Det (mobjToCN obj id)) -- (mkNP aSg_Det (mobjToCN obj))
(PastPartAP (mkVPSlash (mkV2A (mkV "call" "calls" "called" "called" "calling") noPrep) prop)));
-- iff_definition defi condition = lin S { s = "iff" }; -- better solution for this?
-- -- iff_definition defi condition = lin S { s = "iff" }; -- better solution for this?
iff_definition defi condition = lin S { s = defi.s ++ "iff" ++ condition.s.s }; -- better solution for this?
def_defmobj_defmobj a b = mkCl a b;
def_appo_is_mobj definiendum representative definiens =
mkS (mkCl (DetCN {- mkNP is for some reason ambiguous -}
aSg_Det (appo_mobj definiendum representative)) definiens);
-- def_defmobj_defmobj a b = mkCl a b;
def_mobj_is_mobj definiendum definiens =
mkS (mkCl (DetCN aSg_Det (mobjToCN definiendum)) (mobjToCN definiens));
-- mkS (mkCl (DetCN {- mkNP is for some reason ambiguous -}
-- aSg_Det (appo_mobj definiendum representative)) definiens);
--
utter_statement s = mkUtt s.s;
utter_definition s = mkUtt s;
--
--
-- copied from ExtendEng.gf
PastPartAP vp = {
s = \\a => vp.ad ! a ++ vp.ptp ++ vp.p ++ vp.c2 ++ vp.s2 ! a ++ vp.ext ;
......
-- natural language lexicon
abstract NLexicon = MCats, NLexiconMObj ** {
abstract NLexicon = MCats, NLexiconMObj, Cat ** {
fun
-- integer_MObj : MObj;
-- set_MObj : MObj;
......
This diff is collapsed.
resource UtilsEng = MCatsEng ** open SyntaxEng, ParadigmsEng, ResEng, ParamX in {
-- CONSTRUCTORS
oper
mkMObj_helper : N -> Str -> Str -> boolean -> boolean -> MObj
= \n,p1,p2,hp1,hp2 -> lin MObj {
core = mkCN n; -- core of the declaration (e.g. "continuous function")
suffix = \\n => ""; -- suffix (usually starting with a preposition, e.g. "on the real numbers")
prep1 = p1; -- preposition 1 (e.g. "from")
prep2 = p2; -- preposition 2 (e.g. "to")
hasp1 = hp1;
hasp2 = hp2;
};
mkMObj = overload {
mkMObj : N -> Str -> Str -> boolean -> boolean -> MObj
= mkMObj_helper;
mkMObj : Str -> MObj
= \s -> mkMObj_helper (mkN s) "" "" false false;
mkMObj : N -> MObj
= \n -> mkMObj_helper n "" "" false false;
};
-- MODIFIERS
oper
mobj_set_suffix : MObj -> (ParamX.Number => Str) -> MObj
= \mobj,s -> lin MObj {
core = mobj.core;
suffix = s;
prep1 = mobj.prep1;
prep2 = mobj.prep2;
hasp1 = mobj.hasp1;
hasp2 = mobj.hasp2;
};
mobjAddSuffix = overload {
mobjAddSuffix : MObj -> Str -> MObj
= \mobj,s -> mobj_set_suffix mobj (\\n => (mobj.suffix!n) ++ s);
mobjAddSuffix : MObj -> RS -> MObj
= \mobj,rs -> mobj_set_suffix mobj (table {
Sg => (mobj.suffix ! Sg) ++ (rs.s ! AgP3Sg Neutr);
Pl => (mobj.suffix ! Pl) ++ (rs.s ! AgP3Pl Neutr)
});
};
mobjPrepMObjProp : MObj -> MObjProp -> MObj
= \mobj,prop -> mobj ** { core = mkCN prop mobj.core };
mobjToCN = overload {
mobjToCN : MObj -> CN = \mobj ->
lin CN { s = \\number,case_ => mobj.core.s ! number ! case_ ++ mobj.suffix ! number; g = mobj.core.g };
mobjToCN : MObj -> Identifier -> CN = \mobj,id ->
lin CN { s = \\number,case_ => mobj.core.s ! number ! case_ ++ id.s ++ mobj.suffix ! number; g = mobj.core.g };
};
}
Supports Markdown
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