next-lib renamed to lib, lib to old-lib

This commit is contained in:
aarne
2009-06-22 15:39:08 +00:00
parent 90bd07b1cf
commit 2116f41bc2
1433 changed files with 8 additions and 8 deletions

214
lib/src/Make.hs Normal file
View File

@@ -0,0 +1,214 @@
module Main where
import Control.Monad
import Data.Maybe
import System.Cmd
import System.Directory
import System.Environment
import System.Exit
-- Make commands for compiling and testing resource grammars.
-- usage: runghc Make ((present? OPT?) | (clone FILE))? LANGS?
-- where
-- - OPT = (lang | api | math | pgf | test | demo | parse | clean)
-- - LANGS has the form e.g. langs=Eng,Fin,Rus
-- - clone with a flag file=FILENAME clones the file to the specified languages,
-- by replacing the 3-letter language name of the original in both
-- the filename and the body
-- with each name in the list (default: all languages)
-- With no argument, lang and api are done, in this order.
-- See 'make' below for what is done by which command.
default_gf = "../../dist/build/gf/gf"
presApiPath = "-path=api:present"
presSymbolPath = "-path=.:abstract:present:common:romance:scandinavian" ----
-- the languages have long directory names and short ISO codes (3 letters)
-- we also give the decodings for postprocessing linearizations, as long as grammars
-- don't support all flags needed; they are used in tests
langsCoding = [
(("arabic", "Ara"),""),
(("bulgarian","Bul"),""),
(("catalan", "Cat"),""),
(("danish", "Dan"),""),
(("english", "Eng"),""),
(("finnish", "Fin"),""),
(("french", "Fre"),""),
(("hindi", "Hin"),"to_devanagari"),
(("german", "Ger"),""),
(("interlingua","Ina"),""),
(("italian", "Ita"),""),
(("latin", "Lat"),""),
(("norwegian","Nor"),""),
(("polish", "Pol"),""),
(("romanian", "Ron"),""),
(("russian", "Rus"),""),
(("spanish", "Spa"),""),
(("swedish", "Swe"),""),
(("thai", "Tha"),"to_thai"),
(("turkish", "Tur"),"")
]
langs = map fst langsCoding
-- languagues for which to compile Lang
langsLang = langs `except` ["Ara","Pol","Ron","Tur"]
-- languages for which to compile Try
langsAPI = langsLang `except` ["Bul","Hin","Ina","Lat","Rus","Tha"]
-- languages for which to compile minimal Syntax
langsMinimal = langs `only` ["Eng","Bul","Ger","Ita"]
-- languages for which to run treebank test
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"]
-- languages for which to run demo test
langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
-- languages for which to compile parsing grammars
langsParse = langs `only` ["Eng"]
-- languages for which langs.pgf is built
langsPGF = langsTest `only` ["Eng","Fre","Swe"]
-- languages for which Compatibility exists (to be extended)
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
treebankExx = "exx-resource.gft"
treebankResults = "exx-resource.gftb"
main = do
xx <- getArgs
make xx
make :: [String] -> IO ()
make xx = do
let ifx opt act = if null xx || elem opt xx then act >> return () else return ()
let ifxx opt act = if elem opt xx then act >> return () else return ()
let pres = elem "present" xx
let dir = if pres then "../present" else "../alltenses"
let optl ls = maybe ls id $ getOptLangs xx
ifx "lang" $ do
mapM_ (gfc pres [] . lang) (optl langsLang)
mapM_ (gfc pres presSymbolPath . symbol) (optl langsAPI)
copy "*/*.gfo" dir
ifx "compat" $ do
mapM_ (gfc pres [] . compat) (optl langsCompat)
copy "*/Compatibility*.gfo" dir
ifx "api" $ do
mapM_ (gfc pres presApiPath . try) (optl langsAPI)
mapM_ (gfc pres presApiPath . symbolic) (optl langsAPI)
copy "*/*.gfo" dir
ifx "minimal" $ do
mapM_ (gfcmin presApiPath . syntax) (optl langsMinimal)
copy "api/*.gfo" "../minimal"
ifxx "pgf" $ do
run_gfc $ ["-s","--make","--name=langs","--parser=off",
"--output-dir=" ++ dir]
++ [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- optl langsPGF]
ifxx "test" $ do
let ls = optl langsTest
gf (treeb "Lang" ls) $ unwords [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- ls]
ifxx "demo" $ do
let ls = optl langsDemo
gf (demos "Demo" ls) $ unwords ["demo/Demo" ++ la ++ ".gf" | (_,la) <- ls]
ifxx "parse" $ do
mapM_ (gfc pres [] . parse) (optl langsParse)
copy "parse/*.gfo parse/oald/*.gfo" dir
ifxx "clean" $ do
system "rm -f */*.gfo ../alltenses/*.gfo ../present/*.gfo"
ifxx "clone" $ do
let (pref,lang) = case getLangName xx of
Just pl -> pl
_ -> error "expected flag option file=ppppppLLL.gf"
s <- readFile (pref ++ lang ++ ".gf")
mapM_ (\la -> writeFile (pref ++ la ++ ".gf") (replaceLang lang la s)) (map snd (optl langs))
return ()
gfc pres ppath file = do
let preproc = if pres then "-preproc=./mkPresent" else ""
let path = if pres then ppath else ""
putStrLn $ "Compiling " ++ file
run_gfc ["-s","-src", preproc, path, file]
gfcmin path file = do
let preproc = "-preproc=./mkMinimal"
putStrLn $ "Compiling minimal " ++ file
run_gfc ["-s","-src", preproc, path, file]
gf comm file = do
putStrLn $ "Reading " ++ file
let cmd = "echo \"" ++ comm ++ "\" | gf -s " ++ file
putStrLn cmd
system cmd
treeb abstr ls = "rf -lines -tree -file=" ++ treebankExx ++
" | l -treebank " ++ unlexer abstr ls ++ " | wf -file=" ++ treebankResults
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
" | ps -to_html | wf -file=resdemo.html"
lang (lla,la) = lla ++ "/All" ++ la ++ ".gf"
compat (lla,la) = lla ++ "/Compatibility" ++ la ++ ".gf"
symbol (lla,la) = lla ++ "/Symbol" ++ la ++ ".gf"
try (lla,la) = "api/Try" ++ la ++ ".gf"
syntax (lla,la) = "api/Syntax" ++ la ++ ".gf"
symbolic (lla,la) = "api/Symbolic" ++ la ++ ".gf"
parse (lla,la) = "parse/Parse" ++ la ++ ".gf"
except ls es = filter (flip notElem es . snd) ls
only ls es = filter (flip elem es . snd) ls
-- list of languages overriding the definitions above
getOptLangs args = case [ls | a <- args, let (f,ls) = splitAt 6 a, f=="langs="] of
ls:_ -> return $ findLangs $ seps ls
_ -> Nothing
where
seps = words . map (\c -> if c==',' then ' ' else c)
findLangs ls = [lang | lang@(_,la) <- langs, elem la ls]
-- the file name has the form p....pLLL.gf, i.e. 3-letter lang name, suffix .gf
getLangName args = case [ls | a <- args, let (f,ls) = splitAt 5 a, f=="file="] of
fi:_ -> let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in return (reverse ferp,reverse nal)
_ -> Nothing
replaceLang s1 s2 = repl where
repl s = case s of
c:cs -> case splitAt lgs s of
(pre,rest) | pre == s1 -> s2 ++ repl rest
_ -> c : repl cs
_ -> s
lgs = 3 -- length s1
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
"\\\""
where
unlex lla = maybe "" id $ lookup lla langsCoding
-- | Runs the gf executable in compile mode with the given arguments.
run_gfc :: [String] -> IO ()
run_gfc args =
do let args' = ["-batch"] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"]
--- do let args' = ["-batch","-gf-lib-path=."] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"] --- why path? AR
putStrLn $ "Running: " ++ default_gf ++ " " ++ unwords (map showArg args')
e <- rawSystem default_gf args'
case e of
ExitSuccess -> return ()
ExitFailure i -> putStrLn $ "gf exited with exit code: " ++ show i
where rts_flags = ["-K100M"]
showArg arg = "'" ++ arg ++ "'"
copy :: String -> String -> IO ()
copy from to =
do system $ "cp " ++ from ++ " " ++ to
return ()

60
lib/src/Makefile Normal file
View File

@@ -0,0 +1,60 @@
RUNGHC=runghc
RUNMAKE=$(RUNGHC) Make.hs
GF_LIB_PATH=..
.PHONY: all present alltenses lang api math prelude test demo parse synopsis link compiled constructX clean
all: link prelude constructX present alltenses compat
present:
$(RUNMAKE) present lang
$(RUNMAKE) present api
alltenses:
$(RUNMAKE) lang
$(RUNMAKE) api
lang:
$(RUNMAKE) lang
api:
$(RUNMAKE) api
compat:
$(RUNMAKE) present compat
prelude:
gf -batch prelude/*.gf
cp -p prelude/*.gfo ../prelude
constructX:
gf -batch common/ConstructX.gf
cp -p common/ConstructX.gfo ../prelude
MakeStructural:
gf -batch */MakeStructural*.gf
cp -p */MakeStructural*.gfo ../present
cp -p */MakeStructural*.gfo ../alltenses
test:
$(RUNMAKE) test
demo:
$(RUNMAKE) demo
parse:
$(RUNMAKE) parse
synopsis:
cd doc ; $(RUNGHC) MkSynopsis ; cd ..
link:
chmod a+x mkPresent mkMinimal
compiled:
(cd .. && tar -zcf resource-compiled.tar.gz prelude alltenses present)
clean:
$(RUNMAKE) clean

View File

@@ -0,0 +1,35 @@
--1 Adjective: Adjectives and Adjectival Phrases
abstract Adjective = Cat ** {
fun
-- The principal ways of forming an adjectival phrase are
-- positive, comparative, relational, reflexive-relational, and
-- elliptic-relational.
PositA : A -> AP ; -- warm
ComparA : A -> NP -> AP ; -- warmer than I
ComplA2 : A2 -> NP -> AP ; -- married to her
ReflA2 : A2 -> AP ; -- married to itself
UseA2 : A2 -> AP ; -- married
UseComparA : A -> AP ; -- warmer
CAdvAP : CAdv -> AP -> NP -> AP ; -- as cool as John
-- The superlative use is covered in $Ord$.
AdjOrd : Ord -> AP ; -- warmest
-- Sentence and question complements defined for all adjectival
-- phrases, although the semantics is only clear for some adjectives.
SentAP : AP -> SC -> AP ; -- good that she is here
-- An adjectival phrase can be modified by an *adadjective*, such as "very".
AdAP : AdA -> AP -> AP ; -- very warm
-- The formation of adverbs from adjective (e.g. "quickly") is covered
-- in [Adverb Adverb.html].
}

View File

@@ -0,0 +1,32 @@
--1 Adverb: Adverbs and Adverbial Phrases
abstract Adverb = Cat ** {
fun
-- The two main ways of forming adverbs are from adjectives and by
-- prepositions from noun phrases.
PositAdvAdj : A -> Adv ; -- warmly
PrepNP : Prep -> NP -> Adv ; -- in the house
-- Comparative adverbs have a noun phrase or a sentence as object of
-- comparison.
ComparAdvAdj : CAdv -> A -> NP -> Adv ; -- more warmly than John
ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs
-- Adverbs can be modified by 'adadjectives', just like adjectives.
AdAdv : AdA -> Adv -> Adv ; -- very quickly
-- Subordinate clauses can function as adverbs.
SubjS : Subj -> S -> Adv ; -- when she sleeps
-- Comparison adverbs also work as numeral adverbs.
AdnCAdv : CAdv -> AdN ; -- less (than five)
}

View File

@@ -0,0 +1,63 @@
--1 Obsolete constructs included for backward-compatibility
abstract Backward = Cat ** {
-- from Cat
cat
Slash ;
fun
-- from Verb 19/4/2008
ComplV2 : V2 -> NP -> VP ; -- use it
ComplV3 : V3 -> NP -> NP -> VP ; -- send a message to her
ComplV2V : V2V -> NP -> VP -> VP ; -- cause it to burn
ComplV2S : V2S -> NP -> S -> VP ; -- tell me that it rains
ComplV2Q : V2Q -> NP -> QS -> VP ; -- ask me who came
ComplV2A : V2A -> NP -> AP -> VP ; -- paint it red
ReflV2 : V2 -> VP ; -- use itself
UseVQ : VQ -> V2 ; -- ask (a question)
UseVS : VS -> V2 ; -- know (a secret)
-- from Sentence 19/4/2008
SlashV2 : NP -> V2 -> Slash ; -- (whom) he sees
SlashVVV2 : NP -> VV -> V2 -> Slash; -- (whom) he wants to see
-- from Noun 19/4/2008
NumInt : Int -> Num ; -- 51
OrdInt : Int -> Ord ; -- 51st (DEPRECATED)
NoOrd : Ord ;
-- 20/4
DetSg : Quant -> Ord -> Det ; -- the best man
DetPl : Quant -> Num -> Ord -> Det ; -- the five best men
NoNum : Num ;
-- 22/4
DefArt : Quant ; -- the (house), the (houses)
IndefArt : Quant ; -- a (house), (houses)
MassDet : Quant ; -- (beer)
-- from Structural 19/4/2008
that_NP : NP ;
these_NP : NP ;
this_NP : NP ;
those_NP : NP ;
whichPl_IDet : IDet ;
whichSg_IDet : IDet ;
-- from Adverb
AdvSC : SC -> Adv ; -- that he arrives ---- REMOVE?
}

133
lib/src/abstract/Cat.gf Normal file
View File

@@ -0,0 +1,133 @@
--1 Cat: the Category System
-- The category system is central to the library in the sense
-- that the other modules ($Adjective$, $Adverb$, $Noun$, $Verb$ etc)
-- communicate through it. This means that a e.g. a function using
-- $NP$s in $Verb$ need not know how $NP$s are constructed in $Noun$:
-- it is enough that both $Verb$ and $Noun$ use the same type $NP$,
-- which is given here in $Cat$.
--
-- Some categories are inherited from [``Common`` Common.html].
-- The reason they are defined there is that they have the same
-- implementation in all languages in the resource (typically,
-- just a string). These categories are
-- $AdA, AdN, AdV, Adv, Ant, CAdv, IAdv, PConj, Phr$,
-- $Pol, SC, Tense, Text, Utt, Voc$.
--
-- Moreover, the list categories $ListAdv, ListAP, ListNP, ListS$
-- are defined on $Conjunction$ and only used locally there.
abstract Cat = Common ** {
cat
--2 Sentences and clauses
-- Constructed in [Sentence Sentence.html], and also in
-- [Idiom Idiom.html].
S ; -- declarative sentence e.g. "she lived here"
QS ; -- question e.g. "where did she live"
RS ; -- relative e.g. "in which she lived"
Cl ; -- declarative clause, with all tenses e.g. "she looks at this"
ClSlash;-- clause missing NP (S/NP in GPSG) e.g. "she looks at"
SSlash ;-- sentence missing NP e.g. "she has looked at"
Imp ; -- imperative e.g. "look at this"
--2 Questions and interrogatives
-- Constructed in [Question Question.html].
QCl ; -- question clause, with all tenses e.g. "why does she walk"
IP ; -- interrogative pronoun e.g. "who"
IComp ; -- interrogative complement of copula e.g. "where"
IDet ; -- interrogative determiner e.g. "how many"
IQuant; -- interrogative quantifier e.g. "which"
--2 Relative clauses and pronouns
-- Constructed in [Relative Relative.html].
RCl ; -- relative clause, with all tenses e.g. "in which she lives"
RP ; -- relative pronoun e.g. "in which"
--2 Verb phrases
-- Constructed in [Verb Verb.html].
VP ; -- verb phrase e.g. "is very warm"
Comp ; -- complement of copula, such as AP e.g. "very warm"
VPSlash ; -- verb phrase missing complement e.g. "give to John"
--2 Adjectival phrases
-- Constructed in [Adjective Adjective.html].
AP ; -- adjectival phrase e.g. "very warm"
--2 Nouns and noun phrases
-- Constructed in [Noun Noun.html].
-- Many atomic noun phrases e.g. "everybody"
-- are constructed in [Structural Structural.html].
-- The determiner structure is
-- ``` Predet (QuantSg | QuantPl Num) Ord
-- as defined in [Noun Noun.html].
CN ; -- common noun (without determiner) e.g. "red house"
NP ; -- noun phrase (subject or object) e.g. "the red house"
Pron ; -- personal pronoun e.g. "she"
Det ; -- determiner phrase e.g. "those seven"
Predet ; -- predeterminer (prefixed Quant) e.g. "all"
Quant ; -- quantifier ('nucleus' of Det) e.g. "this/these"
Num ; -- number determining element e.g. "seven"
Card ; -- cardinal number e.g. "seven"
Ord ; -- ordinal number (used in Det) e.g. "seventh"
--2 Numerals
-- Constructed in [Numeral Numeral.html].
Numeral ; -- cardinal or ordinal in words e.g. "five/fifth"
Digits ; -- cardinal or ordinal in digits e.g. "1,000/1,000th"
--2 Structural words
-- Constructed in [Structural Structural.html].
Conj ; -- conjunction e.g. "and"
---b DConj ; -- distributed conjunction e.g. "both - and"
Subj ; -- subjunction e.g. "if"
Prep ; -- preposition, or just case e.g. "in"
--2 Words of open classes
-- These are constructed in [Lexicon Lexicon.html] and in
-- additional lexicon modules.
V ; -- one-place verb e.g. "sleep"
V2 ; -- two-place verb e.g. "love"
V3 ; -- three-place verb e.g. "show"
VV ; -- verb-phrase-complement verb e.g. "want"
VS ; -- sentence-complement verb e.g. "claim"
VQ ; -- question-complement verb e.g. "wonder"
VA ; -- adjective-complement verb e.g. "look"
V2V ; -- verb with NP and V complement e.g. "cause"
V2S ; -- verb with NP and S complement e.g. "tell"
V2Q ; -- verb with NP and Q complement e.g. "ask"
V2A ; -- verb with NP and AP complement e.g. "paint"
A ; -- one-place adjective e.g. "warm"
A2 ; -- two-place adjective e.g. "divisible"
N ; -- common noun e.g. "house"
N2 ; -- relational noun e.g. "son"
N3 ; -- three-place relational noun e.g. "connection"
PN ; -- proper name e.g. "Paris"
-- DEPRECATED: QuantSg, QuantPl
--- QuantSg ;-- quantifier ('nucleus' of sing. Det) e.g. "every"
--- QuantPl ;-- quantifier ('nucleus' of plur. Det) e.g. "many"
}

View File

@@ -0,0 +1,64 @@
--1 Common: Structures with Common Implementations.
-- This module defines the categories that uniformly have the linearization
-- ${s : Str}$ in all languages.
-- Moreover, this module defines the abstract parameters of tense, polarity, and
-- anteriority, which are used in [``Phrase`` Phrase.html] to generate different
-- forms of sentences. Together they give 4 x 2 x 2 = 16 sentence forms.
-- These tenses are defined for all languages in the library. More tenses
-- can be defined in the language extensions, e.g. the "passé simple" of
-- Romance languages in [``ExtraRomance`` ../romance/ExtraRomance.gf].
abstract Common = {
cat
--2 Top-level units
-- Constructed in [``Text`` Text.html]: $Text$.
Text ; -- text consisting of several phrases e.g. "He is here. Why?"
-- Constructed in [``Phrase`` Phrase.html]:
Phr ; -- phrase in a text e.g. "but be quiet please"
Utt ; -- sentence, question, word... e.g. "be quiet"
Voc ; -- vocative or "please" e.g. "my darling"
PConj ; -- phrase-beginning conjunction e.g. "therefore"
-- Constructed in [``Sentence`` Sentence.html]:
SC ; -- embedded sentence or question e.g. "that it rains"
--2 Adverbs
-- Constructed in [``Adverb`` Adverb.html].
-- Many adverbs are constructed in [``Structural`` Structural.html].
Adv ; -- verb-phrase-modifying adverb e.g. "in the house"
AdV ; -- adverb directly attached to verb e.g. "always"
AdA ; -- adjective-modifying adverb e.g. "very"
AdN ; -- numeral-modifying adverb e.g. "more than"
IAdv ; -- interrogative adverb e.g. "why"
CAdv ; -- comparative adverb e.g. "more"
--2 Tense, polarity, and anteriority
Temp ; -- temporal and aspectual features e.g. past anterior
Tense ; -- tense e.g. present, past, future
Pol ; -- polarity e.g. positive, negative
Ant ; -- anteriority e.g. simultaneous, anterior
fun
TTAnt : Tense -> Ant -> Temp ;
PPos, PNeg : Pol ; -- I sleep/don't sleep
TPres : Tense ;
ASimul : Ant ;
TPast, TFut, TCond : Tense ; -- I slept/will sleep/would sleep --# notpresent
AAnter : Ant ; -- I have slept --# notpresent
}

View File

@@ -0,0 +1,9 @@
abstract Compatibility = Cat ** {
-- from Noun 19/4/2008
fun
NumInt : Int -> Num ; -- 57
OrdInt : Int -> Ord ; -- 57
}

View File

@@ -0,0 +1,45 @@
--1 Conjunction: Coordination
-- Coordination is defined for many different categories; here is
-- a sample. The rules apply to *lists* of two or more elements,
-- and define two general patterns:
-- - ordinary conjunction: X,...X and X
-- - distributed conjunction: both X,...,X and X
--
--
-- $VP$ conjunctions are not covered here, because their applicability
-- depends on language. Some special cases are defined in
-- [``Extra`` ../abstract/Extra.gf].
abstract Conjunction = Cat ** {
--2 Rules
fun
ConjS : Conj -> [S] -> S ; -- "he walks and she runs"
ConjRS : Conj -> [RS] -> RS ; -- "who walks and whose mother runs"
ConjAP : Conj -> [AP] -> AP ; -- "cold and warm"
ConjNP : Conj -> [NP] -> NP ; -- "she or we"
ConjAdv : Conj -> [Adv] -> Adv ; -- "here or there"
--2 Categories
-- These categories are only used in this module.
cat
[S]{2} ;
[RS]{2} ;
[Adv]{2} ;
[NP]{2} ;
[AP]{2} ;
--2 List constructors
-- The list constructors are derived from the list notation and therefore
-- not given explicitly. But here are their type signatures:
-- BaseC : C -> C -> [C] ; -- for C = S, AP, NP, Adv
-- ConsC : C -> [C] -> [C] ;
}

30
lib/src/abstract/Extra.gf Normal file
View File

@@ -0,0 +1,30 @@
--1 More syntax rules
-- This module defines syntax rules that are not implemented in all
-- languages, but in more than one, so that it makes sense to offer a
-- common API.
abstract Extra = Cat ** {
fun
GenNP : NP -> Quant ; -- this man's
ComplBareVS : VS -> S -> VP ; -- know you go
StrandRelSlash : RP -> ClSlash -> RCl ; -- that he lives in
EmptyRelSlash : ClSlash -> RCl ; -- he lives in
StrandQuestSlash : IP -> ClSlash -> QCl ; -- whom does John live with
-- $VP$ conjunction, which has different fragments implemented in
-- different languages - never a full $VP$, though.
cat
VPI ;
[VPI] {2} ;
fun
MkVPI : VP -> VPI ;
ConjVPI : Conj -> [VPI] -> VPI ;
ComplVPIVV : VV -> VPI -> VP ;
}

View File

@@ -0,0 +1,22 @@
--1 Grammar: the Main Module of the Resource Grammar
-- This grammar is a collection of the different grammar modules,
-- To test the resource, import [``Lang`` Lang.html], which also contains
-- a lexicon.
abstract Grammar =
Noun,
Verb,
Adjective,
Adverb,
Numeral,
Sentence,
Question,
Relative,
Conjunction,
Phrase,
Text,
Structural,
Idiom ;

22
lib/src/abstract/Idiom.gf Normal file
View File

@@ -0,0 +1,22 @@
--1 Idiom: Idiomatic Expressions
abstract Idiom = Cat ** {
-- This module defines constructions that are formed in fixed ways,
-- often different even in closely related languages.
fun
ImpersCl : VP -> Cl ; -- it is hot
GenericCl : VP -> Cl ; -- one sleeps
CleftNP : NP -> RS -> Cl ; -- it is I who did it
CleftAdv : Adv -> S -> Cl ; -- it is here she slept
ExistNP : NP -> Cl ; -- there is a house
ExistIP : IP -> QCl ; -- which houses are there
ProgrVP : VP -> VP ; -- be sleeping
ImpPl1 : VP -> Utt ; -- let's go
}

13
lib/src/abstract/Lang.gf Normal file
View File

@@ -0,0 +1,13 @@
--1 Lang: a Test Module for the Resource Grammar
-- This grammar is for testing the resource as included in the
-- language-independent API, consisting of a grammar and a lexicon.
-- The grammar without a lexicon is [``Grammar`` Grammar.html],
-- which may be more suitable to open in applications.
abstract Lang =
Grammar,
Lexicon
** {
flags startcat=Phr ;
} ;

355
lib/src/abstract/Lexicon.gf Normal file
View File

@@ -0,0 +1,355 @@
abstract Lexicon = Cat ** {
fun
add_V3 : V3 ;
airplane_N : N ;
already_Adv : Adv ;
animal_N : N ;
answer_V2S : V2S ;
apartment_N : N ;
apple_N : N ;
art_N : N ;
ashes_N : N ;
ask_V2Q : V2Q ;
baby_N : N ;
back_N : N ;
bad_A : A ;
bank_N : N ;
bark_N : N ;
beautiful_A : A ;
become_VA : VA ;
beer_N : N ;
beg_V2V : V2V ;
belly_N : N ;
big_A : A ;
bike_N : N ;
bird_N : N ;
bite_V2 : V2 ;
black_A : A ;
blood_N : N ;
blow_V : V ;
blue_A : A ;
boat_N : N ;
bone_N : N ;
book_N : N ;
boot_N : N ;
boss_N : N ;
boy_N : N ;
bread_N : N ;
break_V2 : V2 ;
breast_N : N ;
breathe_V : V ;
broad_A : A ;
brother_N2 : N2 ;
brown_A : A ;
burn_V : V ;
butter_N : N ;
buy_V2 : V2 ;
camera_N : N ;
cap_N : N ;
car_N : N ;
carpet_N : N ;
cat_N : N ;
ceiling_N : N ;
chair_N : N ;
cheese_N : N ;
child_N : N ;
church_N : N ;
city_N : N ;
clean_A : A ;
clever_A : A ;
close_V2 : V2 ;
cloud_N : N ;
coat_N : N ;
cold_A : A ;
come_V : V ;
computer_N : N ;
correct_A : A ;
country_N : N ;
count_V2 : V2 ;
cousin_N : N ;
cow_N : N ;
cut_V2 : V2 ;
day_N : N ;
die_V : V ;
dig_V : V ;
dirty_A : A ;
distance_N3 : N3 ;
doctor_N : N ;
dog_N : N ;
door_N : N ;
do_V2 : V2 ;
drink_V2 : V2 ;
drink_V2 : V2 ;
dry_A : A ;
dull_A : A ;
dust_N : N ;
ear_N : N ;
earth_N : N ;
easy_A2V : A2 ;
eat_V2 : V2 ;
eat_V2 : V2 ;
egg_N : N ;
empty_A : A ;
enemy_N : N ;
eye_N : N ;
factory_N : N ;
fall_V : V ;
far_Adv : Adv ;
father_N2 : N2 ;
fat_N : N ;
fear_VS : VS ;
fear_V2 : V2 ;
feather_N : N ;
fight_V2 : V2 ;
find_V2 : V2 ;
fingernail_N : N ;
fire_N : N ;
fish_N : N ;
float_V : V ;
floor_N : N ;
flower_N : N ;
flow_V : V ;
fly_V : V ;
fog_N : N ;
foot_N : N ;
forest_N : N ;
forget_V2 : V2 ;
freeze_V : V ;
fridge_N : N ;
friend_N : N ;
fruit_N : N ;
full_A : A ;
fun
fun_AV : A ;
garden_N : N ;
girl_N : N ;
give_V3 : V3 ;
glove_N : N ;
gold_N : N ;
good_A : A ;
go_V : V ;
grammar_N : N ;
grass_N : N ;
green_A : A ;
guts_N : N ;
hair_N : N ;
hand_N : N ;
harbour_N : N ;
hate_V2 : V2 ;
hat_N : N ;
head_N : N ;
heart_N : N ;
hear_V2 : V2 ;
hear_V2 : V2 ;
heavy_A : A ;
hill_N : N ;
hit_V2 : V2 ;
hold_V2 : V2 ;
hope_VS : VS ;
horn_N : N ;
horse_N : N ;
hot_A : A ;
house_N : N ;
hunt_V2 : V2 ;
husband_N : N ;
ice_N : N ;
important_A : A ;
industry_N : N ;
iron_N : N ;
john_PN : PN ;
jump_V : V ;
kill_V2 : V2 ;
king_N : N ;
knee_N : N ;
know_V2 : V2 ;
know_VS : VS ;
lake_N : N ;
lamp_N : N ;
language_N : N ;
laugh_V : V ;
leaf_N : N ;
learn_V2 : V2 ;
leather_N : N ;
leave_V2 : V2 ;
left_Ord : Ord ;
leg_N : N ;
lie_V : V ;
like_V2 : V2 ;
listen_V2 : V2 ;
liver_N : N ;
live_V : V ;
long_A : A ;
lose_V2 : V2 ;
louse_N : N ;
love_N : N ;
love_V2 : V2 ;
man_N : N ;
married_A2 : A2 ;
meat_N : N ;
milk_N : N ;
moon_N : N ;
mother_N2 : N2 ;
mountain_N : N ;
mouth_N : N ;
music_N : N ;
name_N : N ;
narrow_A : A ;
near_A : A ;
neck_N : N ;
new_A : A ;
newspaper_N : N ;
night_N : N ;
nose_N : N ;
now_Adv : Adv ;
number_N : N ;
oil_N : N ;
old_A : A ;
open_V2 : V2 ;
paint_V2A : V2A ;
paper_N : N ;
paris_PN : PN ;
peace_N : N ;
pen_N : N ;
person_N : N ;
planet_N : N ;
plastic_N : N ;
play_V2 : V2 ;
play_V : V ;
policeman_N : N ;
priest_N : N ;
probable_AS : A ;
pull_V2 : V2 ;
push_V2 : V2 ;
put_V2 : V2 ;
queen_N : N ;
question_N : N ;
radio_N : N ;
rain_N : N ;
rain_V0 : V ;
read_V2 : V2 ;
ready_A : A ;
reason_N : N ;
red_A : A ;
religion_N : N ;
restaurant_N : N ;
right_Ord : Ord ;
river_N : N ;
road_N : N ;
rock_N : N ;
roof_N : N ;
root_N : N ;
rope_N : N ;
rotten_A : A ;
round_A : A ;
rubber_N : N ;
rub_V2 : V2 ;
rule_N : N ;
run_V : V ;
salt_N : N ;
sand_N : N ;
say_VS : VS ;
school_N : N ;
science_N : N ;
scratch_V2 : V2 ;
sea_N : N ;
seed_N : N ;
seek_V2 : V2 ;
see_V2 : V2 ;
see_V2 : V2 ;
sell_V3 : V3 ;
send_V3 : V3 ;
sew_V : V ;
sharp_A : A ;
sheep_N : N ;
ship_N : N ;
shirt_N : N ;
shoe_N : N ;
shop_N : N ;
short_A : A ;
silver_N : N ;
sing_V : V ;
sister_N : N ;
sit_V : V ;
skin_N : N ;
sky_N : N ;
sleep_V : V ;
small_A : A ;
smell_V : V ;
smoke_N : N ;
smooth_A : A ;
snake_N : N ;
snow_N : N ;
sock_N : N ;
song_N : N ;
speak_V2 : V2 ;
spit_V : V ;
split_V2 : V2 ;
squeeze_V2 : V2 ;
stab_V2 : V2 ;
stand_V : V ;
star_N : N ;
steel_N : N ;
stick_N : N ;
stone_N : N ;
stop_V : V ;
stove_N : N ;
straight_A : A ;
student_N : N ;
stupid_A : A ;
suck_V2 : V2 ;
sun_N : N ;
swell_V : V ;
swim_V : V ;
switch8off_V2 : V2 ;
switch8on_V2 : V2 ;
table_N : N ;
tail_N : N ;
talk_V3 : V3 ;
teacher_N : N ;
teach_V2 : V2 ;
television_N : N ;
thick_A : A ;
thin_A : A ;
think_V : V ;
throw_V2 : V2 ;
tie_V2 : V2 ;
today_Adv : Adv ;
tongue_N : N ;
tooth_N : N ;
train_N : N ;
travel_V : V ;
tree_N : N ;
turn_V : V ;
ugly_A : A ;
uncertain_A : A ;
understand_V2 : V2 ;
university_N : N ;
village_N : N ;
vomit_V : V ;
wait_V2 : V2 ;
walk_V : V ;
warm_A : A ;
war_N : N ;
wash_V2 : V2 ;
watch_V2 : V2 ;
water_N : N ;
wet_A : A ;
white_A : A ;
wide_A : A ;
wife_N : N ;
wind_N : N ;
window_N : N ;
wine_N : N ;
wing_N : N ;
win_V2 : V2 ;
wipe_V2 : V2 ;
woman_N : N ;
wonder_VQ : VQ ;
wood_N : N ;
worm_N : N ;
write_V2 : V2 ;
year_N : N ;
yellow_A : A ;
young_A : A ;
}

136
lib/src/abstract/Noun.gf Normal file
View File

@@ -0,0 +1,136 @@
--1 Noun: Nouns, noun phrases, and determiners
abstract Noun = Cat ** {
--2 Noun phrases
-- The three main types of noun phrases are
-- - common nouns with determiners
-- - proper names
-- - pronouns
--
--
fun
DetCN : Det -> CN -> NP ; -- the man
UsePN : PN -> NP ; -- John
UsePron : Pron -> NP ; -- he
-- Pronouns are defined in the module [``Structural`` Structural.html].
-- A noun phrase already formed can be modified by a $Predet$erminer.
PredetNP : Predet -> NP -> NP; -- only the man
-- A noun phrase can also be postmodified by the past participle of a
-- verb, by an adverb, or by a relative clause
PPartNP : NP -> V2 -> NP ; -- the man seen
AdvNP : NP -> Adv -> NP ; -- Paris today
RelNP : NP -> RS -> NP ; -- Paris, which is here
-- Determiners can form noun phrases directly.
DetNP : Det -> NP ; -- these five
--2 Determiners
-- The determiner has a fine-grained structure, in which a 'nucleus'
-- quantifier and an optional numeral can be discerned.
DetQuant : Quant -> Num -> Det ; -- these five
DetQuantOrd : Quant -> Num -> Ord -> Det ; -- these five best
-- Whether the resulting determiner is singular or plural depends on the
-- cardinal.
-- All parts of the determiner can be empty, except $Quant$, which is
-- the "kernel" of a determiner. It is, however, the $Num$ that determines
-- the inherent number.
NumSg : Num ;
NumPl : Num ;
NumCard : Card -> Num ;
-- $Card$ consists of either digits or numeral words.
NumDigits : Digits -> Card ; -- 51
NumNumeral : Numeral -> Card ; -- fifty-one
-- The construction of numerals is defined in [Numeral Numeral.html].
-- A $Card$ can be modified by certain adverbs.
AdNum : AdN -> Card -> Card ; -- almost 51
-- An $Ord$ consists of either digits or numeral words.
-- Also superlative forms of adjectives behave syntactically like ordinals.
OrdDigits : Digits -> Ord ; -- 51st
OrdNumeral : Numeral -> Ord ; -- fifty-first
OrdSuperl : A -> Ord ; -- warmest
-- Definite and indefinite noun phrases are sometimes realized as
-- neatly distinct words (Spanish "un, unos ; el, los") but also without
-- any particular word (Finnish; Swedish definites).
IndefArt : Quant ;
DefArt : Quant ;
-- Nouns can be used without an article as mass nouns. The resource does
-- not distinguish mass nouns from other common nouns, which can result
-- in semantically odd expressions.
MassNP : CN -> NP ; -- (beer)
-- Pronouns have possessive forms. Genitives of other kinds
-- of noun phrases are not given here, since they are not possible
-- in e.g. Romance languages. They can be found in $Extra$ modules.
PossPron : Pron -> Quant ; -- my (house)
-- Other determiners are defined in [Structural Structural.html].
--2 Common nouns
-- Simple nouns can be used as nouns outright.
UseN : N -> CN ; -- house
-- Relational nouns take one or two arguments.
ComplN2 : N2 -> NP -> CN ; -- mother of the king
ComplN3 : N3 -> NP -> N2 ; -- distance from this city (to Paris)
-- Relational nouns can also be used without their arguments.
-- The semantics is typically derivative of the relational meaning.
UseN2 : N2 -> CN ; -- mother
Use2N3 : N3 -> N2 ; -- distance (from this city)
Use3N3 : N3 -> N2 ; -- distance (to Paris)
-- Nouns can be modified by adjectives, relative clauses, and adverbs
-- (the last rule will give rise to many 'PP attachment' ambiguities
-- when used in connection with verb phrases).
AdjCN : AP -> CN -> CN ; -- big house
RelCN : CN -> RS -> CN ; -- house that John bought
AdvCN : CN -> Adv -> CN ; -- house on the hill
-- Nouns can also be modified by embedded sentences and questions.
-- For some nouns this makes little sense, but we leave this for applications
-- to decide. Sentential complements are defined in [Verb Verb.html].
SentCN : CN -> SC -> CN ; -- question where she sleeps
--2 Apposition
-- This is certainly overgenerating.
ApposCN : CN -> NP -> CN ; -- city Paris (, numbers x and y)
} ;

View File

@@ -0,0 +1,60 @@
--1 Numerals
-- This grammar defines numerals from 1 to 999999.
-- The implementations are adapted from the
-- [numerals library http://www.cs.chalmers.se/~aarne/GF/examples/numerals/]
-- which defines numerals for 88 languages.
-- The resource grammar implementations add to this inflection (if needed)
-- and ordinal numbers.
--
-- *Note* 1. Number 1 as defined
-- in the category $Numeral$ here should not be used in the formation of
-- noun phrases, and should therefore be removed. Instead, one should use
-- [Structural Structural.html]$.one_Quant$. This makes the grammar simpler
-- because we can assume that numbers form plural noun phrases.
--
-- *Note* 2. The implementations introduce spaces between
-- parts of a numeral, which is often incorrect - more work on
-- (un)lexing is needed to solve this problem.
abstract Numeral = Cat ** {
cat
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
-- Numerals as sequences of digits have a separate, simpler grammar
cat
Dig ; -- single digit 0..9
fun
IDig : Dig -> Digits ; -- 8
IIDig : Dig -> Digits -> Digits ; -- 876
D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig ;
}

View File

@@ -0,0 +1,44 @@
--1 Phrase: Phrases and Utterances
abstract Phrase = Cat ** {
-- When a phrase is built from an utterance it can be prefixed
-- with a phrasal conjunction (such as "but", "therefore")
-- and suffixing with a vocative (typically a noun phrase).
fun
PhrUtt : PConj -> Utt -> Voc -> Phr ; -- but come here, my friend
-- Utterances are formed from sentences, questions, and imperatives.
UttS : S -> Utt ; -- John walks
UttQS : QS -> Utt ; -- is it good
UttImpSg : Pol -> Imp -> Utt; -- (don't) love yourself
UttImpPl : Pol -> Imp -> Utt; -- (don't) love yourselves
UttImpPol : Pol -> Imp -> Utt ; -- (don't) sleep (polite)
-- There are also 'one-word utterances'. A typical use of them is
-- as answers to questions.
-- *Note*. This list is incomplete. More categories could be covered.
-- Moreover, in many languages e.g. noun phrases in different cases
-- can be used.
UttIP : IP -> Utt ; -- who
UttIAdv : IAdv -> Utt ; -- why
UttNP : NP -> Utt ; -- this man
UttAdv : Adv -> Utt ; -- here
UttVP : VP -> Utt ; -- to sleep
-- The phrasal conjunction is optional. A sentence conjunction
-- can also used to prefix an utterance.
NoPConj : PConj ;
PConjConj : Conj -> PConj ; -- and
-- The vocative is optional. Any noun phrase can be made into vocative,
-- which may be overgenerating (e.g. "I").
NoVoc : Voc ;
VocNP : NP -> Voc ; -- my friend
}

View File

@@ -0,0 +1,41 @@
--1 Question: Questions and Interrogative Pronouns
abstract Question = Cat ** {
-- A question can be formed from a clause ('yes-no question') or
-- with an interrogative.
fun
QuestCl : Cl -> QCl ; -- does John walk
QuestVP : IP -> VP -> QCl ; -- who walks
QuestSlash : IP -> ClSlash -> QCl ; -- whom does John love
QuestIAdv : IAdv -> Cl -> QCl ; -- why does John walk
QuestIComp : IComp -> NP -> QCl ; -- where is John
-- Interrogative pronouns can be formed with interrogative
-- determiners, with or without a noun.
IdetCN : IDet -> CN -> IP ; -- which five songs
IdetIP : IDet -> IP ; -- which five
-- They can be modified with adverbs.
AdvIP : IP -> Adv -> IP ; -- who in Paris
-- Interrogative quantifiers have number forms and can take number modifiers.
IdetQuant : IQuant -> Num -> IDet ; -- which (five)
-- Interrogative adverbs can be formed prepositionally.
PrepIP : Prep -> IP -> IAdv ; -- with whom
-- Interrogative complements to copulas can be both adverbs and
-- pronouns.
CompIAdv : IAdv -> IComp ; -- where (is it)
CompIP : IP -> IComp ; -- who (is it)
-- More $IP$, $IDet$, and $IAdv$ are defined in $Structural$.
}

View File

@@ -0,0 +1,26 @@
--1 Relative clauses and pronouns
abstract Relative = Cat ** {
fun
-- The simplest way to form a relative clause is from a clause by
-- a pronoun similar to "such that".
RelCl : Cl -> RCl ; -- such that John loves her
-- The more proper ways are from a verb phrase
-- (formed in [``Verb`` Verb.html]) or a sentence
-- with a missing noun phrase (formed in [``Sentence`` Sentence.html]).
RelVP : RP -> VP -> RCl ; -- who loves John
RelSlash : RP -> ClSlash -> RCl ; -- whom John loves
-- Relative pronouns are formed from an 'identity element' by prefixing
-- or suffixing (depending on language) prepositional phrases or genitives.
IdRP : RP ; -- which
FunRP : Prep -> NP -> RP -> RP ; -- the mother of whom
}

View File

@@ -0,0 +1,100 @@
--1 Sentence: Sentences, Clauses, and Imperatives
abstract Sentence = Cat ** {
--2 Clauses
-- The $NP VP$ predication rule form a clause whose linearization
-- gives a table of all tense variants, positive and negative.
-- Clauses are converted to $S$ (with fixed tense) with the
-- $UseCl$ function below.
fun
PredVP : NP -> VP -> Cl ; -- John walks
-- Using an embedded sentence as a subject is treated separately.
-- This can be overgenerating. E.g. "whether you go" as subject
-- is only meaningful for some verb phrases.
PredSCVP : SC -> VP -> Cl ; -- that she goes is good
--2 Clauses missing object noun phrases
-- This category is a variant of the 'slash category' $S/NP$ of
-- GPSG and categorial grammars, which in turn replaces
-- movement transformations in the formation of questions
-- and relative clauses. Except $SlashV2$, the construction
-- rules can be seen as special cases of function composition, in
-- the style of CCG.
-- *Note* the set is not complete and lacks e.g. verbs with more than 2 places.
SlashVP : NP -> VPSlash -> ClSlash ; -- (whom) he sees
AdvSlash : ClSlash -> Adv -> ClSlash ; -- (whom) he sees today
SlashPrep : Cl -> Prep -> ClSlash ; -- (with whom) he walks
SlashVS : NP -> VS -> SSlash -> ClSlash ; -- (whom) she says that he loves
--2 Imperatives
-- An imperative is straightforwardly formed from a verb phrase.
-- It has variation over positive and negative, singular and plural.
-- To fix these parameters, see [Phrase Phrase.html].
ImpVP : VP -> Imp ; -- love yourselves
--2 Embedded sentences
-- Sentences, questions, and infinitival phrases can be used as
-- subjects and (adverbial) complements.
EmbedS : S -> SC ; -- that she goes
EmbedQS : QS -> SC ; -- who goes
EmbedVP : VP -> SC ; -- to go
--2 Sentences
-- These are the 2 x 4 x 4 = 16 forms generated by different
-- combinations of tense, polarity, and
-- anteriority, which are defined in [``Common`` Common.html].
fun
UseCl : Temp -> Pol -> Cl -> S ;
UseQCl : Temp -> Pol -> QCl -> QS ;
UseRCl : Temp -> Pol -> RCl -> RS ;
UseSlash : Temp -> Pol -> ClSlash -> SSlash ;
-- An adverb can be added to the beginning of a sentence.
AdvS : Adv -> S -> S ; -- today, I will go home
-- A sentence can be modified by a relative clause referring to its contents.
RelS : S -> RS -> S ; -- she sleeps, which is good
---- A sentence can also be post-modified by a subjunct sentence.
---- ModSubjS : S -> Subj -> S -> S ; -- she sleeps, because she is old
---- cf. Adverb.SubjS
}
--.
-- Examples for English $S$/$Cl$:
{-
Pres Simul Pos ODir : he sleeps
Pres Simul Neg ODir : he doesn't sleep
Pres Anter Pos ODir : he has slept
Pres Anter Neg ODir : he hasn't slept
Past Simul Pos ODir : he slept
Past Simul Neg ODir : he didn't sleep
Past Anter Pos ODir : he had slept
Past Anter Neg ODir : he hadn't slept
Fut Simul Pos ODir : he will sleep
Fut Simul Neg ODir : he won't sleep
Fut Anter Pos ODir : he will have slept
Fut Anter Neg ODir : he won't have slept
Cond Simul Pos ODir : he would sleep
Cond Simul Neg ODir : he wouldn't sleep
Cond Anter Pos ODir : he would have slept
Cond Anter Neg ODir : he wouldn't have slept
-}

View File

@@ -0,0 +1,123 @@
--1 Structural: Structural Words
--
-- Here we have some words belonging to closed classes and appearing
-- in all languages we have considered.
-- Sometimes more distinctions are needed, e.g. $we_Pron$ in Spanish
-- should be replaced by masculine and feminine variants, found in
-- [``ExtraSpa`` ../spanish/ExtraSpa.gf].
abstract Structural = Cat ** {
fun
-- This is an alphabetical list of structural words
above_Prep : Prep ;
after_Prep : Prep ;
all_Predet : Predet ;
almost_AdA : AdA ;
almost_AdN : AdN ;
although_Subj : Subj ;
always_AdV : AdV ;
and_Conj : Conj ;
because_Subj : Subj ;
before_Prep : Prep ;
behind_Prep : Prep ;
between_Prep : Prep ;
both7and_DConj : Conj ; -- both...and
---b both7and_DConj : DConj ;
but_PConj : PConj ;
by8agent_Prep : Prep ; -- by (agent)
by8means_Prep : Prep ; -- by (means of)
can8know_VV : VV ; -- can (capacity)
can_VV : VV ; -- can (possibility)
during_Prep : Prep ;
either7or_DConj : Conj ; -- either...or
---b either7or_DConj : DConj ;
every_Det : Det ;
everybody_NP : NP ; -- everybody
everything_NP : NP ;
everywhere_Adv : Adv ;
--- first_Ord : Ord ; DEPRECATED
few_Det : Det ;
for_Prep : Prep ;
from_Prep : Prep ;
he_Pron : Pron ;
here_Adv : Adv ;
here7to_Adv : Adv ; -- to here
here7from_Adv : Adv ; -- from here
how_IAdv : IAdv ;
how8many_IDet : IDet ;
i_Pron : Pron ;
if_Subj : Subj ;
in8front_Prep : Prep ; -- in front of
in_Prep : Prep ;
it_Pron : Pron ;
less_CAdv : CAdv ;
many_Det : Det ;
more_CAdv : CAdv ;
most_Predet : Predet ;
much_Det : Det ;
must_VV : VV ;
---b no_Phr : Phr ;
no_Utt : Utt ;
on_Prep : Prep ;
--- one_Quant : QuantSg ; DEPRECATED
only_Predet : Predet ;
or_Conj : Conj ;
otherwise_PConj : PConj ;
part_Prep : Prep ;
please_Voc : Voc ;
possess_Prep : Prep ; -- of (possessive)
quite_Adv : AdA ;
she_Pron : Pron ;
so_AdA : AdA ;
someSg_Det : Det ;
somePl_Det : Det ;
somebody_NP : NP ;
something_NP : NP ;
somewhere_Adv : Adv ;
that_Quant : Quant ;
there_Adv : Adv ;
there7to_Adv : Adv ; -- to there
there7from_Adv : Adv ; -- from there
therefore_PConj : PConj ;
they_Pron : Pron ;
this_Quant : Quant ;
through_Prep : Prep ;
to_Prep : Prep ;
too_AdA : AdA ;
under_Prep : Prep ;
very_AdA : AdA ;
want_VV : VV ;
we_Pron : Pron ;
whatPl_IP : IP ; -- what (plural)
whatSg_IP : IP ; -- what (singular)
when_IAdv : IAdv ;
when_Subj : Subj ;
where_IAdv : IAdv ;
which_IQuant : IQuant ;
whoPl_IP : IP ; -- who (plural)
whoSg_IP : IP ; -- who (singular)
why_IAdv : IAdv ;
with_Prep : Prep ;
without_Prep : Prep ;
---b yes_Phr : Phr ;
yes_Utt : Utt ;
youSg_Pron : Pron ; -- you (singular)
youPl_Pron : Pron ; -- you (plural)
youPol_Pron : Pron ; -- you (polite)
no_Quant : Quant ;
not_Predet : Predet ;
if_then_Conj : Conj ;
at_least_AdN : AdN ;
at_most_AdN : AdN ;
nobody_NP : NP ;
nothing_NP : NP ;
except_Prep : Prep ;
as_CAdv : CAdv ;
have_V2 : V2 ;
}

View File

@@ -0,0 +1,46 @@
--1 Symbolic expressions
-- *Note*. This module is not automatically included in the main
-- grammar [Lang Lang.html].
abstract Symbol = Cat, PredefAbs ** {
--2 Noun phrases with symbols and numbers
fun
SymbPN : Symb -> PN ; -- x
IntPN : Int -> PN ; -- 27
FloatPN : Float -> PN ; -- 3.14159
NumPN : Card -> PN ;
CNNumNP : CN -> Card -> NP ; -- level five ; level 5
CNSymbNP : Det -> CN -> [Symb] -> NP ; -- (the) (2) numbers x and y
--2 Sentence consisting of a formula
SymbS : Symb -> S ; -- A
--2 Symbols as numerals
SymbNum : Symb -> Card ; -- n
SymbOrd : Symb -> Ord ; -- n'th
--2 Symbol lists
-- A symbol list has at least two elements. The last two are separated
-- by a conjunction ("and" in English), the others by commas.
-- This produces "x, y and z", in English.
cat
Symb ;
[Symb]{2} ;
fun
MkSymb : String -> Symb ;
--2 Obsolescent
CNIntNP : CN -> Int -> NP ; -- level 53 (covered by CNNumNP)
}

15
lib/src/abstract/Text.gf Normal file
View File

@@ -0,0 +1,15 @@
--1 Text: Texts
-- Texts are built from an empty text by adding $Phr$ases,
-- using as constructors the punctuation marks ".", "?", and "!".
-- Any punctuation mark can be attached to any kind of phrase.
abstract Text = Common ** {
fun
TEmpty : Text ; --
TFullStop : Phr -> Text -> Text ; -- John walks. ...
TQuestMark : Phr -> Text -> Text ; -- Are they here? ...
TExclMark : Phr -> Text -> Text ; -- Let's go! ...
}

71
lib/src/abstract/Verb.gf Normal file
View File

@@ -0,0 +1,71 @@
--1 The construction of verb phrases
abstract Verb = Cat ** {
--2 Complementization rules
-- Verb phrases are constructed from verbs by providing their
-- complements. There is one rule for each verb category.
fun
UseV : V -> VP ; -- sleep
ComplVV : VV -> VP -> VP ; -- want to run
ComplVS : VS -> S -> VP ; -- say that she runs
ComplVQ : VQ -> QS -> VP ; -- wonder who runs
ComplVA : VA -> AP -> VP ; -- they become red
SlashV2a : V2 -> VPSlash ; -- love (it)
Slash2V3 : V3 -> NP -> VPSlash ; -- give it (to her)
Slash3V3 : V3 -> NP -> VPSlash ; -- give (it) to her
SlashV2V : V2V -> VP -> VPSlash ; -- beg (her) to go
SlashV2S : V2S -> S -> VPSlash ; -- answer (to him) that it is good
SlashV2Q : V2Q -> QS -> VPSlash ; -- ask (him) who came
SlashV2A : V2A -> AP -> VPSlash ; -- paint (it) red
ComplSlash : VPSlash -> NP -> VP ; -- love it
SlashVV : VV -> VPSlash -> VPSlash ; -- want to buy
SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy
--2 Other ways of forming verb phrases
-- Verb phrases can also be constructed reflexively and from
-- copula-preceded complements.
ReflVP : VPSlash -> VP ; -- love himself
UseComp : Comp -> VP ; -- be warm
-- Passivization of two-place verbs is another way to use
-- them. In many languages, the result is a participle that
-- is used as complement to a copula ("is used"), but other
-- auxiliary verbs are possible (Ger. "wird angewendet", It.
-- "viene usato"), as well as special verb forms (Fin. "käytetään",
-- Swe. "används").
--
-- *Note*. the rule can be overgenerating, since the $V2$ need not
-- take a direct object.
PassV2 : V2 -> VP ; -- be loved
-- Adverbs can be added to verb phrases. Many languages make
-- a distinction between adverbs that are attached in the end
-- vs. next to (or before) the verb.
AdvVP : VP -> Adv -> VP ; -- sleep here
AdVVP : AdV -> VP -> VP ; -- always sleep
-- *Agents of passives* are constructed as adverbs with the
-- preposition [Structural Structural.html]$.8agent_Prep$.
--2 Complements to copula
-- Adjectival phrases, noun phrases, and adverbs can be used.
CompAP : AP -> Comp ; -- (be) small
CompNP : NP -> Comp ; -- (be) a man
CompAdv : Adv -> Comp ; -- (be) here
}

187
lib/src/api/Combinators.gf Normal file
View File

@@ -0,0 +1,187 @@
--1 Combinators: a High-Level Syntax API
-- This module defines some "grammatical functions" that give shortcuts to
-- typical constructions. [``Constructors`` Constructors.html] and the
-- language-specific ``Paradigms`` modules are usually needed
-- to construct arguments of these functions.
incomplete resource Combinators = open Cat, Structural, Constructors in {
oper
--2 Predication
pred : overload {
pred : V -> NP -> Cl ; -- x converges
pred : V2 -> NP -> NP -> Cl ; -- x intersects y
pred : V3 -> NP -> NP -> NP -> Cl ; -- x intersects y at z
pred : V -> NP -> NP -> Cl ; -- x and y intersect
pred : A -> NP -> Cl ; -- x is even
pred : A2 -> NP -> NP -> Cl ; -- x is divisible by y
pred : A -> NP -> NP -> Cl ; -- x and y are equal
pred : N -> NP -> Cl ; -- x is a maximum
pred : CN -> NP -> Cl ; -- x is a local maximum
pred : NP -> NP -> Cl ; -- x is the neutral element
pred : N -> NP -> NP -> Cl ; -- x and y are inverses
pred : Adv -> NP -> Cl ; -- x is in scope
pred : Prep -> NP -> NP -> Cl -- x is outside y
} ;
--2 Function application
app : overload {
app : N -> NP ;
app : N2 -> NP -> NP ;
app : N3 -> NP -> NP -> NP ;
app : N2 -> NP -> NP -> NP ;
app : N2 -> N -> CN ;
app : N2 -> NP -> CN ; -- divisor of x
app : N3 -> NP -> NP -> CN ; -- path from x to y
app : N2 -> NP -> NP -> CN ; -- path between x and y
} ;
--2 Coordination
coord : overload {
coord : Conj -> Adv -> Adv -> Adv ;
coord : Conj -> AP -> AP -> AP ;
coord : Conj -> NP -> NP -> NP ;
coord : Conj -> S -> S -> S ;
coord : Conj -> ListAdv -> Adv ;
coord : Conj -> ListAP -> AP ;
coord : Conj -> ListNP -> NP ;
coord : Conj -> ListS -> S ;
} ;
--2 Modification
mod : overload {
mod : A -> N -> CN ;
mod : AP -> CN -> CN ;
mod : AdA -> A -> AP ;
mod : Det -> N -> NP ;
mod : Det -> CN -> NP ;
mod : Quant -> N -> NP ;
mod : Quant -> CN -> NP ;
mod : Predet -> N -> NP ;
mod : Numeral -> N -> NP
} ;
--2 Negation
neg : overload {
neg : Imp -> Utt ;
neg : Cl -> S ;
neg : QCl -> QS ;
neg : RCl -> RS
};
--.
pred = overload {
pred : V -> NP -> Cl
= \v,np -> mkCl np v ;
pred : V2 -> NP -> NP -> Cl
= \v,np,ob -> mkCl np v ob ;
pred : V3 -> NP -> NP -> NP -> Cl
= \v,np,ob,ob2 -> mkCl np v ob ob2 ;
pred : V -> NP -> NP -> Cl --# notminimal
= \v,x,y -> mkCl (mkNP and_Conj x y) v ; --# notminimal
pred : A -> NP -> Cl
= \a,np -> mkCl np a ;
pred : A2 -> NP -> NP -> Cl --# notminimal
= \a,x,y -> mkCl x a y ; --# notminimal
pred : A -> NP -> NP -> Cl --# notminimal
= \a,x,y -> mkCl (mkNP and_Conj x y) a ; --# notminimal
pred : N -> NP -> Cl
= \n,x -> mkCl x (mkNP a_Art n) ;
pred : CN -> NP -> Cl
= \n,x -> mkCl x (mkNP a_Art n) ;
pred : NP -> NP -> Cl
= \n,x -> mkCl x n ;
pred : N2 -> NP -> NP -> Cl --# notminimal
= \n,x,y -> mkCl x (mkNP a_Art (mkCN n y)) ; --# notminimal
pred : N -> NP -> NP -> Cl --# notminimal
= \n,x,y -> mkCl (mkNP and_Conj x y) (mkNP a_Art plNum n) ; --# notminimal
pred : Adv -> NP -> Cl
= \a,x -> mkCl x a ;
pred : Prep -> NP -> NP -> Cl
= \p,x,y -> mkCl x (mkAdv p y) ;
} ;
app = overload {
app : N -> NP
= \n -> mkNP the_Art n ;
app : N2 -> NP -> NP --# notminimal
= \n,x -> mkNP the_Art (mkCN n x) ; --# notminimal
app : N3 -> NP -> NP -> NP --# notminimal
= \n,x,y -> mkNP the_Art (mkCN n x y) ; --# notminimal
app : N2 -> NP -> NP -> NP --# notminimal
= \n,x,y -> mkNP the_Art (mkCN n (mkNP and_Conj x y)) ; --# notminimal
app : N2 -> N -> CN --# notminimal
= \f,n -> mkCN f (mkNP a_Art plNum n) ; --# notminimal
app : N2 -> NP -> CN --# notminimal
= mkCN ; --# notminimal
app : N3 -> NP -> NP -> CN --# notminimal
= mkCN ; --# notminimal
app : N2 -> NP -> NP -> CN --# notminimal
= \n,x,y -> mkCN n (mkNP and_Conj x y) ; --# notminimal
} ;
coord = overload { --# notminimal
coord : Conj -> Adv -> Adv -> Adv --# notminimal
= mkAdv ; --# notminimal
coord : Conj -> AP -> AP -> AP --# notminimal
= mkAP ; --# notminimal
coord : Conj -> NP -> NP -> NP --# notminimal
= mkNP ; --# notminimal
coord : Conj -> S -> S -> S --# notminimal
= mkS ; --# notminimal
coord : Conj -> ListAdv -> Adv --# notminimal
= mkAdv ; --# notminimal
coord : Conj -> ListAP -> AP --# notminimal
= mkAP ; --# notminimal
coord : Conj -> ListNP -> NP --# notminimal
= mkNP ; --# notminimal
coord : Conj -> ListS -> S --# notminimal
= mkS ; --# notminimal
} ; --# notminimal
mod = overload {
mod : A -> N -> CN
= mkCN ;
mod : AP -> CN -> CN
= mkCN ;
mod : AdA -> A -> AP
= mkAP ;
mod : Det -> N -> NP
= mkNP ;
mod : Det -> CN -> NP
= mkNP ;
mod : Quant -> N -> NP
= mkNP ;
mod : Quant -> CN -> NP
= mkNP ;
mod : Predet -> N -> NP
= \p,n -> mkNP p (mkNP a_Art n) ;
mod : Numeral -> N -> NP
= mkNP ;
} ;
neg = overload {
neg : Imp -> Utt
= mkUtt negativePol ;
neg : Cl -> S
= mkS negativePol ;
neg : QCl -> QS
= mkQS negativePol ;
neg : RCl -> RS --# notminimal
= mkRS negativePol ; --# notminimal
};
}

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsAra = Combinators with
(Cat = CatAra),
(Structural = StructuralAra),
(Constructors = ConstructorsAra) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsBul = Combinators with
(Cat = CatBul),
(Structural = StructuralBul),
(Constructors = ConstructorsBul) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses
resource CombinatorsCat = Combinators with
(Cat = CatCat),
(Structural = StructuralCat),
(Constructors = ConstructorsCat) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsDan = Combinators with
(Cat = CatDan),
(Structural = StructuralDan),
(Constructors = ConstructorsDan) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsEng = Combinators with
(Cat = CatEng),
(Structural = StructuralEng),
(Constructors = ConstructorsEng) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsFin = Combinators with
(Cat = CatFin),
(Structural = StructuralFin),
(Constructors = ConstructorsFin) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsFre = Combinators with
(Cat = CatFre),
(Structural = StructuralFre),
(Constructors = ConstructorsFre) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsGer = Combinators with
(Cat = CatGer),
(Structural = StructuralGer),
(Constructors = ConstructorsGer) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsHin = Combinators with
(Cat = CatHin),
(Structural = StructuralHin),
(Constructors = ConstructorsHin) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsIna = Combinators with
(Cat = CatIna),
(Structural = StructuralIna),
(Constructors = ConstructorsIna) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsIta = Combinators with
(Cat = CatIta),
(Structural = StructuralIta),
(Constructors = ConstructorsIta) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsNor = Combinators with
(Cat = CatNor),
(Structural = StructuralNor),
(Constructors = ConstructorsNor) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsRus = Combinators with
(Cat = CatRus),
(Structural = StructuralRus),
(Constructors = ConstructorsRus) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses
resource CombinatorsSpa = Combinators with
(Cat = CatSpa),
(Structural = StructuralSpa),
(Constructors = ConstructorsSpa) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsSwe = Combinators with
(Cat = CatSwe),
(Structural = StructuralSwe),
(Constructors = ConstructorsSwe) ;

View File

@@ -0,0 +1,6 @@
--# -path=.:alltenses:prelude
resource CombinatorsTha = Combinators with
(Cat = CatTha),
(Structural = StructuralTha),
(Constructors = ConstructorsTha) ;

1745
lib/src/api/Constructors.gf Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsAra = Constructors with (Grammar = GrammarAra) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsBul = Constructors with (Grammar = GrammarBul) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses
resource ConstructorsCat = Constructors with (Grammar = GrammarCat) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsDan = Constructors with (Grammar = GrammarDan) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsEng = Constructors with (Grammar = GrammarEng) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsFin = Constructors with (Grammar = GrammarFin) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsFre = Constructors with (Grammar = GrammarFre) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsGer = Constructors with (Grammar = GrammarGer) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsIta = Constructors with (Grammar = GrammarIta) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsNor = Constructors with (Grammar = GrammarNor) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsRus = Constructors with (Grammar = GrammarRus) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsSpa = Constructors with (Grammar = GrammarSpa) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsSwe = Constructors with (Grammar = GrammarSwe) ;

86
lib/src/api/Symbolic.gf Normal file
View File

@@ -0,0 +1,86 @@
--1 Symbolic: Noun Phrases with mathematical symbols
incomplete resource Symbolic = open Symbol, Grammar, PredefCnc in {
oper
symb : overload {
symb : Str -> NP ; -- x
symb : Int -> NP ; -- 23
symb : Float -> NP ; -- 0.99
symb : N -> Digits -> NP ; -- level 4
symb : N -> Card -> NP ; -- level at least four
symb : CN -> Card -> NP ; -- advanced level at least four
symb : Det -> N -> Card -> NP ; -- the number at least four
symb : Det -> CN -> Card -> NP ; -- the even number at least four
symb : N -> Numeral -> NP ; -- level four
symb : CN -> Numeral -> NP ; -- advanced level four
symb : Det -> N -> Numeral -> NP ; -- the largest number four
symb : Det -> CN -> Numeral -> NP ; -- the largest even number four
symb : Det -> N -> Str -> Str -> NP ; -- the largest levels i and j
symb : Det -> CN -> [Symb] -> NP ; -- the largest basic levels i, j, and k
symb : Quant -> N -> Numeral -> NP ; -- the number four
symb : Quant -> CN -> Numeral -> NP ; -- the even number four
symb : Quant -> N -> Str -> Str -> NP ; -- the levels i and j
symb : Quant -> CN -> [Symb] -> NP ; -- the basic levels i, j, and k
symb : Symb -> S ; -- A
symb : Symb -> Card ; -- n
symb : Symb -> Ord -- n'th
} ;
mkSymb : Str -> Symb ;
mkInteger : Predef.Int -> Integer ;
mkFloating : Predef.Float -> Floating ;
--.
symb = overload {
symb : Str -> NP
= \s -> UsePN (SymbPN (mkSymb s)) ;
symb : Int -> NP
= \i -> UsePN (IntPN i) ;
symb : Float -> NP
= \i -> UsePN (FloatPN i) ;
symb : N -> Digits -> NP
= \c,i -> CNNumNP (UseN c) (NumDigits i) ;
symb : N -> Card -> NP
= \c,n -> CNNumNP (UseN c) n ;
symb : CN -> Card -> NP
= \c,n -> CNNumNP c n ;
symb : Det -> N -> Card -> NP
= \d,n,x -> DetCN d (ApposCN (UseN n) (UsePN (NumPN x))) ;
symb : Det -> CN -> Card -> NP
= \d,n,x -> DetCN d (ApposCN n (UsePN (NumPN x))) ;
symb : N -> Numeral -> NP
= \c,n -> CNNumNP (UseN c) (NumNumeral n) ;
symb : CN -> Numeral -> NP
= \c,n -> CNNumNP c (NumNumeral n) ;
symb : Det -> N -> Numeral -> NP
= \d,n,x -> DetCN d (ApposCN (UseN n) (UsePN (NumPN (NumNumeral x)))) ;
symb : Det -> CN -> Numeral -> NP
= \d,n,x -> DetCN d (ApposCN n (UsePN (NumPN (NumNumeral x)))) ;
symb : Det -> N -> Str -> Str -> NP
= \c,n,x,y -> CNSymbNP c (UseN n) (BaseSymb (mkSymb x) (mkSymb y)) ;
symb : Det -> CN -> [Symb] -> NP
= CNSymbNP ;
symb : Quant -> N -> Numeral -> NP
= \d,n,x -> DetCN (DetQuant d NumSg) (ApposCN (UseN n) (UsePN (NumPN (NumNumeral x)))) ;
symb : Quant -> CN -> Numeral -> NP
= \d,n,x -> DetCN (DetQuant d NumSg) (ApposCN n (UsePN (NumPN (NumNumeral x)))) ;
symb : Quant -> N -> Str -> Str -> NP
= \d,n,x,y -> CNSymbNP (DetQuant d NumSg) (UseN n) (BaseSymb (mkSymb x) (mkSymb y)) ;
symb : Quant -> CN -> [Symb] -> NP
= \d -> CNSymbNP (DetQuant d NumSg);
symb : Symb -> S = SymbS ;
symb : Symb -> Card = SymbNum ;
symb : Symb -> Ord = SymbOrd
} ;
mkSymb : Str -> Symb = \s -> {s = s ; lock_Symb = <>} ;
mkInteger i = {s = Predef.show Predef.Int i ; lock_Int = <>} ;
mkFloating f = {s = Predef.show Predef.Float f ; lock_Float = <>} ;
Integer : Type = {s : Str ; lock_Int : {}} ;
Floating : Type = {s : Str ; lock_Float : {}} ;
}

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicBul = Symbolic with
(Symbol = SymbolBul),
(Grammar = GrammarBul) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:prelude
resource SymbolicCat = Symbolic with
(Symbol = SymbolCat),
(Grammar = GrammarCat) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicDan = Symbolic with
(Symbol = SymbolDan),
(Grammar = GrammarDan) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicEng = Symbolic with
(Symbol = SymbolEng),
(Grammar = GrammarEng) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicFin = Symbolic with
(Symbol = SymbolFin),
(Grammar = GrammarFin) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicFre = Symbolic with
(Symbol = SymbolFre),
(Grammar = GrammarFre) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicGer = Symbolic with
(Symbol = SymbolGer),
(Grammar = GrammarGer) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicIta = Symbolic with
(Symbol = SymbolIta),
(Grammar = GrammarIta) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicNor = Symbolic with
(Symbol = SymbolNor),
(Grammar = GrammarNor) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:prelude
resource SymbolicSpa = Symbolic with
(Symbol = SymbolSpa),
(Grammar = GrammarSpa) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicSwe = Symbolic with
(Symbol = SymbolSwe),
(Grammar = GrammarSwe) ;

4
lib/src/api/Syntax.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
interface Syntax = Constructors, Cat, Structural, Combinators ;

4
lib/src/api/SyntaxAra.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxAra of Syntax = ConstructorsAra, CatAra, StructuralAra, CombinatorsAra ;

4
lib/src/api/SyntaxBul.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxBul of Syntax = ConstructorsBul, CatBul, StructuralBul, CombinatorsBul ;

5
lib/src/api/SyntaxCat.gf Normal file
View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses
instance SyntaxCat of Syntax =
ConstructorsCat, CatCat, StructuralCat, CombinatorsCat ;

4
lib/src/api/SyntaxDan.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxDan of Syntax = ConstructorsDan, CatDan, StructuralDan, CombinatorsDan ;

5
lib/src/api/SyntaxEng.gf Normal file
View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxEng of Syntax =
ConstructorsEng, CatEng, StructuralEng, CombinatorsEng ;

4
lib/src/api/SyntaxFin.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxFin of Syntax = ConstructorsFin, CatFin, StructuralFin, CombinatorsFin ;

4
lib/src/api/SyntaxFre.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxFre of Syntax = ConstructorsFre, CatFre, StructuralFre, CombinatorsFre ;

4
lib/src/api/SyntaxGer.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxGer of Syntax = ConstructorsGer, CatGer, StructuralGer, CombinatorsGer ;

4
lib/src/api/SyntaxIta.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxIta of Syntax = ConstructorsIta, CatIta, StructuralIta, CombinatorsIta ;

5
lib/src/api/SyntaxNor.gf Normal file
View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxNor of Syntax = ConstructorsNor, CatNor, StructuralNor, CombinatorsNor
;

4
lib/src/api/SyntaxRus.gf Normal file
View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxRus of Syntax = ConstructorsRus, CatRus, StructuralRus, CombinatorsRus ;

5
lib/src/api/SyntaxSpa.gf Normal file
View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses
instance SyntaxSpa of Syntax =
ConstructorsSpa, CatSpa, StructuralSpa, CombinatorsSpa ;

5
lib/src/api/SyntaxSwe.gf Normal file
View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxSwe of Syntax =
ConstructorsSwe, CatSwe, StructuralSwe, CombinatorsSwe ;

13
lib/src/api/TryBul.gf Normal file
View File

@@ -0,0 +1,13 @@
--# -path=.:alltenses:prelude
resource TryBul = SyntaxBul, LexiconBul, ParadigmsBul - [mkAdv] **
open (P = ParadigmsBul) in {
oper
mkAdv = overload SyntaxBul {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
}

13
lib/src/api/TryCat.gf Normal file
View File

@@ -0,0 +1,13 @@
--# -path=.:alltenses:prelude
resource TryCat = SyntaxCat, LexiconCat, ParadigmsCat - [mkAdv] **
open (P = ParadigmsCat) in {
oper
mkAdv = overload SyntaxCat {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
}

3
lib/src/api/TryDan.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryDan = SyntaxDan, LexiconDan, ParadigmsDan - [mkAdv] ;

22
lib/src/api/TryEng.gf Normal file
View File

@@ -0,0 +1,22 @@
--# -path=.:alltenses:prelude
resource TryEng = SyntaxEng-[mkAdN], LexiconEng, ParadigmsEng - [mkAdv,mkAdN,mkOrd] **
open (P = ParadigmsEng) in {
oper
mkAdv = overload SyntaxEng {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
mkAdN = overload {
mkAdN : CAdv -> AdN = SyntaxEng.mkAdN ;
mkAdN : Str -> AdN = P.mkAdN ;
} ;
mkOrd = overload SyntaxEng {
mkOrd : Str -> Ord = P.mkOrd ;
} ;
}

3
lib/src/api/TryFin.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryFin = SyntaxFin, LexiconFin-[mkOrd], ParadigmsFin - [mkAdv] ;

3
lib/src/api/TryFre.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryFre = SyntaxFre, LexiconFre, ParadigmsFre - [mkAdv] ;

3
lib/src/api/TryGer.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryGer = SyntaxGer, LexiconGer, ParadigmsGer - [mkAdv] ;

3
lib/src/api/TryIta.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryIta = SyntaxIta, LexiconIta, ParadigmsIta - [mkAdv,in_Prep] ;

3
lib/src/api/TryNor.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryNor = SyntaxNor, LexiconNor, ParadigmsNor - [mkAdv] ;

3
lib/src/api/TryRus.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TryRus = SyntaxRus, LexiconRus, ParadigmsRus - [mkAdv] ;

3
lib/src/api/TrySpa.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource TrySpa = SyntaxSpa, LexiconSpa, ParadigmsSpa - [mkAdv] ;

12
lib/src/api/TrySwe.gf Normal file
View File

@@ -0,0 +1,12 @@
--# -path=.:alltenses:prelude
resource TrySwe = SyntaxSwe, LexiconSwe, ParadigmsSwe - [mkAdv] **
open (P = ParadigmsSwe) in {
oper
mkAdv = overload SyntaxSwe {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
}

76
lib/src/api/minimals.txt Normal file
View File

@@ -0,0 +1,76 @@
ASimul
AdAP
AdjCN
AdvVP
CompAP
CompAdv
CompNP
ComparA
ComplSlash
DefArt
DetCN
DetQuant
Grammar
IdetCN
IdetQuant
ImpVP
IndefArt
MassNP
NoPConj
NoVoc
NumCard
NumNumeral
NumPl
NumSg
PNeg
PPos
PhrUtt
PositA
PositAdvAdj
PredVP
PredetNP
PrepNP
QuestCl
QuestIAdv
QuestVP
Slash3V3
SlashV2A
SlashV2a
TEmpty
TExclMark
TFullStop
TPres
TQuestMark
TTAnt
UseCl
UseComp
UseN
UsePN
UsePron
UseQCl
UseV
UttAdv
UttIAdv
UttIP
UttImpSg
UttNP
UttQS
UttS
n2
n3
n4
n5
n6
n7
n8
n9
plNum
pot0
pot01
pot0as1
pot1
pot110
pot1as2
pot2
pot2as3
pot3

View File

@@ -0,0 +1,43 @@
concrete AdjectiveAra of Adjective = CatAra ** open ResAra, Prelude in {
lin
PositA a = {
s = \\h,g,n,d,c => case h of {
Hum => a.s ! APosit g n d c;
NoHum => case n of {
Pl => a.s ! APosit Fem Sg d c ;
_ => a.s ! APosit g n d c
}
}
};
---- guessed by AR
ComparA a np = {
s = \\sp,g,n,st,c => a.s ! AComp st c ++ "مِنْ" ++ np.s ! Gen ;
} ;
--
-- $SuperlA$ belongs to determiner syntax in $Noun$.
--
-- ComplA2 a np = {
-- s = \\_ => a.s ! AAdj Posit ++ a.c2 ++ np.s ! Acc ;
-- isPre = False
-- } ;
--
-- ReflA2 a = {
-- s = \\ag => a.s ! AAdj Posit ++ a.c2 ++ reflPron ! ag ;
-- isPre = False
-- } ;
--
-- SentAP ap sc = {
-- s = \\a => ap.s ! a ++ sc.s ;
-- isPre = False
-- } ;
--
AdAP ada ap = {
s = \\sp,g,n,st,c => ada.s ++ ap.s ! sp ! g ! n ! st ! c
} ;
--
-- UseA2 a = a ;
--
}

View File

@@ -0,0 +1,21 @@
concrete AdverbAra of Adverb = CatAra ** open ResAra, Prelude in {
lin
PositAdvAdj a = {s = a.s ! APosit Masc Sg Indef Acc} ;
-- ComparAdvAdj cadv a np = {
-- s = cadv.s ++ a.s ! AAdv ++ "مِنْ" ++ np.s ! Gen
-- } ;
-- ComparAdvAdjS cadv a s = {
-- s = cadv.s ++ a.s ! AAdv ++ "تهَن" ++ s.s
-- } ;
PrepNP prep np = {s = prep.s ++ np.s ! Gen} ;
-- AdAdv = cc2 ;
--
-- SubjS = cc2 ;
-- AdvSC s = s ; --- this rule give stack overflow in ordinary parsing
--
-- AdnCAdv cadv = {s = cadv.s ++ "تهَن"} ;
--
}

3
lib/src/arabic/AllAra.gf Normal file
View File

@@ -0,0 +1,3 @@
--# -path=.:../abstract:../common:prelude
concrete AllAra of AllAraAbs = LangAra ;

View File

@@ -0,0 +1,3 @@
--# -path=.:../abstract:../common:prelude
abstract AllAraAbs = Lang ;

103
lib/src/arabic/CatAra.gf Normal file
View File

@@ -0,0 +1,103 @@
concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
flags optimize=all_subs ;
lincat
-- Phrase
Utt = {s : Gender => Str};
-- Tensed/Untensed
S = {s : Str} ;
QS = {s : QForm => Str} ;
-- RS = {s : Agr => Str} ;
-- Sentence
Cl = {s : ResAra.Tense => Polarity => Order => Str} ;
-- Slash = {s : Tense => Anteriority => Polarity => Order => Str} ** {c2 : Str} ;
Imp = {s : Polarity => Gender => ResAra.Number => Str} ;
-- Question
QCl = {s : ResAra.Tense => Polarity => QForm => Str} ;
IP = {s : Str ; n : ResAra.Number} ;
-- IAdv = {s : Str} ;
IDet = {s : Case => Str ; n : ResAra.Number} ; ---- AR add Case
--
---- Relative
--
-- RCl = {s : Tense => Anteriority => Polarity => Agr => Str} ;
-- RP = {s : Case => Str ; a : RAgr} ;
--
-- Verb
VP = ResAra.VP ;
VPSlash = ResAra.VP ** {c2 : Str} ;
Comp = ResAra.Comp ; --{s : AAgr => Case => Str} ;
-- SC = {s : Str} ;
--
-- Adjective
AP = {s : Species => Gender => NTable } ;
-- Noun
CN = ResAra.Noun ** {adj : NTable};
NP, Pron = ResAra.NP; --{s : Case => Str ; a : Agr } ;
Num, Ord, Card = {s : Gender => State => Case => Str ;
n : Size };
Predet = ResAra.Predet ;
-- DEPRECATED
-- QuantSg, QuantPl =
-- {s : Species => Gender => Case => Str;
-- n : ResAra.Number;
-- d : State;
-- isNum : Bool;
-- isPron : Bool} ;
Det = ResAra.Det ;
-- {s : Species => Gender => Case => Str ;
-- d : State; n : Size; isNum : Bool } ;
Quant = {s : ResAra.Number => Species => Gender => Case => Str;
d : State;
isNum : Bool;
isPron: Bool} ;
Art = {s : ResAra.Number => Species => Gender => Case => Str;
d : State} ;
-- Numeral
Numeral = {s : CardOrd => Gender => State => Case => Str ;
n : Size } ;
Digits = {s : Str;
n : Size};
-- Structural
Conj = {s : Str ; n : ResAra.Number} ;
-- DConj = {s1,s2 : Str ; n : ResAra.Number} ;
-- Subj = {s : Str} ;
Prep = {s : Str} ;
-- Open lexical classes, e.g. Lexicon
V, VS, VQ, VA = ResAra.Verb ; -- = {s : VForm => Str} ;
V2, V2A = ResAra.Verb ** {c2 : Str} ;
V2V, V2S, V2Q = ResAra.Verb ** {c2 : Str} ; --- AR
V3 = ResAra.Verb ** {c2, c3 : Str} ;
-- VV = {s : VVForm => Str ; isAux : Bool} ;
A = ResAra.Adj ;
A2 = ResAra.Adj ** {c2 : Str} ;
N, N2 = ResAra.Noun ;
--{s : ResAra.Number => State => Case => Str; g : Gender ; h = Species} ;
-- N2 = {s : ResAra.Number => Case => Str} ** {c2 : Str} ;??
N3 = ResAra.Noun ** {c2,c3 : Str} ;
PN = {s : Case => Str; g : Gender; h : Species} ;
}

View File

@@ -0,0 +1,45 @@
concrete ConjunctionAra of Conjunction =
CatAra ** open ResAra, Coordination, Prelude in {
--
-- flags optimize=all_subs ;
--
-- lin
--
-- ConjS = conjunctSS ;
-- DConjS = conjunctDistrSS ;
--
-- ConjAdv = conjunctSS ;
-- DConjAdv = conjunctDistrSS ;
--
-- ConjNP conj ss = conjunctTable Case conj ss ** {
-- a = {n = conjNumber conj.n ss.a.n ; p = ss.a.p}
-- } ;
-- DConjNP conj ss = conjunctDistrTable Case conj ss ** {
-- a = {n = conjNumber conj.n ss.a.n ; p = ss.a.p}
-- } ;
--
-- ConjAP conj ss = conjunctTable Agr conj ss ** {
-- isPre = ss.isPre
-- } ;
-- DConjAP conj ss = conjunctDistrTable Agr conj ss ** {
-- isPre = ss.isPre
-- } ;
--
---- These fun's are generated from the list cat's.
--
-- BaseS = twoSS ;
-- ConsS = consrSS comma ;
-- BaseAdv = twoSS ;
-- ConsAdv = consrSS comma ;
-- BaseNP x y = twoTable Case x y ** {a = conjAgr x.a y.a} ;
-- ConsNP xs x = consrTable Case comma xs x ** {a = conjAgr xs.a x.a} ;
-- BaseAP x y = twoTable Agr x y ** {isPre = andB x.isPre y.isPre} ;
-- ConsAP xs x = consrTable Agr comma xs x ** {isPre = andB xs.isPre x.isPre} ;
--
-- lincat
-- [S] = {s1,s2 : Str} ;
-- [Adv] = {s1,s2 : Str} ;
-- [NP] = {s1,s2 : Case => Str ; a : Agr} ;
-- [AP] = {s1,s2 : Agr => Str ; isPre : Bool} ;
--
}

Some files were not shown because too many files have changed in this diff Show More