mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-08 22:41:05 -07:00
gendered person names possible, see README
This commit is contained in:
@@ -15,16 +15,35 @@ GF RGL and evaluate the text generated by this. The steps to take are the follow
|
|||||||
- in grammars/, copy `NobelEng.gf` to `NobelDan.gf` and do the necessary changes
|
- in grammars/, copy `NobelEng.gf` to `NobelDan.gf` and do the necessary changes
|
||||||
- in grammars/, start GF and `import NobelDan.gf`, to do some testing
|
- in grammars/, start GF and `import NobelDan.gf`, to do some testing
|
||||||
- in grammars/ outside GF, do `gf -make NobelEng.gf NobelDan.gf`
|
- in grammars/ outside GF, do `gf -make NobelEng.gf NobelDan.gf`
|
||||||
- in scripts/, generate all texts with `python3 describe_nobel.py Dan`
|
- (if possible, do this, but see woraround below) in scripts/, generate all texts with `python3 describe_nobel.py Dan`
|
||||||
|
|
||||||
The last step requires `pip3 install pgf`.
|
|
||||||
|
|
||||||
Replace da and Dan with your own language codes!
|
Replace da and Dan with your own language codes!
|
||||||
|
|
||||||
More instructions and demos are given in the lectures of the week 5-9 May 2025.
|
The last step above requires `pip3 install pgf`.
|
||||||
|
|
||||||
If you don't manage to install pgf, a quick way to test is, in GF,
|
If you don't manage to install pgf, a quick way to test is, in GF,
|
||||||
```
|
```
|
||||||
import NobelEng.gf
|
import NobelEng.gf
|
||||||
rf -file="../data/trees.gft" -lines -tree | l
|
rf -file="../data/trees.gft" -lines -tree | l
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## If you need gender agreement of nakes
|
||||||
|
|
||||||
|
(This note was added late, and is therefore not required at the 2025 course)
|
||||||
|
|
||||||
|
In some languages, names of laureates requires gender agreement.
|
||||||
|
In that case, use the GF command
|
||||||
|
```
|
||||||
|
rf -file="../data/gendertrees.gft" -lines -tree | l
|
||||||
|
```
|
||||||
|
or, if it works for you, the Python command
|
||||||
|
```
|
||||||
|
python3 describe_nobel.py Dan gender
|
||||||
|
```
|
||||||
|
This requires you to define linearizations of the gender-specific functions `MaleName` and `FemaleName` so that the gender agreement is set properly.
|
||||||
|
The following works for many languages:
|
||||||
|
```
|
||||||
|
FemaleName s = mkNP (mkPN s.s feminine) ;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2532
lab2/data/gendertrees.gft
Normal file
2532
lab2/data/gendertrees.gft
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,8 @@ fun
|
|||||||
AwardSentence : Name -> Award -> Date -> Sentence ;
|
AwardSentence : Name -> Award -> Date -> Sentence ;
|
||||||
DiedSentence : Name -> Date -> Sentence ;
|
DiedSentence : Name -> Date -> Sentence ;
|
||||||
|
|
||||||
|
FemaleName : String -> Name ; -- use if your language needs gender agreement
|
||||||
|
MaleName : String -> Name ; -- use if your language needs gender agreement
|
||||||
StringName : String -> Name ;
|
StringName : String -> Name ;
|
||||||
YearDate : Int -> Date ;
|
YearDate : Int -> Date ;
|
||||||
he_Name, she_Name, they_Name : Name ;
|
he_Name, she_Name, they_Name : Name ;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ lin
|
|||||||
DiedSentence name date =
|
DiedSentence name date =
|
||||||
mkS pastTense (mkCl name (mkVP die_VP date)) ;
|
mkS pastTense (mkCl name (mkVP die_VP date)) ;
|
||||||
|
|
||||||
|
FemaleName s = symb s ; -- use if your language needs gender agreement
|
||||||
|
MaleName s = symb s ; -- use if your language needs gender agreement
|
||||||
StringName s = symb s ;
|
StringName s = symb s ;
|
||||||
|
|
||||||
YearDate i = inAdv <symb i : NP> ;
|
YearDate i = inAdv <symb i : NP> ;
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ def quantifier(term):
|
|||||||
case ("TElement", element):
|
case ("TElement", element):
|
||||||
return lambda p: p(value(element))
|
return lambda p: p(value(element))
|
||||||
case ("TAll", [kind]):
|
case ("TAll", [kind]):
|
||||||
return lambda p: all(lambda x: not predicate(kind)(x) or p(x), data)
|
return lambda p: all([not predicate(kind)(x) or p(x) for x in data])
|
||||||
case ("TAny", [kind]):
|
case ("TAny", [kind]):
|
||||||
return lambda p: any(lambda x: predicate(kind)(x) and p(x), data)
|
return lambda p: any([predicate(kind)(x) and p(x) for x in data])
|
||||||
|
|
||||||
print('not yet', str(tree))
|
print('not yet', str(tree))
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import pgf
|
|||||||
|
|
||||||
# query: https://w.wiki/3tEM
|
# query: https://w.wiki/3tEM
|
||||||
|
|
||||||
|
# usage: descri_nobel <lang> gender?
|
||||||
|
|
||||||
DATA_FILE = '../data/query.json'
|
DATA_FILE = '../data/query.json'
|
||||||
WIKIDATA_PREFIX = 'http://www.wikidata.org/entity/'
|
WIKIDATA_PREFIX = 'http://www.wikidata.org/entity/'
|
||||||
GRAMMAR_PREFIX = 'Nobel'
|
GRAMMAR_PREFIX = 'Nobel'
|
||||||
@@ -51,7 +53,15 @@ def template_description(d):
|
|||||||
|
|
||||||
def name(d):
|
def name(d):
|
||||||
person = d['personLabel']
|
person = d['personLabel']
|
||||||
return f'StringName "{person}"'
|
if not sys.argv[2:]:
|
||||||
|
namefun = 'StringName'
|
||||||
|
elif pronoun(d) == 'she':
|
||||||
|
namefun = 'FemaleName'
|
||||||
|
elif pronoun(d) == 'he':
|
||||||
|
namefun = 'MaleName'
|
||||||
|
else:
|
||||||
|
namefun = 'StringName'
|
||||||
|
return f'{namefun} "{person}"'
|
||||||
|
|
||||||
|
|
||||||
def funs(funfile):
|
def funs(funfile):
|
||||||
@@ -78,8 +88,8 @@ def grammar_description(grammar, fundata, d, lang):
|
|||||||
died = pgf.readExpr(
|
died = pgf.readExpr(
|
||||||
f"DiedSentence ({name(d)}) (YearDate {year(d['deathDate'])})")
|
f"DiedSentence ({name(d)}) (YearDate {year(d['deathDate'])})")
|
||||||
sentences.append(died)
|
sentences.append(died)
|
||||||
# return ('\n '.join([str(s) for s in sentences]))
|
return ('\n '.join([str(s) for s in sentences]))
|
||||||
return ' '.join([lang.linearize(s) + '.' for s in sentences])
|
# return ' '.join([lang.linearize(s) + '.' for s in sentences])
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1:]:
|
if sys.argv[1:]:
|
||||||
|
|||||||
Reference in New Issue
Block a user