mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-08 22:41:05 -07:00
testing with trees without pgf
This commit is contained in:
@@ -23,3 +23,8 @@ 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.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
2532
lab2/data/trees.gft
Normal file
2532
lab2/data/trees.gft
Normal file
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ def predicate(tree):
|
||||
case ("PFemale", []):
|
||||
return lambda d: d['sexLabel'] == 'female'
|
||||
case ("KProperty", [property, kind]):
|
||||
return lambda d: predicate(property)(d) and predicate(kind(d))
|
||||
return lambda d: predicate(property)(d) and predicate(kind)(d)
|
||||
case ("KLaureate", []):
|
||||
return lambda d: True
|
||||
case ("KMan", []):
|
||||
@@ -85,9 +85,9 @@ def value(element):
|
||||
_, string = name.unpack
|
||||
return [d for d in data if d['personLabel'] == string][0] ## uncertain !
|
||||
case ('EYoungest', [kind]):
|
||||
return min(data, key = age)
|
||||
return min([d for d in data if predicate(kind)(d)], key = age)
|
||||
case ('EOldest', [kind]):
|
||||
return max(data, key = age)
|
||||
return max([d for d in data if predicate(kind)(d)], key = age)
|
||||
|
||||
print('not yet', str(tree))
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ 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])
|
||||
|
||||
|
||||
@@ -93,3 +94,4 @@ else:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user