Merge branch 'master' of github.com:GrammaticalFramework/gf-rgl

This commit is contained in:
John J. Camilleri
2020-11-30 20:58:05 +01:00
26 changed files with 80406 additions and 42 deletions

View File

@@ -4,7 +4,7 @@ language: c
os:
- linux
- osx
- windows
# - windows
addons:
apt:

View File

@@ -193,6 +193,9 @@ abstract Extend = Cat ** {
Cons_nr_RNP : NP -> RNPList -> RNPList ; -- John, my family, myself
---- Cons_rn_RNP : RNP -> ListNP -> RNPList ; -- myself, John, Mary
-- reflexive possessive on its own right, like in Swedish, Czech, Slovak
ReflPossPron : Quant ; -- Swe sin,sitt,sina
--- from Extensions

View File

@@ -79,6 +79,7 @@ lin
Base_rn_RNP = variants {} ; -- RNP -> NP -> RNPList ; -- myself, John
Cons_rr_RNP = variants {} ; -- RNP -> RNPList -> RNPList ; -- my family, myself, John
Cons_nr_RNP = variants {} ; -- NP -> RNPList -> RNPList ; -- John, my family, myself
ReflPossPron = PossPron he_Pron ; -- : Quant ; -- Swe sin,sitt,sina
ComplGenVV = variants {} ; -- VV -> Ant -> Pol -> VP -> VP ; -- want not to have slept
ComplSlashPartLast = ComplSlash ;
--SlashV2V = variants {} ; -- V2V -> Ant -> Pol -> VPS -> VPSlash ; -- force (her) not to have slept

View File

@@ -1,6 +1,7 @@
--# -path=.:../abstract:../common:../api
concrete AllCze of AllCzeAbs =
LangCze
LangCze,
ExtendCze
;

View File

@@ -1,6 +1,7 @@
--# -path=.:../abstract:../common:prelude
abstract AllCzeAbs =
Lang
Lang,
Extend
;

View File

@@ -24,6 +24,7 @@ concrete CatCze of Cat =
VPSlash = {verb : VerbForms ; clit,compl : Agr => Str ; c : ComplementCase} ; ----
V = ResCze.VerbForms ;
V2 = ResCze.VerbForms ** {c : ComplementCase} ;
VS,VQ = ResCze.VerbForms ;
A = ResCze.AdjForms ;
AP = ResCze.Adjective ** {isPost : Bool} ; -- {s : Gender => Number => Case => Str}

38
src/czech/ExtendCze.gf Normal file
View File

@@ -0,0 +1,38 @@
concrete ExtendCze of Extend = CatCze **
ExtendFunctor - [
ReflPossPron
---- constant not found (yet)
,youPolFem_Pron
,UttVPShort
,UttAccIP
,UttDatIP
,SubjRelNP
,StrandRelSlash
,StrandQuestSlash
,SlashBareV2S
,PredIAdvVP
,PredAPVP
,ExistsNP
,ExistS
,ExistPluralCN
,ExistNPQS
,ExistMassCN
,ExistIPQS
,ExistCN
,EmptyRelSlash
,DetNPMasc
,DetNPFem
,ComplBareVS
,CompIQuant
,CompBareCN
]
with (Grammar = GrammarCze)
**
open
ResCze
in {
lin ReflPossPron = justDemPronFormsAdjective reflPossessivePron ;
}

View File

@@ -632,8 +632,6 @@ adjFormsAdjective : AdjForms -> Adjective = \afs -> {
a : Agr
} ;
---- TODO: possessives
personalPron : Agr -> PronForms = \a ->
{a = a ; cnom = []} **
case a of {
@@ -753,6 +751,7 @@ adjFormsAdjective : AdjForms -> Adjective = \afs -> {
} ;
reflPossessivePron : DemPronForms = mladyAdjForms "svy" ** {msnom = "svůj" ; pdat = "svým"} ;
mkPron : Agr -> PronForms ** {poss : DemPronForms} = \a ->
personalPron a ** {poss = possessivePron a} ;

View File

@@ -23,6 +23,7 @@ lin
youSg_Pron = mkPron (Ag (Masc Anim) Sg P2) ;
he_Pron = mkPron (Ag (Masc Anim) Sg P3) ;
she_Pron = mkPron (Ag Fem Sg P3) ;
it_Pron = mkPron (Ag Neutr Sg P3) ;
we_Pron = mkPron (Ag (Masc Anim) Pl P1) ;
youPl_Pron = mkPron (Ag (Masc Anim) Pl P2) ;
they_Pron = mkPron (Ag (Masc Anim) Pl P3) ;

View File

@@ -99,14 +99,13 @@ concrete NounHun of Noun = CatHun ** open
quant ** num ** {
s = \\c => case <isNum num,isIndefArt quant> of {
<True,True> => [] ; -- don't output "a 2 cars"
_ => quant.s ! n ! c }
_ => quant.s ! n ! c } -- az/azok a …
++ num.s ! Attrib ; -- TODO: add inflection table in numbers
sp = \\c => case <isNum num,isIndefArt quant> of {
<True,True> => [] ;
_ => quant.sp ! n ! c }
_ => quant.sp ! n ! c } -- az/azok …
++ num.s ! Indep ;
n = n ;
dt = qt2dt quant.qt ;
} ;
-- : Quant -> Num -> Ord -> Det ; -- these five best
@@ -170,20 +169,20 @@ concrete NounHun of Noun = CatHun ** open
DefArt = mkQuant "a" "a" ** {
s,
sp = \\_,_ => pre {"a" ; "az" / v } ;
qt = DefQuant ;
dt = DefDet ;
} ;
-- : Quant
IndefArt = mkQuant "egy" [] ** {
s = \\n,_ => case n of {Sg => "egy" ; Pl => []} ;
sp = \\n,_ => case n of {Sg => "egy" ; Pl => "sok"} ;
qt = IndefArticle ;
dt = IndefDet ;
} ;
-- : Pron -> Quant
PossPron pron = pron ** {
s,sp = \\_ => pron.s ;
qt = QuantPoss (agr2pstem pron.agr) ;
dt = DetPoss (agr2pstem pron.agr) ;
caseagr = False ;
} ;

