mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 11:18:55 -06:00
resource = resource-1.0
This commit is contained in:
5
lib/resource-0.9/Makefile
Normal file
5
lib/resource-0.9/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
all:
|
||||
gf +RTS -K10M -M1012M <MkResource.gfs
|
||||
# gf +RTS -K10M <MkResource.gfs
|
||||
clean:
|
||||
rm -f */*.gfc */*.gfr
|
||||
27
lib/resource-0.9/README
Normal file
27
lib/resource-0.9/README
Normal file
@@ -0,0 +1,27 @@
|
||||
23/1/2005 -- 21/12/2005
|
||||
|
||||
GF Resource Grammar Library Version 0.9
|
||||
|
||||
The contents of this directory are open source software
|
||||
under GNU General Public License (See LICENCE).
|
||||
|
||||
Authors (c): Janna Khegai (Russian), Aarne Ranta.
|
||||
|
||||
For more information, see doc/gf-resource.html.
|
||||
|
||||
To compile a gfcm package, type 'make'. Then open the resource
|
||||
with either of
|
||||
|
||||
gf langs.gfcm
|
||||
|
||||
gfeditor langs.gfcm
|
||||
|
||||
VERSION NOTICE: this resource grammar library is at the moment of
|
||||
writing the most complete one. It supersedes and includes
|
||||
v 0.6 (../resource-0.6) in all other respects except that
|
||||
it is not implemented for German.
|
||||
|
||||
HOWEVER, this library is no longer developed, but the
|
||||
development has been moved to v 1.0 (../resource-1.0).
|
||||
V 1.0 will replace v 0.9 during Winter and Spring 2006.
|
||||
|
||||
31
lib/resource-0.9/abstract/Lang.gf
Normal file
31
lib/resource-0.9/abstract/Lang.gf
Normal file
@@ -0,0 +1,31 @@
|
||||
--# -path=.:../../prelude
|
||||
|
||||
abstract Lang =
|
||||
Rules,
|
||||
Clause,
|
||||
Structural,
|
||||
Basic,
|
||||
Time,
|
||||
Country,
|
||||
Math
|
||||
|
||||
** {
|
||||
|
||||
flags startcat=Phr ;
|
||||
|
||||
fun
|
||||
|
||||
-- Mount $Time$.
|
||||
|
||||
AdvDate : Date -> Adv ;
|
||||
AdvTime : Time -> Adv ;
|
||||
NWeekday : Weekday -> N ;
|
||||
PNWeekday : Weekday -> PN ;
|
||||
|
||||
-- Mount $Country$.
|
||||
|
||||
PNCountry : Country -> PN ;
|
||||
ANationality : Nationality -> A ;
|
||||
NLanguage : Language -> N ;
|
||||
|
||||
}
|
||||
103
lib/resource-0.9/abstract/Structural.gf
Normal file
103
lib/resource-0.9/abstract/Structural.gf
Normal file
@@ -0,0 +1,103 @@
|
||||
--1 GF Resource Grammar API for Structural Words
|
||||
--
|
||||
-- AR 21/11/2003
|
||||
--
|
||||
-- Here we have some words belonging to closed classes and appearing
|
||||
-- in all languages we have considered.
|
||||
-- Sometimes they are not really meaningful, e.g. $we_NP$ in Spanish
|
||||
-- should be replaced by masculine and feminine variants.
|
||||
|
||||
abstract Structural = Categories, Numerals ** {
|
||||
|
||||
fun
|
||||
|
||||
-- First mount the numerals.
|
||||
|
||||
UseNumeral : Numeral-> Num ;
|
||||
|
||||
-- Then an alphabetical list of structural words
|
||||
|
||||
above_Prep : Prep ;
|
||||
after_Prep : Prep ;
|
||||
all8mass_Det : Det ;
|
||||
all_NDet : NDet ;
|
||||
almost_Adv : AdA ;
|
||||
although_Subj : Subj ;
|
||||
and_Conj : Conj ;
|
||||
because_Subj : Subj ;
|
||||
before_Prep : Prep ;
|
||||
behind_Prep : Prep ;
|
||||
between_Prep : Prep ;
|
||||
both_AndConjD : ConjD ;
|
||||
by8agent_Prep : Prep ;
|
||||
by8means_Prep : Prep ;
|
||||
can8know_VV : VV ;
|
||||
can_VV : VV ;
|
||||
during_Prep : Prep ;
|
||||
either8or_ConjD : ConjD ;
|
||||
every_Det : Det ;
|
||||
everybody_NP : NP ;
|
||||
everything_NP : NP ;
|
||||
everywhere_Adv : Adv ;
|
||||
from_Prep : Prep ;
|
||||
he_NP : NP ;
|
||||
how_IAdv : IAdv ;
|
||||
how8many_IDet : IDet ;
|
||||
i_NP : NP ;
|
||||
if_Subj : Subj ;
|
||||
in8front_Prep : Prep ;
|
||||
in_Prep : Prep ;
|
||||
it_NP : NP ;
|
||||
many_Det : Det ;
|
||||
most_Det : Det ;
|
||||
most8many_Det : Det ;
|
||||
much_Det : Det ;
|
||||
must_VV : VV ;
|
||||
no_Phr : Phr ;
|
||||
on_Prep : Prep ;
|
||||
or_Conj : Conj ;
|
||||
otherwise_Adv : AdC ;
|
||||
part_Prep : Prep ;
|
||||
possess_Prep : Prep ;
|
||||
quite_Adv : AdA ;
|
||||
she_NP : NP ;
|
||||
so_Adv : AdA ;
|
||||
some_Det : Det ;
|
||||
some_NDet : NDet ;
|
||||
somebody_NP : NP ;
|
||||
something_NP : NP ;
|
||||
somewhere_Adv : Adv ;
|
||||
that_Det : Det ;
|
||||
that_NP : NP ;
|
||||
therefore_Adv : AdC ;
|
||||
these_NDet : NDet ;
|
||||
they8fem_NP : NP ;
|
||||
they_NP : NP ;
|
||||
this_Det : Det ;
|
||||
this_NP : NP ;
|
||||
those_NDet : NDet ;
|
||||
thou_NP : NP ;
|
||||
through_Prep : Prep ;
|
||||
to_Prep : Prep ;
|
||||
too_Adv : AdA ;
|
||||
under_Prep : Prep ;
|
||||
very_Adv : AdA ;
|
||||
want_VV : VV ;
|
||||
we_NP : NP ;
|
||||
what8many_IP : IP ;
|
||||
what8one_IP : IP ;
|
||||
when_IAdv : IAdv ;
|
||||
when_Subj : Subj ;
|
||||
where_IAdv : IAdv ;
|
||||
which8many_IDet : IDet ;
|
||||
which8one_IDet : IDet ;
|
||||
who8many_IP : IP ;
|
||||
who8one_IP : IP ;
|
||||
why_IAdv : IAdv ;
|
||||
with_Prep : Prep ;
|
||||
without_Prep : Prep ;
|
||||
ye_NP : NP ;
|
||||
yes_Phr : Phr ;
|
||||
you_NP : NP ;
|
||||
|
||||
}
|
||||
22
lib/resource-0.9/danish/LangDan.gf
Normal file
22
lib/resource-0.9/danish/LangDan.gf
Normal file
@@ -0,0 +1,22 @@
|
||||
--# -path=.:../scandinavian:../abstract:../../prelude
|
||||
|
||||
concrete LangDan of Lang =
|
||||
RulesDan,
|
||||
ClauseDan,
|
||||
StructuralDan,
|
||||
BasicDan,
|
||||
TimeDan,
|
||||
CountryDan
|
||||
|
||||
** open Prelude, ParadigmsDan in {
|
||||
|
||||
lin
|
||||
AdvDate d = prefixSS "på" d ;
|
||||
AdvTime t = prefixSS "klokken" t ;
|
||||
NWeekday w = w ;
|
||||
PNWeekday w = nounPN w ;
|
||||
|
||||
PNCountry x = x ;
|
||||
ANationality x = x ;
|
||||
NLanguage x = x ;
|
||||
}
|
||||
4
lib/resource-0.9/danish/MathDan.gf
Normal file
4
lib/resource-0.9/danish/MathDan.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
--# -path=.:../scandinavian:../abstract:../../prelude
|
||||
|
||||
concrete MathDan of Math = CategoriesDan **
|
||||
MathScand with (SyntaxScand=SyntaxDan) ;
|
||||
266
lib/resource-0.9/danish/MorphoDan.gf
Normal file
266
lib/resource-0.9/danish/MorphoDan.gf
Normal file
@@ -0,0 +1,266 @@
|
||||
--1 A Simple Danish Resource Morphology
|
||||
--
|
||||
-- Aarne Ranta 2002
|
||||
--
|
||||
-- This resource morphology contains definitions needed in the resource
|
||||
-- syntax. It moreover contains copies of the most usual inflectional patterns
|
||||
-- as defined in functional morphology (in the Haskell file $RulesSw.hs$).
|
||||
--
|
||||
-- We use the parameter types and word classes defined for morphology.
|
||||
|
||||
resource MorphoDan = open Prelude, TypesDan in {
|
||||
|
||||
-- Danish grammar source: http://users.cybercity.dk/~nmb3879/danish.html
|
||||
|
||||
-- nouns
|
||||
|
||||
oper
|
||||
mkSubstantive : (_,_,_,_ : Str) -> {s : SubstForm => Str} =
|
||||
\dreng, drengen, drenge, drengene -> {s = table {
|
||||
SF Sg Indef c => mkCase dreng ! c ;
|
||||
SF Sg Def c => mkCase drengen ! c ;
|
||||
SF Pl Indef c => mkCase drenge ! c ;
|
||||
SF Pl Def c => mkCase drengene ! c
|
||||
}
|
||||
} ;
|
||||
|
||||
mkCase : Str -> Case => Str = \bil -> table {
|
||||
Nom => bil ;
|
||||
Gen => bil + "s" --- but: hus --> hus
|
||||
} ;
|
||||
|
||||
extNGen : Str -> NounGender = \s -> case last s of {
|
||||
"n" => NUtr ;
|
||||
_ => NNeutr
|
||||
} ;
|
||||
|
||||
nDreng : Str -> Subst = \dreng ->
|
||||
mkSubstantive dreng (dreng + "en") (dreng + "e") (dreng + "ene") **
|
||||
{h1 = Utr} ;
|
||||
|
||||
nBil : Str -> Subst = \bil ->
|
||||
mkSubstantive bil (bil + "en") (bil + "er") (bil + "erne") **
|
||||
{h1 = Utr} ;
|
||||
|
||||
nUge : Str -> Subst = \uge ->
|
||||
mkSubstantive uge (uge + "n") (uge + "r") (uge + "rne") **
|
||||
{h1 = Utr} ;
|
||||
|
||||
nHus : Str -> Subst = \hus ->
|
||||
mkSubstantive hus (hus + "et") hus (hus + "ene") **
|
||||
{h1 = Neutr} ;
|
||||
|
||||
-- adjectives
|
||||
|
||||
mkAdjective : (_,_,_,_,_ : Str) -> Adj =
|
||||
\stor,stort,store,storre,storst -> {s = table {
|
||||
AF (Posit (Strong (ASg Utr))) c => mkCase stor ! c ;
|
||||
AF (Posit (Strong (ASg Neutr))) c => mkCase stort ! c ;
|
||||
AF (Posit _) c => mkCase store ! c ;
|
||||
AF Compar c => mkCase storre ! c ;
|
||||
AF (Super SupStrong) c => mkCase storst ! c ;
|
||||
AF (Super SupWeak) c => mkCase (storst + "e") ! c
|
||||
}
|
||||
} ;
|
||||
|
||||
aRod : Str -> Adj = \rod ->
|
||||
mkAdjective rod (rod + "t") (rod + "e") (rod + "ere") (rod + "est") ;
|
||||
|
||||
aAbstrakt : Str -> Adj = \abstrakt ->
|
||||
mkAdjective abstrakt abstrakt (abstrakt + "e") (abstrakt + "ere") (abstrakt + "est") ;
|
||||
|
||||
aRask : Str -> Adj = \rask ->
|
||||
mkAdjective rask rask (rask + "e") (rask + "ere") (rask + "est") ;
|
||||
|
||||
extractPositive : Adj -> {s : AdjFormPos => Case => Str} = \adj ->
|
||||
{s = \\a,c => adj.s ! (AF (Posit a) c)} ;
|
||||
|
||||
-- verbs
|
||||
|
||||
mkVerb : (_,_,_,_,_,_ : Str) -> Verbum =
|
||||
\spise,spiser,spises,spiste,spist,spis -> {s = table {
|
||||
VI (Inf v) => mkVoice v spise ;
|
||||
VF (Pres Act) => spiser ;
|
||||
VF (Pres Pass) => spises ;
|
||||
VF (Pret v) => mkVoice v spiste ;
|
||||
VI (Supin v) => mkVoice v spist ;
|
||||
VI (PtPret _ c) => mkCase spist ! c ; ---- GenNum
|
||||
VF (Imper v) => mkVoice v spis
|
||||
}
|
||||
} ;
|
||||
|
||||
irregVerb : (drikke,drakk,drukket : Str) -> Verbum =
|
||||
\drikke,drakk,drukket ->
|
||||
let
|
||||
drikk = init drikke ;
|
||||
drikker = case last (init drikke) of {
|
||||
"r" => drikk ;
|
||||
_ => drikke + "r"
|
||||
}
|
||||
in
|
||||
mkVerb drikke drikker (drikke + "s") drakk drukket drikk ;
|
||||
|
||||
regVerb : Str -> Str -> Verbum = \spise, spiste ->
|
||||
let
|
||||
spis = init spise ;
|
||||
te = Predef.dp 2 spiste
|
||||
in
|
||||
case te of {
|
||||
"te" => vSpis spis ;
|
||||
"de" => case last spise of {
|
||||
"e" => vHusk spis ;
|
||||
_ => vBo spise
|
||||
} ;
|
||||
_ => vHusk spis
|
||||
} ;
|
||||
|
||||
mkVoice : Voice -> Str -> Str = \v,s -> case v of {
|
||||
Act => s ;
|
||||
Pass => s + case last s of {
|
||||
"s" => "es" ;
|
||||
_ => "s"
|
||||
}
|
||||
} ;
|
||||
|
||||
vHusk : Str -> Verbum = \husk ->
|
||||
mkVerb (husk + "e") (husk + "er") (husk + "es") (husk + "ede") (husk + "et") husk ;
|
||||
|
||||
vSpis : Str -> Verbum = \spis ->
|
||||
mkVerb (spis + "e") (spis + "er") (spis + "es") (spis + "te") (spis + "t") spis ;
|
||||
|
||||
vBo : Str -> Verbum = \bo ->
|
||||
mkVerb bo (bo + "r") (bo + "es") (bo + "ede") (bo + "et") bo ;
|
||||
|
||||
-- pronouns
|
||||
|
||||
oper jag_32 : ProPN =
|
||||
{s = table {
|
||||
PNom => "jeg" ;
|
||||
PAcc => "mig" ;
|
||||
PGen (ASg Utr) => "min" ;
|
||||
PGen (ASg Neutr) => "mit" ;
|
||||
PGen APl => "mine"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P1
|
||||
} ;
|
||||
|
||||
oper du_33 : ProPN =
|
||||
{s = table {
|
||||
PNom => "du" ;
|
||||
PAcc => "dig" ;
|
||||
PGen (ASg Utr) => "din" ;
|
||||
PGen (ASg Neutr) => "dit" ;
|
||||
PGen APl => "dine"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P2
|
||||
} ;
|
||||
|
||||
oper han_34 : ProPN =
|
||||
{s = table {
|
||||
PNom => "han" ;
|
||||
PAcc => "ham" ;
|
||||
PGen (ASg Utr) => "hans" ;
|
||||
PGen (ASg Neutr) => "hans" ;
|
||||
PGen APl => "hans"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P3
|
||||
} ;
|
||||
oper hon_35 : ProPN =
|
||||
{s = table {
|
||||
PNom => "hun" ;
|
||||
PAcc => "hende" ;
|
||||
PGen (ASg Utr) => "hendes" ;
|
||||
PGen (ASg Neutr) => "hendes" ;
|
||||
PGen APl => "hendes"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P3
|
||||
} ;
|
||||
|
||||
oper vi_36 : ProPN =
|
||||
{s = table {
|
||||
PNom => "vi" ;
|
||||
PAcc => "os" ;
|
||||
PGen _ => "vores"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Pl ;
|
||||
h3 = P1
|
||||
} ;
|
||||
|
||||
oper ni_37 : ProPN =
|
||||
{s = table {
|
||||
PNom => "i" ;
|
||||
PAcc => "jer" ;
|
||||
PGen _ => "jeres"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Pl ;
|
||||
h3 = P2
|
||||
} ;
|
||||
|
||||
oper de_38 : ProPN =
|
||||
{s = table {
|
||||
PNom => "de" ;
|
||||
PAcc => "dem" ;
|
||||
PGen _ => "deres"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Pl ;
|
||||
h3 = P3
|
||||
} ;
|
||||
|
||||
oper De_38 : ProPN =
|
||||
{s = table {
|
||||
PNom => "De" ;
|
||||
PAcc => "Dem" ;
|
||||
PGen _ => "Deres"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P2
|
||||
} ;
|
||||
|
||||
oper den_39 : ProPN =
|
||||
{s = table {
|
||||
PNom => "den" ;
|
||||
PAcc => "den" ;
|
||||
PGen _ => "dens"
|
||||
} ;
|
||||
h1 = Utr ;
|
||||
h2 = Sg ;
|
||||
h3 = P3
|
||||
} ;
|
||||
|
||||
oper det_40 : ProPN =
|
||||
{s = table {
|
||||
PNom => "det" ;
|
||||
PAcc => "det" ;
|
||||
PGen _ => "dets"
|
||||
} ;
|
||||
h1 = Neutr ;
|
||||
h2 = Sg ;
|
||||
h3 = P3
|
||||
} ;
|
||||
|
||||
|
||||
-- from Numerals
|
||||
|
||||
param DForm = ental | ton | tiotal ;
|
||||
|
||||
oper mkTal : Str -> Str -> Str -> {s : DForm => Str} =
|
||||
\to, tolv, tyve ->
|
||||
{s = table {ental => to ; ton => tolv ; tiotal => tyve}} ;
|
||||
oper regTal : Str -> {s : DForm => Str} = \fem -> mkTal fem (fem + "ton") (fem + "tio") ;
|
||||
numPl : Str -> {s : Gender => Str ; n : Number} = \n ->
|
||||
{s = \\_ => n ; n = Pl} ;
|
||||
|
||||
|
||||
}
|
||||
370
lib/resource-0.9/danish/ParadigmsDan.gf
Normal file
370
lib/resource-0.9/danish/ParadigmsDan.gf
Normal file
@@ -0,0 +1,370 @@
|
||||
--# -path=.:../scandinavian:../abstract:../../prelude
|
||||
|
||||
--1 Sanish Lexical Paradigms
|
||||
--
|
||||
-- Aarne Ranta 2003
|
||||
--
|
||||
-- This is an API to the user of the resource grammar
|
||||
-- for adding lexical items. It gives functions for forming
|
||||
-- expressions of open categories: nouns, adjectives, verbs.
|
||||
--
|
||||
-- Closed categories (determiners, pronouns, conjunctions) are
|
||||
-- accessed through the resource syntax API, $Structural.gf$.
|
||||
--
|
||||
-- The main difference with $MorphoDan.gf$ is that the types
|
||||
-- referred to are compiled resource grammar types. We have moreover
|
||||
-- had the design principle of always having existing forms, rather
|
||||
-- than stems, as string arguments of the paradigms.
|
||||
--
|
||||
-- The structure of functions for each word class $C$ is the following:
|
||||
-- first we give a handful of patterns that aim to cover all
|
||||
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
|
||||
-- escape to construct the most irregular words of type $C$.
|
||||
-- However, this function should only seldom be needed: we have a
|
||||
-- separate module $IrregularEng$, which covers all irregularly inflected
|
||||
-- words.
|
||||
--
|
||||
-- The following modules are presupposed:
|
||||
|
||||
resource ParadigmsDan =
|
||||
open (Predef=Predef), Prelude, TypesDan, MorphoDan, SyntaxDan, CategoriesDan in {
|
||||
|
||||
--2 Parameters
|
||||
--
|
||||
-- To abstract over gender names, we define the following identifiers.
|
||||
|
||||
oper
|
||||
Gender : Type ;
|
||||
|
||||
utrum : Gender ;
|
||||
neutrum : Gender ;
|
||||
|
||||
-- To abstract over number names, we define the following.
|
||||
|
||||
Number : Type ;
|
||||
|
||||
singular : Number ;
|
||||
plural : Number ;
|
||||
|
||||
-- To abstract over case names, we define the following.
|
||||
|
||||
Case : Type ;
|
||||
|
||||
nominative : Case ;
|
||||
genitive : Case ;
|
||||
|
||||
-- Prepositions used in many-argument functions are just strings.
|
||||
|
||||
Preposition : Type = Str ;
|
||||
|
||||
--2 Nouns
|
||||
|
||||
-- Worst case: give all four forms. The gender is computed from the
|
||||
-- last letter of the second form (if "n", then $utrum$, otherwise $neutrum$).
|
||||
|
||||
mkN : (dreng,drengen,drenger,drengene : Str) -> N ;
|
||||
|
||||
-- The regular function takes the singular indefinite form and the gender,
|
||||
-- and computes the other forms by a heuristic.
|
||||
-- If in doubt, use the $cc$ command to test!
|
||||
|
||||
regN : Str -> Gender -> N ;
|
||||
|
||||
-- This function takes the singular indefinite and definite forms; the
|
||||
-- gender is computed from the definite form.
|
||||
|
||||
mk2N : (bil,bilen : Str) -> N ;
|
||||
|
||||
|
||||
--3 Compound nouns
|
||||
--
|
||||
-- All the functions above work quite as well to form compound nouns,
|
||||
-- such as "fotboll".
|
||||
|
||||
|
||||
--3 Relational nouns
|
||||
--
|
||||
-- Relational nouns ("daughter of x") need a preposition.
|
||||
|
||||
mkN2 : N -> Preposition -> N2 ;
|
||||
|
||||
-- The most common preposition is "av", and the following is a
|
||||
-- shortcut for regular, $nonhuman$ relational nouns with "av".
|
||||
|
||||
regN2 : Str -> Gender -> N2 ;
|
||||
|
||||
-- Use the function $mkPreposition$ or see the section on prepositions below to
|
||||
-- form other prepositions.
|
||||
--
|
||||
-- Three-place relational nouns ("the connection from x to y") need two prepositions.
|
||||
|
||||
mkN3 : N -> Preposition -> Preposition -> N3 ;
|
||||
|
||||
|
||||
--3 Relational common noun phrases
|
||||
--
|
||||
-- In some cases, you may want to make a complex $CN$ into a
|
||||
-- relational noun (e.g. "the old town hall of"). However, $N2$ and
|
||||
-- $N3$ are purely lexical categories. But you can use the $AdvCN$
|
||||
-- and $PrepNP$ constructions to build phrases like this.
|
||||
|
||||
--
|
||||
--3 Proper names and noun phrases
|
||||
--
|
||||
-- Proper names, with a regular genitive, are formed as follows
|
||||
|
||||
regPN : Str -> Gender -> PN ; -- John, John's
|
||||
|
||||
-- Sometimes you can reuse a common noun as a proper name, e.g. "Bank".
|
||||
|
||||
nounPN : N -> PN ;
|
||||
|
||||
-- To form a noun phrase that can also be plural and have an irregular
|
||||
-- genitive, you can use the worst-case function.
|
||||
|
||||
mkNP : Str -> Str -> Number -> Gender -> NP ;
|
||||
|
||||
--2 Adjectives
|
||||
|
||||
-- Non-comparison one-place adjectives need three forms:
|
||||
|
||||
mkA : (galen,galet,galne : Str) -> A ;
|
||||
|
||||
-- For regular adjectives, the other forms are derived.
|
||||
|
||||
regA : Str -> A ;
|
||||
|
||||
-- In most cases, two forms are enough.
|
||||
|
||||
mk2A : (stor,stort : Str) -> A ;
|
||||
|
||||
--3 Two-place adjectives
|
||||
--
|
||||
-- Two-place adjectives need a preposition for their second argument.
|
||||
|
||||
mkA2 : A -> Preposition -> A2 ;
|
||||
|
||||
-- Comparison adjectives may need as many as five forms.
|
||||
|
||||
mkADeg : (stor,stort,store,storre,storst : Str) -> ADeg ;
|
||||
|
||||
-- The regular pattern works for many adjectives, e.g. those ending
|
||||
-- with "ig".
|
||||
|
||||
regADeg : Str -> ADeg ;
|
||||
|
||||
-- Just the comparison forms can be irregular.
|
||||
|
||||
irregADeg : (tung,tyngre,tyngst : Str) -> ADeg ;
|
||||
|
||||
-- Sometimes just the positive forms are irregular.
|
||||
|
||||
mk3ADeg : (galen,galet,galna : Str) -> ADeg ;
|
||||
mk2ADeg : (bred,bredt : Str) -> ADeg ;
|
||||
|
||||
-- If comparison is formed by "mer, "mest", as in general for
|
||||
-- long adjective, the following pattern is used:
|
||||
|
||||
compoundADeg : A -> ADeg ; -- -/mer/mest norsk
|
||||
|
||||
-- From a given $ADeg$, it is possible to get back to $A$.
|
||||
|
||||
adegA : ADeg -> A ;
|
||||
|
||||
|
||||
--2 Adverbs
|
||||
|
||||
-- Adverbs are not inflected. Most lexical ones have position
|
||||
-- after the verb. Some can be preverbal (e.g. "always").
|
||||
|
||||
mkAdv : Str -> Adv ;
|
||||
mkAdV : Str -> AdV ;
|
||||
|
||||
-- Adverbs modifying adjectives and sentences can also be formed.
|
||||
|
||||
mkAdA : Str -> AdA ;
|
||||
|
||||
--2 Prepositions
|
||||
--
|
||||
-- A preposition is just a string.
|
||||
|
||||
mkPreposition : Str -> Preposition ;
|
||||
|
||||
--2 Verbs
|
||||
--
|
||||
-- The worst case needs six forms.
|
||||
|
||||
mkV : (spise,spiser,spises,spiste,spist,spis : Str) -> V ;
|
||||
|
||||
-- The 'regular verb' function is the first conjugation.
|
||||
|
||||
regV : (snakke : Str) -> V ;
|
||||
|
||||
-- The almost regular verb function needs the infinitive and the preteritum.
|
||||
|
||||
mk2V : (leve,levde : Str) -> V ;
|
||||
|
||||
-- There is an extensive list of irregular verbs in the module $IrregularSwe$.
|
||||
-- In practice, it is enough to give three forms, as in school books.
|
||||
|
||||
irregV : (drikke, drakk, drukket : Str) -> V ;
|
||||
|
||||
|
||||
--3 Verbs with a particle.
|
||||
--
|
||||
-- The particle, such as in "switch on", is given as a string.
|
||||
|
||||
partV : V -> Str -> V ;
|
||||
|
||||
--3 Deponent verbs.
|
||||
--
|
||||
-- Some words are used in passive forms only, e.g. "hoppas".
|
||||
|
||||
depV : V -> V ;
|
||||
|
||||
--3 Two-place verbs
|
||||
--
|
||||
-- Two-place verbs need a preposition, except the special case with direct object.
|
||||
-- (transitive verbs). Notice that a particle comes from the $V$.
|
||||
|
||||
mkV2 : V -> Preposition -> V2 ;
|
||||
|
||||
dirV2 : V -> V2 ;
|
||||
|
||||
--3 Three-place verbs
|
||||
--
|
||||
-- Three-place (ditransitive) verbs need two prepositions, of which
|
||||
-- the first one or both can be absent.
|
||||
|
||||
mkV3 : V -> Str -> Str -> V3 ; -- speak, with, about
|
||||
dirV3 : V -> Str -> V3 ; -- give,_,to
|
||||
dirdirV3 : V -> V3 ; -- give,_,_
|
||||
|
||||
--3 Other complement patterns
|
||||
--
|
||||
-- Verbs and adjectives can take complements such as sentences,
|
||||
-- questions, verb phrases, and adjectives.
|
||||
|
||||
mkV0 : V -> V0 ;
|
||||
mkVS : V -> VS ;
|
||||
mkV2S : V -> Str -> V2S ;
|
||||
mkVV : V -> VV ;
|
||||
mkV2V : V -> Str -> Str -> V2V ;
|
||||
mkVA : V -> VA ;
|
||||
mkV2A : V -> Str -> V2A ;
|
||||
mkVQ : V -> VQ ;
|
||||
mkV2Q : V -> Str -> V2Q ;
|
||||
|
||||
mkAS : A -> AS ;
|
||||
mkA2S : A -> Str -> A2S ;
|
||||
mkAV : A -> AV ;
|
||||
mkA2V : A -> Str -> A2V ;
|
||||
|
||||
|
||||
--2 Definitions of the paradigms
|
||||
--
|
||||
-- The definitions should not bother the user of the API. So they are
|
||||
-- hidden from the document.
|
||||
--.
|
||||
|
||||
Gender = SyntaxDan.NounGender ;
|
||||
Number = TypesDan.Number ;
|
||||
Case = TypesDan.Case ;
|
||||
utrum = NUtr ;
|
||||
neutrum = NNeutr ;
|
||||
singular = Sg ;
|
||||
plural = Pl ;
|
||||
nominative = Nom ;
|
||||
genitive = Gen ;
|
||||
|
||||
mkN x y z u = let sb = mkSubstantive x y z u
|
||||
in {s = \\n,b,c => sb.s ! SF n b c ; g = extNGen y ; lock_N = <>} ;
|
||||
regN x g = case last x of {
|
||||
"e" => case g of {
|
||||
NUtr => mkN x (x + "n") (x + "r") (x + "rne") ;
|
||||
NNeutr => mkN x (x + "t") (x + "r") (init x + "ene")
|
||||
} ;
|
||||
_ => case g of {
|
||||
NUtr => mkN x (x + "en") (x + "er") (x + "rene") ;
|
||||
NNeutr => mkN x (x + "et") (x + "") (x + "ene")
|
||||
}
|
||||
} ;
|
||||
|
||||
mk2N x y = case last y of {
|
||||
"n" => regN x utrum ;
|
||||
_ => regN x neutrum
|
||||
} ;
|
||||
|
||||
|
||||
mkN2 = \n,p -> n ** {lock_N2 = <> ; s2 = p} ;
|
||||
regN2 n g = mkN2 (regN n g) (mkPreposition "av") ;
|
||||
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
|
||||
|
||||
regPN n g = {s = \\c => mkCase n ! c ; g = g} ** {lock_PN = <>} ;
|
||||
nounPN n = {s = n.s ! singular ! Indef ; g = n.g ; lock_PN = <>} ;
|
||||
mkNP x y n g =
|
||||
{s = table {PGen _ => x ; _ => y} ; g = genNoun g ; n = n ; p = P3 ;
|
||||
lock_NP = <>} ;
|
||||
|
||||
mkA a b c = extractPositive (mkAdjective a b c [] []) ** {lock_A = <>} ;
|
||||
mk2A a b = mkA a b (a + "e") ;
|
||||
regA a = extractPositive (regADeg a) ** {lock_A = <>} ;
|
||||
|
||||
mkA2 a p = a ** {s2 = p ; lock_A2 = <>} ;
|
||||
|
||||
mkADeg a b c d e = mkAdjective a b c d e ** {lock_ADeg = <>} ;
|
||||
regADeg a = case Predef.dp 2 a of {
|
||||
---- "ig" => aBillig a ;
|
||||
"sk" => aRask a ;
|
||||
_ => case last a of {
|
||||
"t" => aAbstrakt a ;
|
||||
_ => aRod a
|
||||
}} ** {lock_ADeg = <>} ;
|
||||
irregADeg a b c = mkAdjective a (a + "t") (a + "e") b c ** {lock_ADeg = <>} ;
|
||||
mk3ADeg a b c = mkAdjective a b c (a + "ere") (a + "est") ** {lock_ADeg = <>} ;
|
||||
mk2ADeg a b = mkAdjective a b (a + "e") (a + "ere") (a + "est") ** {lock_ADeg = <>} ;
|
||||
|
||||
mkAdv x = ss x ** {lock_Adv = <>} ;
|
||||
mkAdV x = ss x ** {lock_AdV = <>} ;
|
||||
mkAdA x = ss x ** {lock_AdA = <>} ;
|
||||
|
||||
mkPreposition p = p ;
|
||||
|
||||
mkV a b c d e f = mkVerb a b c d e f ** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
regV a = case last a of {
|
||||
"e" => vHusk (init a) ;
|
||||
_ => vBo a
|
||||
} ** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
mk2V a b = regVerb a b ** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
irregV x y z = irregVerb x y z
|
||||
** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
partV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
|
||||
depV v = deponentVerb v ** {lock_V = <>} ;
|
||||
|
||||
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; lock_V2 = <>} ;
|
||||
dirV2 v = mkV2 v [] ;
|
||||
|
||||
mkV3 v p q = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; s3 = q ; lock_V3 = <>} ;
|
||||
dirV3 v p = mkV3 v [] p ;
|
||||
dirdirV3 v = dirV3 v [] ;
|
||||
|
||||
mkV0 v = v ** {lock_V0 = <>} ;
|
||||
mkVS v = v ** {lock_VS = <>} ;
|
||||
mkV2S v p = mkV2 v p ** {lock_V2S = <>} ;
|
||||
mkVV v = v ** {isAux = False ; lock_VV = <>} ;
|
||||
mkV2V v p t = mkV2 v p ** {s3 = t ; lock_V2V = <>} ;
|
||||
mkVA v = v ** {lock_VA = <>} ;
|
||||
mkV2A v p = mkV2 v p ** {lock_V2A = <>} ;
|
||||
mkVQ v = v ** {lock_VQ = <>} ;
|
||||
mkV2Q v p = mkV2 v p ** {lock_V2Q = <>} ;
|
||||
|
||||
mkAS v = v ** {lock_AS = <>} ;
|
||||
mkA2S v p = mkA2 v p ** {lock_A2S = <>} ;
|
||||
mkAV v = v ** {lock_AV = <>} ;
|
||||
mkA2V v p = mkA2 v p ** {lock_A2V = <>} ;
|
||||
|
||||
} ;
|
||||
107
lib/resource-0.9/danish/StructuralDan.gf
Normal file
107
lib/resource-0.9/danish/StructuralDan.gf
Normal file
@@ -0,0 +1,107 @@
|
||||
--# -path=.:../scandinavian:../abstract:../../prelude
|
||||
|
||||
--1 The Top-Level Swedish Resource Grammar: Structural Words
|
||||
--
|
||||
-- Aarne Ranta 2002 -- 2004
|
||||
--
|
||||
concrete StructuralDan of Structural =
|
||||
CategoriesDan, NumeralsDan ** open Prelude, MorphoDan, SyntaxDan in {
|
||||
|
||||
flags optimize=values ;
|
||||
|
||||
lin
|
||||
|
||||
UseNumeral i = {
|
||||
s = \\g => table {Nom => i.s ! g ; Gen => i.s ! g ++ "s"} ; ---
|
||||
n = i.n
|
||||
} ;
|
||||
|
||||
above_Prep = ss "ovenfor" ;
|
||||
after_Prep = ss "efter" ;
|
||||
by8agent_Prep = ss "af" ;
|
||||
all8mass_Det = mkDeterminerSgGender2 "all" "alt" IndefP ;
|
||||
all_NDet = mkDeterminerPl "alle" IndefP ;
|
||||
almost_Adv = ss "næsten" ;
|
||||
although_Subj = ss ["selv om"] ;
|
||||
and_Conj = ss "og" ** {n = Pl} ;
|
||||
because_Subj = ss ["fordi"] ;
|
||||
before_Prep = ss "før" ;
|
||||
behind_Prep = ss "bag" ;
|
||||
between_Prep = ss "mellem" ;
|
||||
both_AndConjD = sd2 "både" "og" ** {n = Pl} ;
|
||||
by8means_Prep = ss "med" ;
|
||||
can8know_VV = mkVerb "kunne" "kan" nonExist "kunne" "kunnet" nonExist **
|
||||
{s1 = [] ; isAux = True} ;
|
||||
can_VV = mkVerb "kunne" "kan" nonExist "kunne" "kunnet" nonExist **
|
||||
{s1 = [] ; isAux = True} ;
|
||||
during_Prep = ss "under" ;
|
||||
either8or_ConjD = sd2 "enten" "eller" ** {n = Sg} ;
|
||||
everybody_NP = let alla = table {Nom => "alle" ; Gen => "alles"} in
|
||||
{s = \\c => alla ! npCase c ; g = Utr ; n = Pl ; p = P3} ;
|
||||
every_Det = varjeDet ;
|
||||
everything_NP = nameNounPhrase (mkProperName "alt" NNeutr) ;
|
||||
everywhere_Adv = advPost "overalt" ;
|
||||
from_Prep = ss "fra" ;
|
||||
he_NP = pronNounPhrase han_34 ;
|
||||
how_IAdv = ss "hvor" ;
|
||||
how8many_IDet = mkDeterminerPl ["hvor mange"] IndefP ;
|
||||
if_Subj = ss "hvis" ;
|
||||
in8front_Prep = ss "fremfor" ; ---- ?
|
||||
i_NP = pronNounPhrase jag_32 ;
|
||||
in_Prep = ss "i" ;
|
||||
it_NP = pronNounPhrase det_40 ; ----
|
||||
many_Det = mkDeterminerPl "mange" IndefP ;
|
||||
most_Det = mkDeterminerSgGender2 ["den meste"] ["det meste"] (DefP Def) ;
|
||||
most8many_Det = flestaDet ;
|
||||
much_Det = mkDeterminerSg (detSgInvar "meget") IndefP ;
|
||||
must_VV = mkVerb "måtte" "må" "mås" "måtte" "måttet" "må" **
|
||||
{s1 = [] ; isAux = True} ; ---- ?
|
||||
on_Prep = ss "på" ;
|
||||
or_Conj = ss "eller" ** {n = Sg} ;
|
||||
otherwise_Adv = ss "anderledes" ; ---- ?
|
||||
part_Prep = ss "af" ;
|
||||
no_Phr = ss ["Nej ."] ;
|
||||
yes_Phr = ss ["Ja ."] ;
|
||||
possess_Prep = ss "af" ;
|
||||
quite_Adv = ss "temmelig" ;
|
||||
she_NP = pronNounPhrase hon_35 ;
|
||||
so_Adv = ss "så" ;
|
||||
somebody_NP = nameNounPhrase (mkProperName "nogen" NUtr) ;
|
||||
some_Det = mkDeterminerSgGender2 "nogen" "noget" IndefP ;
|
||||
some_NDet = mkDeterminerPlNum "nogle" IndefP ;
|
||||
something_NP = nameNounPhrase (mkProperName "noget" NNeutr) ;
|
||||
somewhere_Adv = advPost ["et eller andet sted"] ; ---- ?
|
||||
that_Det = mkDeterminerSgGender2 ["den der"] ["det der"] (DefP Indef) ;
|
||||
that_NP = regNameNounPhrase ["det der"] NNeutr ;
|
||||
therefore_Adv = ss "derfor" ;
|
||||
these_NDet = mkDeterminerPlNum ["de her"] (DefP Indef) ;
|
||||
they8fem_NP = pronNounPhrase de_38 ;
|
||||
they_NP = pronNounPhrase de_38 ;
|
||||
this_Det = mkDeterminerSgGender2 ["den her"] ["det her"] (DefP Indef) ;
|
||||
this_NP = regNameNounPhrase ["det her"] NNeutr ;
|
||||
those_NDet = mkDeterminerPlNum ["de der"] (DefP Indef) ;
|
||||
thou_NP = pronNounPhrase du_33 ;
|
||||
through_Prep = ss "igennem" ;
|
||||
too_Adv = ss "for" ; ---- ?
|
||||
to_Prep = ss "til" ;
|
||||
under_Prep = ss "under" ;
|
||||
very_Adv = ss "meget" ;
|
||||
want_VV = mkVerb "ville" "vil" nonExist "ville" "villet" nonExist **
|
||||
{s1 = [] ; isAux = True} ; ---
|
||||
we_NP = pronNounPhrase (vi_36) ;
|
||||
what8many_IP = intPronWhat plural ;
|
||||
what8one_IP = intPronWhat singular ;
|
||||
when_IAdv = ss "hvornår" ;
|
||||
when_Subj = ss "når" ;
|
||||
where_IAdv = ss "hver" ;
|
||||
which8one_IDet = vilkenDet ;
|
||||
which8many_IDet = mkDeterminerPl "hvilke" IndefP ;
|
||||
who8many_IP = intPronWho plural ;
|
||||
who8one_IP = intPronWho singular ;
|
||||
why_IAdv = ss "hvorfor" ;
|
||||
without_Prep = ss "uden" ;
|
||||
with_Prep = ss "med" ;
|
||||
ye_NP = pronNounPhrase (ni_37) ;
|
||||
you_NP = pronNounPhrase De_38 ;
|
||||
|
||||
}
|
||||
56
lib/resource-0.9/doc/Makefile
Normal file
56
lib/resource-0.9/doc/Makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
all: gfdoc htmls gifs
|
||||
|
||||
htmls:
|
||||
htmls gf-resource.html
|
||||
|
||||
gfdoc:
|
||||
gfdoc ../abstract/Categories.gf ; mv ../abstract/Categories.html .
|
||||
gfdoc ../abstract/Rules.gf ; mv ../abstract/Rules.html .
|
||||
gfdoc ../abstract/Verbphrase.gf ; mv ../abstract/Verbphrase.html .
|
||||
gfdoc ../abstract/Clause.gf ; mv ../abstract/Clause.html .
|
||||
gfdoc ../abstract/Structural.gf ; mv ../abstract/Structural.html .
|
||||
gfdoc ../abstract/Basic.gf ; mv ../abstract/Basic.html .
|
||||
gfdoc ../abstract/Time.gf ; mv ../abstract/Time.html .
|
||||
gfdoc ../abstract/Lang.gf ; mv ../abstract/Lang.html .
|
||||
gfdoc ../swedish/ParadigmsSwe.gf ; mv ../swedish/ParadigmsSwe.html .
|
||||
gfdoc ../swedish/VerbsSwe.gf ; mv ../swedish/VerbsSwe.html .
|
||||
gfdoc ../swedish/BasicSwe.gf ; mv ../swedish/BasicSwe.html .
|
||||
gfdoc ../english/ParadigmsEng.gf ; mv ../english/ParadigmsEng.html .
|
||||
gfdoc ../english/VerbsEng.gf ; mv ../english/VerbsEng.html .
|
||||
gfdoc ../english/BasicEng.gf ; mv ../english/BasicEng.html .
|
||||
gfdoc ../french/ParadigmsFre.gf ; mv ../french/ParadigmsFre.html .
|
||||
gfdoc ../french/VerbsFre.gf ; mv ../french/VerbsFre.html .
|
||||
gfdoc ../french/BasicFre.gf ; mv ../french/BasicFre.html .
|
||||
|
||||
gfdoc ../norwegian/ParadigmsNor.gf ; mv ../norwegian/ParadigmsNor.html .
|
||||
gfdoc ../norwegian/VerbsNor.gf ; mv ../norwegian/VerbsNor.html .
|
||||
gfdoc ../norwegian/BasicNor.gf ; mv ../norwegian/BasicNor.html .
|
||||
|
||||
gfdoc ../finnish/ParadigmsFin.gf ; mv ../finnish/ParadigmsFin.html .
|
||||
gfdoc ../finnish/BasicFin.gf ; mv ../finnish/BasicFin.html .
|
||||
|
||||
gfdoc ../italian/ParadigmsIta.gf ; mv ../italian/ParadigmsIta.html .
|
||||
gfdoc ../italian/BasicIta.gf ; mv ../italian/BasicIta.html .
|
||||
gfdoc ../italian/BeschIta.gf ; mv ../italian/BeschIta.html .
|
||||
|
||||
gfdoc ../spanish/ParadigmsSpa.gf ; mv ../spanish/ParadigmsSpa.html .
|
||||
gfdoc ../spanish/BasicSpa.gf ; mv ../spanish/BasicSpa.html .
|
||||
gfdoc ../spanish/BeschSpa.gf ; mv ../spanish/BeschSpa.html .
|
||||
|
||||
gifs: api lang scand low
|
||||
|
||||
api:
|
||||
# echo "pm -printer=graph | wf Resource.dot" | gf ../abstract/Resource.gf
|
||||
dot -Tgif ResourceVP.dot>Resource.gif
|
||||
|
||||
lang:
|
||||
echo "pm -printer=graph | wf Lang.dot" | gf ../abstract/Lang.gf
|
||||
dot -Tgif Lang.dot>Lang.gif
|
||||
|
||||
low:
|
||||
echo "pm -printer=graph | wf Low.dot" | gf ../english/RulesEng.gf
|
||||
dot -Tgif Low.dot >Low.gif
|
||||
|
||||
scand:
|
||||
echo "pm -printer=graph | wf Scand.dot" | gf ../swedish/RulesSwe.gf
|
||||
dot -Tgif Scand.dot >Scand.gif
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
26
lib/resource-0.9/english/LangEng.gf
Normal file
26
lib/resource-0.9/english/LangEng.gf
Normal file
@@ -0,0 +1,26 @@
|
||||
--# -path=.:../abstract:../../prelude
|
||||
|
||||
-- # -path=.:resource/english:resource/abstract:prelude
|
||||
|
||||
concrete LangEng of Lang =
|
||||
RulesEng,
|
||||
ClauseEng,
|
||||
StructuralEng,
|
||||
BasicEng,
|
||||
TimeEng,
|
||||
CountryEng,
|
||||
MathEng
|
||||
|
||||
** open Prelude, ParadigmsEng in {
|
||||
|
||||
lin
|
||||
AdvDate d = prefixSS "on" d ;
|
||||
AdvTime t = prefixSS "at" t ;
|
||||
NWeekday w = w ;
|
||||
PNWeekday w = nounPN w ;
|
||||
|
||||
PNCountry x = x ;
|
||||
ANationality x = x ;
|
||||
NLanguage x = x ;
|
||||
|
||||
}
|
||||
341
lib/resource-0.9/english/MorphoEng.gf
Normal file
341
lib/resource-0.9/english/MorphoEng.gf
Normal file
@@ -0,0 +1,341 @@
|
||||
--# -path=.:../../prelude
|
||||
|
||||
--1 A Simple English Resource Morphology
|
||||
--
|
||||
-- Aarne Ranta 2002
|
||||
--
|
||||
-- This resource morphology contains definitions needed in the resource
|
||||
-- syntax. It moreover contains the most usual inflectional patterns.
|
||||
--
|
||||
-- We use the parameter types and word classes defined in $Types.gf$.
|
||||
|
||||
resource MorphoEng = TypesEng ** open Prelude, (Predef=Predef) in {
|
||||
|
||||
--2 Phonology
|
||||
--
|
||||
-- To regulate the use of endings for both nouns, adjectives, and verbs:
|
||||
|
||||
oper
|
||||
y2ie : Str -> Str -> Str = \fly,s ->
|
||||
let y = last (init fly) in
|
||||
case y of {
|
||||
"a" => fly + s ;
|
||||
"e" => fly + s ;
|
||||
"o" => fly + s ;
|
||||
"u" => fly + s ;
|
||||
_ => init fly + "ie" + s
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
--2 Nouns
|
||||
--
|
||||
-- For conciseness and abstraction, we define a worst-case macro for
|
||||
-- noun inflection. It is used for defining special case that
|
||||
-- only need one string as argument.
|
||||
|
||||
oper
|
||||
mkNoun : (_,_,_,_ : Str) -> CommonNoun =
|
||||
\man,men, mans, mens -> {s = table {
|
||||
Sg => table {Nom => man ; Gen => mans} ;
|
||||
Pl => table {Nom => men ; Gen => mens}
|
||||
}} ;
|
||||
|
||||
nounReg : Str -> CommonNoun = \dog ->
|
||||
mkNoun dog (dog + "s") (dog + "'s") (dog + "s'");
|
||||
|
||||
nounS : Str -> CommonNoun = \kiss ->
|
||||
mkNoun kiss (kiss + "es") (kiss + "'s") (kiss + "es'") ;
|
||||
|
||||
nounY : Str -> CommonNoun = \fl ->
|
||||
mkNoun (fl + "y") (fl + "ies") (fl + "y's") (fl + "ies'") ;
|
||||
|
||||
nounGen : Str -> CommonNoun = \dog -> case last dog of {
|
||||
"y" => nounY "dog" ;
|
||||
"s" => nounS (init "dog") ;
|
||||
_ => nounReg "dog"
|
||||
} ;
|
||||
|
||||
--3 Proper names
|
||||
--
|
||||
-- Regular proper names are inflected with "'s" in the genitive.
|
||||
|
||||
nameReg : Str -> Gender -> ProperName = \john,g ->
|
||||
{s = table {Nom => john ; Gen => john + "'s"} ; g = g} ;
|
||||
|
||||
|
||||
--2 Pronouns
|
||||
--
|
||||
-- Here we define personal and relative pronouns.
|
||||
|
||||
mkPronoun : (_,_,_,_ : Str) -> Number -> Person -> Gender -> Pronoun =
|
||||
\I,me,my,mine,n,p,g ->
|
||||
{s = table {NomP => I ; AccP => me ; GenP => my ; GenSP => mine} ;
|
||||
n = n ; p = p ; g = g} ;
|
||||
|
||||
human : Gender = Masc ; --- doesn't matter
|
||||
|
||||
pronI = mkPronoun "I" "me" "my" "mine" Sg P1 human ;
|
||||
pronYouSg = mkPronoun "you" "you" "your" "yours" Sg P2 human ; -- verb form still OK
|
||||
pronHe = mkPronoun "he" "him" "his" "his" Sg P3 Masc ;
|
||||
pronShe = mkPronoun "she" "her" "her" "hers" Sg P3 Fem ;
|
||||
pronIt = mkPronoun "it" "it" "its" "it" Sg P3 Neutr ;
|
||||
|
||||
pronWe = mkPronoun "we" "us" "our" "ours" Pl P1 human ;
|
||||
pronYouPl = mkPronoun "you" "you" "your" "yours" Pl P2 human ;
|
||||
pronThey = mkPronoun "they" "them" "their" "theirs" Pl P3 human ; ---
|
||||
|
||||
-- Relative pronouns in the accusative have the 'no pronoun' variant.
|
||||
-- The simple pronouns do not really depend on number.
|
||||
|
||||
relPron : RelPron = {s = table {
|
||||
Neutr => \\_ => table {
|
||||
NomP => variants {"that" ; "which"} ;
|
||||
AccP => variants {"that" ; "which" ; []} ;
|
||||
GenP => variants {"whose"} ;
|
||||
GenSP => variants {"which"}
|
||||
} ;
|
||||
_ => \\_ => table {
|
||||
NomP => variants {"that" ; "who"} ;
|
||||
AccP => variants {"that" ; "who" ; "whom" ; []} ;
|
||||
GenP => variants {"whose"} ;
|
||||
GenSP => variants {"whom"}
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
--3 Determiners
|
||||
--
|
||||
-- We have just a heuristic definition of the indefinite article.
|
||||
-- There are lots of exceptions: consonantic "e" ("euphemism"), consonantic
|
||||
-- "o" ("one-sided"), vocalic "u" ("umbrella").
|
||||
|
||||
artIndef = pre {"a" ;
|
||||
"an" / strs {"a" ; "e" ; "i" ; "o" ; "A" ; "E" ; "I" ; "O" }} ;
|
||||
|
||||
artDef = "the" ;
|
||||
|
||||
--2 Adjectives
|
||||
--
|
||||
-- To form the adjectival and the adverbial forms, two strings are needed
|
||||
-- in the worst case.
|
||||
|
||||
mkAdjective : Str -> Str -> Adjective = \free,freely -> {
|
||||
s = table {
|
||||
AAdj => free ;
|
||||
AAdv => freely
|
||||
}
|
||||
} ;
|
||||
|
||||
-- However, the ending "iy" is sufficient for most cases. This function
|
||||
-- automatically changes the word-final "y" to "i" ("happy" - "happily").
|
||||
-- N.B. this is not correct for "shy", but $mkAdjective$ has to be used.
|
||||
|
||||
regAdjective : Str -> Adjective = \free ->
|
||||
let
|
||||
y = Predef.dp 1 free
|
||||
in mkAdjective
|
||||
free
|
||||
(ifTok Str y "y" (Predef.tk 1 free + ("ily")) (free + "ly")) ;
|
||||
|
||||
-- For the comparison of adjectives, six forms are needed to cover all cases.
|
||||
-- But there is no adjective that actually needs all these.
|
||||
|
||||
mkAdjDegrWorst : (_,_,_,_,_,_ : Str) -> AdjDegr =
|
||||
\good,well,better,betterly,best,bestly ->
|
||||
{s = table {
|
||||
Pos => (mkAdjective good well).s ;
|
||||
Comp => (mkAdjective better betterly).s ;
|
||||
Sup => (mkAdjective best bestly).s
|
||||
}
|
||||
} ;
|
||||
|
||||
-- What is usually needed for irregular comparisons are just three forms,
|
||||
-- since the adverbial form is the same (in comparative or superlative)
|
||||
-- or formed in the regular way (positive).
|
||||
|
||||
adjDegrIrreg : (_,_,_ : Str) -> AdjDegr = \bad,worse,worst ->
|
||||
let badly = (regAdjective bad).s ! AAdv
|
||||
in mkAdjDegrWorst bad badly worse worse worst worst ;
|
||||
|
||||
-- Like above, the regular formation takes account of final "y".
|
||||
|
||||
adjDegrReg : Str -> AdjDegr = \happy ->
|
||||
let happi = ifTok Str (Predef.dp 1 happy) "y" (Predef.tk 1 happy + "i") happy
|
||||
in adjDegrIrreg happy (happi + "er") (happi + "est") ;
|
||||
|
||||
-- Many adjectives are 'inflected' by adding a comparison word.
|
||||
|
||||
adjDegrLong : Str -> AdjDegr = \ridiculous ->
|
||||
adjDegrIrreg ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
|
||||
|
||||
|
||||
--3 Verbs
|
||||
--
|
||||
-- Except for "be", the worst case needs four forms.
|
||||
|
||||
mkVerbP3worst : (_,_,_,_,_: Str) -> VerbP3 = \go,goes,went,gone,going ->
|
||||
{s = table {
|
||||
InfImp => go ;
|
||||
Indic Sg => goes ;
|
||||
Indic _ => go ;
|
||||
Pastt => went ;
|
||||
PPart => gone ;
|
||||
PresPart => going
|
||||
}
|
||||
} ;
|
||||
|
||||
mkVerbP3 : (_,_,_,_: Str) -> VerbP3 = \go,goes,went,gone ->
|
||||
let going = case last go of {
|
||||
"e" => init go + "ing" ;
|
||||
_ => go + "ing"
|
||||
}
|
||||
in
|
||||
mkVerbP3worst go goes went gone going ;
|
||||
|
||||
-- This is what we use to derive the irregular forms in almost all cases
|
||||
|
||||
mkVerbIrreg : (_,_,_ : Str) -> VerbP3 = \bite,bit,bitten ->
|
||||
let bites = case last bite of {
|
||||
"y" => y2ie bite "s" ;
|
||||
"s" => init bite + "es" ;
|
||||
_ => bite + "s"
|
||||
}
|
||||
in mkVerbP3 bite bites bit bitten ;
|
||||
|
||||
-- This is used to derive regular forms.
|
||||
|
||||
mkVerbReg : Str -> VerbP3 = \soak ->
|
||||
let
|
||||
soaks = case last soak of {
|
||||
"y" => y2ie soak "s" ;
|
||||
"s" => init soak + "es" ;
|
||||
_ => soak + "s"
|
||||
} ;
|
||||
soaked = case last soak of {
|
||||
"e" => init soak + "s" ;
|
||||
_ => soak + "ed"
|
||||
}
|
||||
in
|
||||
mkVerbP3 soak soaks soaked soaked ;
|
||||
|
||||
mkVerb : (_,_,_ : Str) -> VerbP3 = \ring,rang,rung ->
|
||||
mkVerbP3 ring (ring + "s") rang rung ;
|
||||
|
||||
regVerbP3 : Str -> VerbP3 = \walk ->
|
||||
mkVerb walk (walk + "ed") (walk + "ed") ;
|
||||
|
||||
verbP3s : Str -> VerbP3 = \kiss ->
|
||||
mkVerbP3 kiss (kiss + "es") (kiss + "ed") (kiss + "ed") ;
|
||||
|
||||
verbP3e : Str -> VerbP3 = \love ->
|
||||
mkVerbP3 love (love + "s") (love + "d") (love + "d") ;
|
||||
|
||||
verbP3y : Str -> VerbP3 = \cr ->
|
||||
mkVerbP3 (cr + "y") (cr + "ies") (cr + "ied") (cr + "ied") ;
|
||||
|
||||
verbGen : Str -> VerbP3 = \kill -> case last kill of {
|
||||
"y" => verbP3y (init kill) ;
|
||||
"e" => verbP3y (init kill) ;
|
||||
"s" => verbP3s (init kill) ;
|
||||
_ => regVerbP3 kill
|
||||
} ;
|
||||
|
||||
verbP3Have = mkVerbP3 "have" "has" "had" "had" ;
|
||||
|
||||
verbP3Do = mkVerbP3 "do" "does" "did" "done" ;
|
||||
|
||||
auxVerbBe : AuxVerb = {s = table {
|
||||
AInfImp => "be" ;
|
||||
AIndic P1 b => if_then_Str b "am" ["am not"] ;
|
||||
AIndic P2 b => negAux b "are" ;
|
||||
AIndic P3 b => negAux b "is" ;
|
||||
APastt Sg b => negAux b "was" ;
|
||||
APastt Pl b => negAux b "were" ;
|
||||
APPart => "been" ;
|
||||
APresPart => "being"
|
||||
}
|
||||
} ;
|
||||
|
||||
-- The negative forms are not used;
|
||||
--- the particle $want.s1$ disappears - is it ever needed?
|
||||
|
||||
verb2aux : Verb -> AuxVerb = \want -> {s = table {
|
||||
AInfImp => want.s ! InfImp ;
|
||||
AIndic P3 b => want.s ! Indic Sg ;
|
||||
AIndic _ b => want.s ! Indic Pl ;
|
||||
APastt _ b => want.s ! Pastt ;
|
||||
APPart => want.s ! PPart ;
|
||||
APresPart => want.s ! PresPart
|
||||
}
|
||||
} ;
|
||||
|
||||
aux2verb : AuxVerb -> Verb = \want -> {s = table {
|
||||
InfImp => want.s ! AInfImp ;
|
||||
Indic Sg => want.s ! AIndic P3 True ;
|
||||
Indic _ => want.s ! AIndic P2 True ;
|
||||
Pastt => want.s ! APastt Pl True ;
|
||||
PPart => want.s ! APPart ;
|
||||
PresPart => want.s ! APresPart
|
||||
} ;
|
||||
s1 = []
|
||||
} ;
|
||||
|
||||
-- The three most important example auxiliaries.
|
||||
|
||||
mkVerbAux : (_,_,_,_: Str) -> AuxVerb = \beable, can, could, beenable ->
|
||||
{s = table {
|
||||
AInfImp => beable ;
|
||||
AIndic _ b => negAux b can ;
|
||||
APastt _ b => negAux b could ;
|
||||
APPart => beenable ;
|
||||
APrepPart => nonExist ---- fix!
|
||||
} ;
|
||||
} ;
|
||||
|
||||
|
||||
verbPart : VerbP3 -> Particle -> Verb = \v,p ->
|
||||
v ** {s1 = p} ;
|
||||
|
||||
verbNoPart : VerbP3 -> Verb = \v -> verbPart v [] ;
|
||||
|
||||
negAux : Bool -> Str -> Str = \b,is -> if_then_Str b is (is + "n't") ;
|
||||
|
||||
-- The optional negation contraction is a useful macro e.g. for "do".
|
||||
|
||||
contractNot : Str -> Str = \is -> variants {is ++ "not" ; is + "n't"} ;
|
||||
|
||||
dont = contractNot (verbP3Do.s ! InfImp) ;
|
||||
|
||||
-- From $numerals$.
|
||||
|
||||
param
|
||||
DForm = unit | teen | ten ;
|
||||
CardOrd = NCard | NOrd ;
|
||||
|
||||
oper
|
||||
mkNum : Str -> Str -> Str -> Str -> {s : DForm => CardOrd => Str} =
|
||||
\two -> \twelve -> \twenty -> \second ->
|
||||
{s = table {
|
||||
unit => table {NCard => two ; NOrd => second} ;
|
||||
teen => \\c => mkCard c twelve ;
|
||||
ten => \\c => mkCard c twenty
|
||||
}
|
||||
} ;
|
||||
|
||||
regNum : Str -> {s : DForm => CardOrd => Str} =
|
||||
\six -> mkNum six (six + "teen") (six + "ty") (regOrd six) ;
|
||||
|
||||
regCardOrd : Str -> {s : CardOrd => Str} = \ten ->
|
||||
{s = table {NCard => ten ; NOrd => regOrd ten}} ;
|
||||
|
||||
mkCard : CardOrd -> Str -> Str = \c,ten -> (regCardOrd ten).s ! c ;
|
||||
|
||||
regOrd : Str -> Str = \ten -> case last ten of {
|
||||
"y" => init ten + "ieth" ;
|
||||
_ => ten + "th"
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--# -path=.:../abstract:../../prelude:../common
|
||||
--# -path=.:../abstract:../../prelude
|
||||
|
||||
--1 English Lexical Paradigms
|
||||
--
|
||||
-- Aarne Ranta 2003--2005
|
||||
-- Aarne Ranta 2003
|
||||
--
|
||||
-- This is an API for the user of the resource grammar
|
||||
-- This is an API to the user of the resource grammar
|
||||
-- for adding lexical items. It gives functions for forming
|
||||
-- expressions of open categories: nouns, adjectives, verbs.
|
||||
--
|
||||
@@ -21,15 +21,13 @@
|
||||
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
|
||||
-- escape to construct the most irregular words of type $C$.
|
||||
-- However, this function should only seldom be needed: we have a
|
||||
-- separate module [``IrregEng`` ../../english/IrregEng.gf],
|
||||
-- which covers irregular verbss.
|
||||
-- separate module $IrregularEng$, which covers all irregularly inflected
|
||||
-- words.
|
||||
--
|
||||
-- The following modules are presupposed:
|
||||
|
||||
resource ParadigmsEng = open
|
||||
(Predef=Predef),
|
||||
Prelude,
|
||||
MorphoEng,
|
||||
CatEng
|
||||
in {
|
||||
resource ParadigmsEng = open (Predef=Predef), Prelude, SyntaxEng,
|
||||
CategoriesEng, RulesEng in {
|
||||
--2 Parameters
|
||||
--
|
||||
-- To abstract over gender names, we define the following identifiers.
|
||||
@@ -40,6 +38,7 @@ oper
|
||||
human : Gender ;
|
||||
nonhuman : Gender ;
|
||||
masculine : Gender ;
|
||||
feminite : Gender ;
|
||||
|
||||
-- To abstract over number names, we define the following.
|
||||
|
||||
@@ -56,13 +55,13 @@ oper
|
||||
genitive : Case ;
|
||||
|
||||
-- Prepositions are used in many-argument functions for rection.
|
||||
-- The resource category $Prep$ is used.
|
||||
|
||||
Preposition : Type ;
|
||||
|
||||
|
||||
--2 Nouns
|
||||
|
||||
-- Worst case: give all four forms.
|
||||
-- Worst case: give all four forms and the semantic gender.
|
||||
|
||||
mkN : (man,men,man's,men's : Str) -> N ;
|
||||
|
||||
@@ -84,29 +83,27 @@ oper
|
||||
|
||||
--3 Compound nouns
|
||||
--
|
||||
-- A compound noun ia an uninflected string attached to an inflected noun,
|
||||
-- such as "baby boom", "chief executive officer".
|
||||
|
||||
compoundN : Str -> N -> N ;
|
||||
-- All the functions above work quite as well to form compound nouns,
|
||||
-- such as "baby boom".
|
||||
|
||||
|
||||
--3 Relational nouns
|
||||
--
|
||||
-- Relational nouns ("daughter of x") need a preposition.
|
||||
|
||||
mkN2 : N -> Prep -> N2 ;
|
||||
mkN2 : N -> Preposition -> N2 ;
|
||||
|
||||
-- The most common preposition is "of", and the following is a
|
||||
-- shortcut for regular relational nouns with "of".
|
||||
-- shortcut for regular, $nonhuman$ relational nouns with "of".
|
||||
|
||||
regN2 : Str -> N2 ;
|
||||
|
||||
-- Use the function $mkPrep$ or see the section on prepositions below to
|
||||
-- Use the function $mkPreposition$ or see the section on prepositions below to
|
||||
-- form other prepositions.
|
||||
--
|
||||
-- Three-place relational nouns ("the connection from x to y") need two prepositions.
|
||||
|
||||
mkN3 : N -> Prep -> Prep -> N3 ;
|
||||
mkN3 : N -> Preposition -> Preposition -> N3 ;
|
||||
|
||||
|
||||
--3 Relational common noun phrases
|
||||
@@ -114,16 +111,15 @@ oper
|
||||
-- In some cases, you may want to make a complex $CN$ into a
|
||||
-- relational noun (e.g. "the old town hall of").
|
||||
|
||||
cnN2 : CN -> Prep -> N2 ;
|
||||
cnN3 : CN -> Prep -> Prep -> N3 ;
|
||||
cnN2 : CN -> Preposition -> N2 ;
|
||||
cnN3 : CN -> Preposition -> Preposition -> N3 ;
|
||||
|
||||
--
|
||||
--3 Proper names and noun phrases
|
||||
--
|
||||
-- Proper names, with a regular genitive, are formed as follows
|
||||
|
||||
regPN : Str -> PN ;
|
||||
regGenPN : Str -> Gender -> PN ; -- John, John's
|
||||
regPN : Str -> Gender -> PN ; -- John, John's
|
||||
|
||||
-- Sometimes you can reuse a common noun as a proper name, e.g. "Bank".
|
||||
|
||||
@@ -150,12 +146,10 @@ oper
|
||||
--
|
||||
-- Two-place adjectives need a preposition for their second argument.
|
||||
|
||||
mkA2 : A -> Prep -> A2 ;
|
||||
mkA2 : A -> Preposition -> A2 ;
|
||||
|
||||
-- Comparison adjectives may two more forms.
|
||||
|
||||
ADeg : Type ;
|
||||
|
||||
mkADeg : (good,better,best,well : Str) -> ADeg ;
|
||||
|
||||
-- The regular pattern recognizes two common variations:
|
||||
@@ -169,7 +163,7 @@ oper
|
||||
|
||||
duplADeg : Str -> ADeg ; -- fat, fatter, fattest
|
||||
|
||||
-- If comparison is formed by "more", "most", as in general for
|
||||
-- If comparison is formed by "more, "most", as in general for
|
||||
-- long adjective, the following pattern is used:
|
||||
|
||||
compoundADeg : A -> ADeg ; -- -/more/most ridiculous
|
||||
@@ -196,8 +190,8 @@ oper
|
||||
-- A preposition as used for rection in the lexicon, as well as to
|
||||
-- build $PP$s in the resource API, just requires a string.
|
||||
|
||||
mkPrep : Str -> Prep ;
|
||||
noPrep : Prep ;
|
||||
mkPreposition : Str -> Preposition ;
|
||||
mkPrep : Str -> Prep ;
|
||||
|
||||
-- (These two functions are synonyms.)
|
||||
|
||||
@@ -235,18 +229,12 @@ oper
|
||||
|
||||
partV : V -> Str -> V ;
|
||||
|
||||
--3 Reflexive verbs
|
||||
--
|
||||
-- By default, verbs are not reflexive; this function makes them that.
|
||||
|
||||
reflV : V -> V ;
|
||||
|
||||
--3 Two-place verbs
|
||||
--
|
||||
-- Two-place verbs need a preposition, except the special case with direct object.
|
||||
-- (transitive verbs). Notice that a particle comes from the $V$.
|
||||
|
||||
mkV2 : V -> Prep -> V2 ;
|
||||
mkV2 : V -> Preposition -> V2 ;
|
||||
|
||||
dirV2 : V -> V2 ;
|
||||
|
||||
@@ -255,9 +243,9 @@ oper
|
||||
-- Three-place (ditransitive) verbs need two prepositions, of which
|
||||
-- the first one or both can be absent.
|
||||
|
||||
mkV3 : V -> Prep -> Prep -> V3 ; -- speak, with, about
|
||||
dirV3 : V -> Prep -> V3 ; -- give,_,to
|
||||
dirdirV3 : V -> V3 ; -- give,_,_
|
||||
mkV3 : V -> Str -> Str -> V3 ; -- speak, with, about
|
||||
dirV3 : V -> Str -> V3 ; -- give,_,to
|
||||
dirdirV3 : V -> V3 ; -- give,_,_
|
||||
|
||||
--3 Other complement patterns
|
||||
--
|
||||
@@ -266,36 +254,29 @@ oper
|
||||
|
||||
mkV0 : V -> V0 ;
|
||||
mkVS : V -> VS ;
|
||||
mkV2S : V -> Prep -> V2S ;
|
||||
mkV2S : V -> Str -> V2S ;
|
||||
mkVV : V -> VV ;
|
||||
mkV2V : V -> Prep -> Prep -> V2V ;
|
||||
mkV2V : V -> Str -> Str -> V2V ;
|
||||
mkVA : V -> VA ;
|
||||
mkV2A : V -> Prep -> V2A ;
|
||||
mkV2A : V -> Str -> V2A ;
|
||||
mkVQ : V -> VQ ;
|
||||
mkV2Q : V -> Prep -> V2Q ;
|
||||
mkV2Q : V -> Str -> V2Q ;
|
||||
|
||||
mkAS : A -> AS ;
|
||||
mkA2S : A -> Prep -> A2S ;
|
||||
mkA2S : A -> Str -> A2S ;
|
||||
mkAV : A -> AV ;
|
||||
mkA2V : A -> Prep -> A2V ;
|
||||
mkA2V : A -> Str -> A2V ;
|
||||
|
||||
-- Notice: categories $V2S, V2V, V2A, V2Q$ are in v 1.0 treated
|
||||
-- just as synonyms of $V2$, and the second argument is given
|
||||
-- as an adverb. Likewise $AS, A2S, AV, A2V$ are just $A$.
|
||||
-- $V0$ is just $V$.
|
||||
|
||||
V0, V2S, V2V, V2A, V2Q : Type ;
|
||||
AS, A2S, AV, A2V : Type ;
|
||||
|
||||
--.
|
||||
--2 Definitions of paradigms
|
||||
--
|
||||
-- The definitions should not bother the user of the API. So they are
|
||||
-- hidden from the document.
|
||||
--.
|
||||
|
||||
Gender = MorphoEng.Gender ;
|
||||
Number = MorphoEng.Number ;
|
||||
Case = MorphoEng.Case ;
|
||||
Gender = SyntaxEng.Gender ;
|
||||
Number = SyntaxEng.Number ;
|
||||
Case = SyntaxEng.Case ;
|
||||
human = Masc ;
|
||||
nonhuman = Neutr ;
|
||||
masculine = Masc ;
|
||||
@@ -305,7 +286,7 @@ oper
|
||||
nominative = Nom ;
|
||||
genitive = Gen ;
|
||||
|
||||
Preposition : Type = Str ; -- obsolete
|
||||
Preposition = Str ;
|
||||
|
||||
regN = \ray ->
|
||||
let
|
||||
@@ -337,32 +318,27 @@ oper
|
||||
mkN man men (man + "'s") mens ;
|
||||
|
||||
mkN = \man,men,man's,men's ->
|
||||
mkNoun man man's men men's ** {g = Neutr ; lock_N = <>} ;
|
||||
mkNoun man men man's men's ** {g = Neutr ; lock_N = <>} ;
|
||||
|
||||
genderN g man = {s = man.s ; g = g ; lock_N = <>} ;
|
||||
|
||||
compoundN s n = {s = \\x,y => s ++ n.s ! x ! y ; g=n.g ; lock_N = <>} ;
|
||||
mkN2 = \n,p -> UseN n ** {lock_N2 = <> ; s2 = p} ;
|
||||
regN2 n = mkN2 (regN n) (mkPreposition "of") ;
|
||||
mkN3 = \n,p,q -> UseN n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
|
||||
cnN2 = \n,p -> n ** {lock_N2 = <> ; s2 = p} ;
|
||||
cnN3 = \n,p,q -> n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
|
||||
|
||||
mkN2 = \n,p -> n ** {lock_N2 = <> ; c2 = p.s} ;
|
||||
regN2 n = mkN2 (regN n) (mkPrep "of") ;
|
||||
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = p.s ; c3 = q.s} ;
|
||||
cnN2 = \n,p -> n ** {lock_N2 = <> ; c2 = p.s} ;
|
||||
cnN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = p.s ; c3 = q.s} ;
|
||||
|
||||
regPN n = regGenPN n human ;
|
||||
regGenPN n g = nameReg n g ** {lock_PN = <>} ;
|
||||
regPN n g = nameReg n g ** {lock_PN = <>} ;
|
||||
nounPN n = {s = n.s ! singular ; g = n.g ; lock_PN = <>} ;
|
||||
mkNP x y n g = {s = table {Gen => x ; _ => y} ; a = agrP3 n ;
|
||||
mkNP x y n g = {s = table {GenP => x ; _ => y} ; a = toAgr n P3 g ;
|
||||
lock_NP = <>} ;
|
||||
|
||||
mkA a b = mkAdjective a a a b ** {lock_A = <>} ;
|
||||
mkA a b = mkAdjective a b ** {lock_A = <>} ;
|
||||
regA a = regAdjective a ** {lock_A = <>} ;
|
||||
|
||||
mkA2 a p = a ** {c2 = p.s ; lock_A2 = <>} ;
|
||||
mkA2 a p = a ** {s2 = p ; lock_A2 = <>} ;
|
||||
|
||||
ADeg = A ; ----
|
||||
|
||||
mkADeg a b c d = mkAdjective a b c d ** {lock_A = <>} ;
|
||||
mkADeg a b c d = mkAdjDegrWorst a b c c d d ** {lock_ADeg = <>} ;
|
||||
|
||||
regADeg happy =
|
||||
let
|
||||
@@ -377,26 +353,22 @@ oper
|
||||
"y" => happ + "ily" ;
|
||||
_ => happy + "ly"
|
||||
} ;
|
||||
in mkADeg happy (happie + "r") (happie + "st") happily ;
|
||||
in mkADeg happy happily (happie + "r") (happie + "st") ;
|
||||
|
||||
duplADeg fat =
|
||||
mkADeg fat
|
||||
(fat + last fat + "er") (fat + last fat + "est") (fat + "ly") ;
|
||||
|
||||
compoundADeg a =
|
||||
let ad = (a.s ! AAdj Posit)
|
||||
in mkADeg ad ("more" ++ ad) ("most" ++ ad) (a.s ! AAdv) ;
|
||||
|
||||
adegA a = a ;
|
||||
duplADeg fat = mkADeg fat
|
||||
(fat + "ly") (fat + last fat + "er") (fat + last fat + "est") ;
|
||||
compoundADeg a = let ad = (a.s ! AAdj) in
|
||||
mkADeg ad (a.s ! AAdv) ("more" ++ ad) ("most" ++ ad) ;
|
||||
adegA a = {s = a.s ! Pos ; lock_A = <>} ;
|
||||
|
||||
mkAdv x = ss x ** {lock_Adv = <>} ;
|
||||
mkAdV x = ss x ** {lock_AdV = <>} ;
|
||||
mkAdA x = ss x ** {lock_AdA = <>} ;
|
||||
|
||||
mkPreposition p = p ;
|
||||
mkPrep p = ss p ** {lock_Prep = <>} ;
|
||||
noPrep = mkPrep [] ;
|
||||
|
||||
mkV a b c d e = mkVerb a b c d e ** {s1 = [] ; lock_V = <>} ;
|
||||
mkV a b c d e = mkVerbP3worst a b c d e ** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
regV cry =
|
||||
let
|
||||
@@ -422,46 +394,36 @@ oper
|
||||
mkV fit (fit + "s") (fitt + "ed") (fitt + "ed") (fitt + "ing") ;
|
||||
|
||||
irregV x y z = let reg = (regV x).s in
|
||||
mkV x (reg ! VPres) y z (reg ! VPresPart) ** {s1 = [] ; lock_V = <>} ;
|
||||
mkV x (reg ! Indic Sg) y z (reg ! PresPart) ** {s1 = [] ; lock_V = <>} ;
|
||||
|
||||
irregDuplV fit y z =
|
||||
let
|
||||
fitting = (regDuplV fit).s ! VPresPart
|
||||
fitting = (regDuplV fit).s ! PresPart
|
||||
in
|
||||
mkV fit (fit + "s") y z fitting ;
|
||||
|
||||
partV v p = verbPart v p ** {lock_V = <>} ;
|
||||
reflV v = {s = v.s ; part = v.part ; lock_V = v.lock_V ; isRefl = True} ;
|
||||
partV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
|
||||
|
||||
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; c2 = p.s ; lock_V2 = <>} ;
|
||||
dirV2 v = mkV2 v noPrep ;
|
||||
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; s3 = p ; lock_V2 = <>} ;
|
||||
dirV2 v = mkV2 v [] ;
|
||||
|
||||
mkV3 v p q = v ** {s = v.s ; s1 = v.s1 ; c2 = p.s ; c3 = q.s ; lock_V3 = <>} ;
|
||||
dirV3 v p = mkV3 v noPrep p ;
|
||||
dirdirV3 v = dirV3 v noPrep ;
|
||||
mkV3 v p q = v ** {s = v.s ; s1 = v.s1 ; s3 = p ; s4 = q ; lock_V3 = <>} ;
|
||||
dirV3 v p = mkV3 v [] p ;
|
||||
dirdirV3 v = dirV3 v [] ;
|
||||
|
||||
mkV0 v = v ** {lock_V0 = <>} ;
|
||||
mkVS v = v ** {lock_VS = <>} ;
|
||||
mkVV v = {
|
||||
s = table {VVF vf => v.s ! vf ; _ => variants {}} ;
|
||||
isAux = False ; lock_VV = <>
|
||||
} ;
|
||||
mkVQ v = v ** {lock_VQ = <>} ;
|
||||
|
||||
V0 : Type = V ;
|
||||
V2S, V2V, V2Q, V2A : Type = V2 ;
|
||||
AS, A2S, AV : Type = A ;
|
||||
A2V : Type = A2 ;
|
||||
|
||||
mkV0 v = v ** {lock_V = <>} ;
|
||||
mkV2S v p = mkV2 v p ** {lock_V2 = <>} ;
|
||||
mkV2V v p t = mkV2 v p ** {s4 = t ; lock_V2 = <>} ;
|
||||
mkV2S v p = mkV2 v p ** {lock_V2S = <>} ;
|
||||
mkVV v = verb2aux v ** {isAux = False ; lock_VV = <>} ;
|
||||
mkV2V v p t = mkV2 v p ** {s4 = t ; lock_V2V = <>} ;
|
||||
mkVA v = v ** {lock_VA = <>} ;
|
||||
mkV2A v p = mkV2 v p ** {lock_V2A = <>} ;
|
||||
mkV2Q v p = mkV2 v p ** {lock_V2 = <>} ;
|
||||
mkVQ v = v ** {lock_VQ = <>} ;
|
||||
mkV2Q v p = mkV2 v p ** {lock_V2Q = <>} ;
|
||||
|
||||
mkAS v = v ** {lock_A = <>} ;
|
||||
mkA2S v p = mkA2 v p ** {lock_A = <>} ;
|
||||
mkAV v = v ** {lock_A = <>} ;
|
||||
mkA2V v p = mkA2 v p ** {lock_A2 = <>} ;
|
||||
mkAS v = v ** {lock_AS = <>} ;
|
||||
mkA2S v p = mkA2 v p ** {lock_A2S = <>} ;
|
||||
mkAV v = v ** {lock_AV = <>} ;
|
||||
mkA2V v p = mkA2 v p ** {lock_A2V = <>} ;
|
||||
|
||||
} ;
|
||||
101
lib/resource-0.9/english/StructuralEng.gf
Normal file
101
lib/resource-0.9/english/StructuralEng.gf
Normal file
@@ -0,0 +1,101 @@
|
||||
--# -path=.:../abstract:../../prelude
|
||||
|
||||
--1 The Top-Level English Resource Grammar: Structural Words
|
||||
--
|
||||
-- Aarne Ranta 2002 -- 2003
|
||||
--
|
||||
concrete StructuralEng of Structural =
|
||||
CategoriesEng, NumeralsEng ** open Prelude, SyntaxEng in {
|
||||
|
||||
flags optimize=all ;
|
||||
|
||||
lin
|
||||
UseNumeral i = {
|
||||
s = table {Nom => i.s ! NCard ; Gen => i.s ! NCard ++ "'s"} ; n = i.n} ; ---
|
||||
|
||||
|
||||
above_Prep = ss "above" ;
|
||||
after_Prep = ss "after" ;
|
||||
all8mass_Det = mkDeterminer Sg "all" ; --- all the missing
|
||||
all_NDet = mkDeterminerNum "all" ;
|
||||
almost_Adv = ss "almost" ;
|
||||
although_Subj = ss "although" ;
|
||||
and_Conj = ss "and" ** {n = Pl} ;
|
||||
because_Subj = ss "because" ;
|
||||
before_Prep = ss "before" ;
|
||||
behind_Prep = ss "behind" ;
|
||||
between_Prep = ss "between" ;
|
||||
both_AndConjD = sd2 "both" "and" ** {n = Pl} ;
|
||||
by8agent_Prep = ss "by" ;
|
||||
by8means_Prep = ss "by" ;
|
||||
can8know_VV = vvCan ;
|
||||
can_VV = vvCan ;
|
||||
during_Prep = ss "during" ;
|
||||
either8or_ConjD = sd2 "either" "or" ** {n = Sg} ;
|
||||
everybody_NP = nameNounPhrase (nameReg "everybody" human) ;
|
||||
every_Det = everyDet ;
|
||||
everything_NP = nameNounPhrase (nameReg "everything" Neutr) ;
|
||||
everywhere_Adv = ss "everywhere" ;
|
||||
from_Prep = ss "from" ;
|
||||
he_NP = pronNounPhrase pronHe ;
|
||||
how_IAdv = ss "how" ;
|
||||
how8many_IDet = mkDeterminer Pl ["how many"] ;
|
||||
if_Subj = ss "if" ;
|
||||
in8front_Prep = ss ["in front of"] ;
|
||||
i_NP = pronNounPhrase pronI ;
|
||||
in_Prep = ss "in" ;
|
||||
it_NP = pronNounPhrase pronIt ;
|
||||
many_Det = mkDeterminer Pl "many" ;
|
||||
most_Det = mkDeterminer Sg "most" ;
|
||||
most8many_Det = mostDet ;
|
||||
much_Det = mkDeterminer Sg ["a lot of"] ; ---
|
||||
must_VV = vvMust ;
|
||||
|
||||
no_Phr = ss "No." ;
|
||||
on_Prep = ss "on" ;
|
||||
or_Conj = ss "or" ** {n = Sg} ;
|
||||
otherwise_Adv = ss "otherwise" ;
|
||||
part_Prep = ss "of" ;
|
||||
possess_Prep = ss "of" ;
|
||||
quite_Adv = ss "quite" ;
|
||||
she_NP = pronNounPhrase pronShe ;
|
||||
so_Adv = ss "so" ;
|
||||
somebody_NP = nameNounPhrase (nameReg "somebody" human) ;
|
||||
some_Det = mkDeterminer Sg "some" ;
|
||||
some_NDet = mkDeterminerNum "some" ;
|
||||
something_NP = nameNounPhrase (nameReg "something" Neutr) ;
|
||||
somewhere_Adv = ss "somewhere" ;
|
||||
that_Det = mkDeterminer Sg "that" ;
|
||||
that_NP = nameNounPhrase (nameReg "that" Neutr) ;
|
||||
therefore_Adv = ss "therefore" ;
|
||||
these_NDet = mkDeterminerNum "these" ;
|
||||
they8fem_NP = pronNounPhrase pronThey ;
|
||||
they_NP = pronNounPhrase pronThey ;
|
||||
this_Det = mkDeterminer Sg "this" ;
|
||||
this_NP = nameNounPhrase (nameReg "this" Neutr) ;
|
||||
those_NDet = mkDeterminerNum "those" ;
|
||||
thou_NP = pronNounPhrase pronYouSg ;
|
||||
through_Prep = ss "through" ;
|
||||
too_Adv = ss "too" ;
|
||||
to_Prep = ss "to" ;
|
||||
under_Prep = ss "under" ;
|
||||
very_Adv = ss "very" ;
|
||||
want_VV = verb2aux (verbNoPart (regVerbP3 "want")) ** {isAux = False} ;
|
||||
we_NP = pronNounPhrase pronWe ;
|
||||
what8many_IP = intPronWhat plural ;
|
||||
what8one_IP = intPronWhat singular ;
|
||||
when_IAdv = ss "when" ;
|
||||
when_Subj = ss "when" ;
|
||||
where_IAdv = ss "where" ;
|
||||
which8many_IDet = mkDeterminer Pl ["which"] ;
|
||||
which8one_IDet = mkDeterminer Sg ["which"] ;
|
||||
who8many_IP = intPronWho plural ;
|
||||
who8one_IP = intPronWho singular ;
|
||||
why_IAdv = ss "why" ;
|
||||
without_Prep = ss "without" ;
|
||||
with_Prep = ss "with" ;
|
||||
ye_NP = pronNounPhrase pronYouPl ;
|
||||
you_NP = pronNounPhrase pronYouSg ;
|
||||
yes_Phr = ss "Yes." ;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user