forked from GitHub/comp-syntax-gu-mlt
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/, start GF and `import NobelDan.gf`, to do some testing
|
||||
- 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!
|
||||
|
||||
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,
|
||||
```
|
||||
import NobelEng.gf
|
||||
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 ;
|
||||
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 ;
|
||||
YearDate : Int -> Date ;
|
||||
he_Name, she_Name, they_Name : Name ;
|
||||
|
||||
@@ -20,6 +20,8 @@ lin
|
||||
DiedSentence name 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 ;
|
||||
|
||||
YearDate i = inAdv <symb i : NP> ;
|
||||
|
||||
@@ -70,9 +70,9 @@ def quantifier(term):
|
||||
case ("TElement", element):
|
||||
return lambda p: p(value(element))
|
||||
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]):
|
||||
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))
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import pgf
|
||||
|
||||
# query: https://w.wiki/3tEM
|
||||
|
||||
# usage: descri_nobel <lang> gender?
|
||||
|
||||
DATA_FILE = '../data/query.json'
|
||||
WIKIDATA_PREFIX = 'http://www.wikidata.org/entity/'
|
||||
GRAMMAR_PREFIX = 'Nobel'
|
||||
@@ -51,7 +53,15 @@ def template_description(d):
|
||||
|
||||
def name(d):
|
||||
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):
|
||||
@@ -78,8 +88,8 @@ def grammar_description(grammar, fundata, d, lang):
|
||||
died = pgf.readExpr(
|
||||
f"DiedSentence ({name(d)}) (YearDate {year(d['deathDate'])})")
|
||||
sentences.append(died)
|
||||
# return ('\n '.join([str(s) for s in sentences]))
|
||||
return ' '.join([lang.linearize(s) + '.' for s in sentences])
|
||||
return ('\n '.join([str(s) for s in sentences]))
|
||||
# return ' '.join([lang.linearize(s) + '.' for s in sentences])
|
||||
|
||||
|
||||
if sys.argv[1:]:
|
||||
|
||||
Reference in New Issue
Block a user