View File

@@ -17,17 +17,11 @@ oper
-- Quant
param
QuantType =
IndefArticle -- Needed to prevent "a 2 cars"
| IndefQuant -- Not IndefArt, not poss, not def
| DefQuant
| QuantPoss PossStem -- Which possessive stem it takes
;
DetType =
DefDet -- distinction between Article and Other no longer needed
| IndefDet -- still need def or indef
| DetPoss PossStem -- Sill need to know which stem it takes if Poss
DefDet
| IndefDet -- Def or Indef relevant for verb agreement
| DetPoss PossStem -- Which possessive stem it takes
;
-- Singular stems. Plural is always same, no need to add here.
@@ -35,10 +29,10 @@ param
oper
-- standard trick to prevent "a one car"
isIndefArt : {qt : QuantType} -> Bool = \quant ->
case quant.qt of {
IndefArticle => True ;
_ => False
isIndefArt : {dt : DetType} -> Bool = \quant ->
case quant.dt of {
IndefDet => True ;
_ => False
} ;
dt2objdef : DetType -> ObjDef = \dt -> case dt of {
@@ -51,12 +45,6 @@ oper
Indef => IndefDet
} ;
qt2dt : QuantType -> DetType = \qt -> case qt of {
QuantPoss x => DetPoss x ;
DefQuant => DefDet ;
_ => IndefDet
} ;
agr2pstem : Person*Number -> PossStem = \pn ->
case <pn.p1,pn.p2> of {
<P1,Pl> => dSg_rPl1 ;

View File

@@ -203,13 +203,13 @@ oper
Quant : Type = BaseQuant ** {
s, -- form that comes before noun: "{this} car"
sp : Number => Case => Str ; -- independent form, "I like {this}" (DetNP)
qt : QuantType ;
dt : DetType ;
} ;
mkQuant : (s,sp : Str) -> Quant = \s,sp -> {
s = mkCaseNoun s ;
sp = mkCaseNoun sp ;
qt = DefQuant ;
dt = DefDet ;
caseagr = True ;
poss = harm1 [] ;
} ;

View File

@@ -160,7 +160,9 @@ oper
-- case (masc and fem singular, masc plural, adverbial), given that
-- comparison is formed by "più".
mkA : (solo,sola,soli,sole,solamente : Str) -> A ; -- irregular adjective
mkA : (solo,sola,soli,sole : Str) -> A ; -- possibly irregular adjective
mkA : (solo,sola,soli,sole,solamente : Str) -> A ; -- irregular adjective, with adverb
-- With irregular comparison, there are as it were two adjectives:
-- the positive ("buono") and the comparative ("migliore").
@@ -391,13 +393,16 @@ oper
regV x =
let
are = Predef.dp 3 x ;
---- are = Predef.dp 3 x ;
ci = Predef.dp 2 (Predef.tk 3 x) ;
i = last ci ;
verb = case are of {
"ire" => finire_100 x ;
"ere" => temere_20 x ;
"are" => case i of {
verb : {s : VForm => Str} = case x of {
_ + "ire" => finire_100 x ;
_ + "ere" => temere_20 x ;
_ + "durre" => condurre_36 x ;
_ + "trarre" => trarre_91 x ;
_ + "rre" => porre_68 x ; --- all other verbs in -rre?
_ + "are" => case i of {
"c" => cercare_7 x ;
"g" => legare_8 x ;
_ => case ci of {
@@ -512,6 +517,7 @@ oper
mkA = overload {
mkA : (bianco : Str) -> A = regA ;
mkA : (solo,sola,soli,sole : Str) -> A = \solo,sola,soli,sole -> mk5A solo sola soli sole (sola + "mente") ;
mkA : (solo,sola,soli,sole, solamente : Str) -> A = mk5A ;
mkA : A -> A -> A = mkADeg ;
mkA : A -> CopulaType -> A = adjCopula ;

5
src/morphodict/Makefile Normal file
View File

@@ -0,0 +1,5 @@
ita:
cp -p MorphoDictItaAbs.header MorphoDictItaAbs.gf
cp -p MorphoDictIta.header MorphoDictIta.gf
python3 get_dict.py Ita tmp/IrregItaAbs.gf tmp/entries | grep -v "lin " >>MorphoDictItaAbs.gf
python3 get_dict.py Ita tmp/IrregItaAbs.gf tmp/entries | grep -v "fun " >>MorphoDictIta.gf

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
concrete MorphoDictIta of MorphoDictItaAbs =
CatIta [N,A,V,Adv,Prep] **
open
ParadigmsIta, IrregIta
in
{
-- converted from https://github.com/TALP-UPC/FreeLing/tree/master/data/it/dictionary/entries
-- inheriting its license https://creativecommons.org/licenses/by-sa/3.0/
lincat NSg,NPl = N ;
oper mkNSg : Str -> Gender -> N = \s,g -> mkN s g ;
oper mkNPl : Str -> Gender -> N = \s,g -> mkN s s g ;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
abstract MorphoDictItaAbs =
Cat [N,A,V,Adv,Prep] **
{
-- converted from https://github.com/TALP-UPC/FreeLing/tree/master/data/it/dictionary/entries
-- inheriting its license https://creativecommons.org/licenses/by-sa/3.0/
cat NSg ; NPl ;

176
src/morphodict/get_dict.py Normal file
View File

@@ -0,0 +1,176 @@
import sys
"""
Converting a form-lemma-description lexicon to a GF lexicon.
Example: Romance resources from http://nlp.lsi.upc.edu/freeling/index.php/node/12
$ python3 get_dict.py Ita tmp/IrregItaAbs.gf tmp/entries
where entries is obtained by
$ cat adjs adv noun verb other | sort -u >entries
in FreeLing/data/it/dictionary/entries/
In this file, each line has three words, e.g.
abbondanze abbondanza NCFP000
from which the script produces two lines,
fun abbondanza_N : N ;
lin abbondanza_N = mkN "abbondanza" "abbondanze" feminine ;
These can be directed to an abstract and concrete module by using grep, as shown in Makefile.
Adaptation to a new language requires extending lang_args() with a new language code and the functions for that language.
"""
# an auxiliary
def quoted(s):
return '"' + s + '"'
######################
## language-specific code
######################
## Ita = Italian
# how each argument is obtained from the set of descriptions
def ita_noun_args(irregs,entry):
arg1 = entry.get('NCFS000', entry.get('NCMS000',entry.get('NCFN000',entry.get('NCMN000','NONE'))))
arg2 = entry.get('NCFP000', entry.get('NCMP000','NONE'))
if 'NCFS000' in entry.keys():
arg3 = 'feminine'
else:
arg3 = 'masculine'
if arg2 == 'NONE':
return ['NSg', arg1, 'mkNSg', quoted(arg1), arg3] # nouns that occur in singular only
elif arg1 == 'NONE':
return ['NPl', arg2, 'mkNPl', quoted(arg2), arg3] # nouns that occur in pular only
else:
return ['N', arg1, 'mkN', quoted(arg1), quoted(arg2),arg3]
def ita_adj_args(irregs,entry):
arg1 = entry.get('AQ0MS00', entry.get('AQ0CS00',entry.get('AQ0CN00','NONE')))
arg2 = entry.get('AQ0FS00', entry.get('AQ0CS00',entry.get('AQ0CN00','NONE')))
arg3 = entry.get('AQ0MP00', entry.get('AQ0CP00',entry.get('AQ0CN00','NONE')))
arg4 = entry.get('AQ0FP00', entry.get('AQ0CS00',entry.get('AQ0CN00','NONE_' + str(entry))))
return ['A', arg1, 'mkA', quoted(arg1), quoted(arg2),quoted(arg3),quoted(arg4)]
def ita_verb_args(irregs,entry):
arg1 = entry.get('VMN0000', 'NONE_' + str(entry))
if (arg1 + '_V') in irregs:
return ['V', arg1, '', 'IrregIta.' + arg1 + '_V']
else:
return ['V', arg1, 'mkV', quoted(arg1)]
def ita_adv_args(irregs,entry):
arg1 = entry.get('RG', 'NONE_' + str(entry))
return ['Adv', arg1, 'mkAdv', quoted(arg1)]
def ita_prep_args(irregs,entry):
arg1 = entry.get('SPS00', 'NONE_' + str(entry)) ## includes di,in,... but not their contractions
return ['Prep', arg1, 'mkPrep', quoted(arg1)]
def ignore_args(irregs,entry):
arg1 = 'NONE_' + str(entry)
return ['IGNORED', list(entry.values())[0], '', quoted(arg1)]
def ita_args(key):
if key[0] == 'A':
return ita_adj_args
elif key[0] == 'N':
return ita_noun_args
elif key[0] == 'V':
return ita_verb_args
elif key[0] == 'R':
return ita_adv_args
elif key[0] == 'S':
return ita_prep_args
else:
return ignore_args
def lang_args(lang,key):
if lang == 'Ita':
return ita_args(key)
else:
print("unknown language", lang)
##########################################################
## from this point, the code is generic for all languages
##########################################################
def get_irregs(ifile):
file = open(ifile)
irregs = []
for line in file:
ws = line.split()
if ws and ws[0] == 'fun':
irregs.append(ws[1])
file.close()
return irregs
def get_dict(filename):
file = open(filename)
dict = {}
for line in file:
words = line.split()
if len(words) == 3:
cat = words[2][0] # N,A,V,R,S ...
key = cat + '_' + words[1]
dict[key] = dict.get(key,{})
dict[key][words[2]] = words[0]
return dict
def clean_fun(lemma,cat):
if lemma.isalpha():
return lemma + '_' + cat
else:
fun = ''
for c in lemma:
if c=="'":
fun += "\\'"
else:
fun += c
return "'" + fun + '_' + cat + "'"
def print_entry(irregs,mapping,entry):
args = mapping(irregs,entry)
fun = clean_fun(args[1],args[0])
comment = min(1,str(args).count('NONE')) * '-- '
rule = [comment + "fun", fun, ":", args[0], ";"]
print(' '.join(rule))
rule = [comment + "lin", fun, "=", args[2]]
for arg in args[3:]:
rule.append(arg)
rule.append(';')
print(' '.join(rule))
def main():
if len(sys.argv) != 4:
print("usage: python3 get_dict <lang> <irregsfile> <dictfile>")
return 1
lang = sys.argv[1]
irregsfile = sys.argv[2]
dictfile = sys.argv[3]
irregs = get_irregs(irregsfile)
dict = get_dict(dictfile)
for key,entry in dict.items():
print_entry(irregs,lang_args(lang,key),entry)
print("}")
return 0
main()

View File

@@ -1,6 +1,7 @@
--# -path=.:../abstract:../common:../api
concrete AllSlo of AllSloAbs =
LangSlo
LangSlo,
ExtendSlo
;

View File

@@ -1,6 +1,7 @@
--# -path=.:../abstract:../common:prelude
abstract AllSloAbs =
Lang
Lang,
Extend
;

View File

@@ -24,6 +24,7 @@ concrete CatSlo of Cat =
VPSlash = {verb : VerbForms ; clit,compl : Agr => Str ; c : ComplementCase} ; ----
V = ResSlo.VerbForms ;
V2 = ResSlo.VerbForms ** {c : ComplementCase} ;
VS,VQ = ResSlo.VerbForms ;
A = ResSlo.AdjForms ;
AP = ResSlo.Adjective ** {isPost : Bool} ; -- {s : Gender => Number => Case => Str}

38
src/slovak/ExtendSlo.gf Normal file
View File

@@ -0,0 +1,38 @@
concrete ExtendSlo of Extend = CatSlo **
ExtendFunctor - [
ReflPossPron
---- constant not found (yet)
,youPolFem_Pron
,UttVPShort
,UttAccIP
,UttDatIP
,SubjRelNP
,StrandRelSlash
,StrandQuestSlash
,SlashBareV2S
,PredIAdvVP
,PredAPVP
,ExistsNP
,ExistS
,ExistPluralCN
,ExistNPQS
,ExistMassCN
,ExistIPQS
,ExistCN
,EmptyRelSlash
,DetNPMasc
,DetNPFem
,ComplBareVS
,CompIQuant
,CompBareCN
]
with (Grammar = GrammarSlo)
**
open
ResSlo
in {
lin ReflPossPron = justDemPronFormsAdjective reflPossessivePron ;
}

View File

@@ -869,6 +869,15 @@ adjFormsAdjective : AdjForms -> Adjective = \afs -> {
} ;
reflPossessivePron : DemPronForms = otcovA "svoj" ** {
msnom = "svoj" ; msgen = "svojho" ; msdat = "svojmu" ;
msins = "svojím" ;
ampnom = "svoji" ;
nsnom, fpnom = "svoje" ;
pgen = "svojich" ;
pdat = "svojim" ;
pins = "svojimi" ;
} ;
mkPron : Agr -> PronForms ** {poss : DemPronForms} = \a ->
personalPron a ** {poss = possessivePron a} ;

View File

@@ -24,6 +24,7 @@ lin
youSg_Pron = mkPron (Ag (Masc Anim) Sg P2) ;
he_Pron = mkPron (Ag (Masc Anim) Sg P3) ;
she_Pron = mkPron (Ag Fem Sg P3) ;
it_Pron = mkPron (Ag Neutr Sg P3) ;
we_Pron = mkPron (Ag (Masc Anim) Pl P1) ;
youPl_Pron = mkPron (Ag (Masc Anim) Pl P2) ;
they_Pron = mkPron (Ag (Masc Anim) Pl P3) ;

View File

@@ -12,14 +12,16 @@ concrete ExtendSwe of Extend = CatSwe **
ICompAP,ProDrop,EmbedSSlash,
AdAdV, PositAdVAdj, GerundCN, GerundNP, GerundAdv, PresPartAP, PastPartAP, PastPartAgentAP,
RNP, RNPList, ReflRNP, ReflPron, ReflPoss, PredetRNP, ConjRNP,
Base_rr_RNP, Base_nr_RNP, Base_rn_RNP, Cons_rr_RNP, Cons_nr_RNP,
Base_rr_RNP, Base_nr_RNP, Base_rn_RNP, Cons_rr_RNP, Cons_nr_RNP, ReflPossPron,
CompoundN, CompoundAP, AdvIsNP,
UttAccNP
]
with (Grammar = GrammarSwe)
**
open CommonScand, ResSwe, ParamX, VerbSwe, Prelude, DiffSwe, StructuralSwe, MorphoSwe,
NounSwe, Coordination, AdjectiveSwe, SentenceSwe, AdverbSwe, RelativeSwe, (P = ParadigmsSwe) in {
NounSwe, Coordination, AdjectiveSwe, SentenceSwe, AdverbSwe, RelativeSwe, (P = ParadigmsSwe),
(M = MakeStructuralSwe)
in {
flags coding=utf8 ;
@@ -207,6 +209,8 @@ concrete ExtendSwe of Extend = CatSwe **
Cons_rr_RNP x xs = consrTable Agr comma x xs ;
Cons_nr_RNP x xs = consrTable Agr comma {s = \\a => x.s ! NPAcc} xs ;
ReflPossPron = M.mkQuant "sin" "sitt" "sina" ;
lin
ApposNP np1 np2 = {s = \\nform => np1.s ! nform ++ comma ++ np2.s ! nform; a = np1.a; isPron = False} ;