forked from GitHub/comp-syntax-gu-mlt
dev shell
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
*.gfo
|
||||
.direnv
|
||||
133
flake.lock
generated
Normal file
133
flake.lock
generated
Normal file
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"nodes": {
|
||||
"bnfc": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1694438405,
|
||||
"narHash": "sha256-UmrJlHrMlB4tOxQEnBA1blh3aUV28dJHFZs5LNUbNLU=",
|
||||
"owner": "BNFC",
|
||||
"repo": "bnfc",
|
||||
"rev": "1ead871febe45b8adecad286a90650414e24d8a4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "BNFC",
|
||||
"ref": "master",
|
||||
"repo": "bnfc",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gf": {
|
||||
"inputs": {
|
||||
"bnfc": "bnfc",
|
||||
"gf-core": "gf-core",
|
||||
"gf-rgl": "gf-rgl",
|
||||
"gf-wordnet": "gf-wordnet",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1695852170,
|
||||
"narHash": "sha256-xgA9ltioXjh5gYdgmzWACMFeFJu3w4ytMqQlb649oH8=",
|
||||
"owner": "anka-213",
|
||||
"repo": "cclaw-nix-stuff",
|
||||
"rev": "bb591a7d0b6e81f5ae053d2e99a0f8dd9fb5d2a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "anka-213",
|
||||
"ref": "nix-flakes",
|
||||
"repo": "cclaw-nix-stuff",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gf-core": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1695655790,
|
||||
"narHash": "sha256-de5Fk5TK5aUL1YQphoYNBrpJj8GRuPJis7komT95+q8=",
|
||||
"owner": "GrammaticalFramework",
|
||||
"repo": "gf-core",
|
||||
"rev": "7d9015e2e159b376cf2ba8332093c9623375557e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "GrammaticalFramework",
|
||||
"ref": "master",
|
||||
"repo": "gf-core",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gf-rgl": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1695810223,
|
||||
"narHash": "sha256-deTXlcYreUl/pHnFZbjSrZIq8L/XunLTODm7aE9LKSA=",
|
||||
"owner": "GrammaticalFramework",
|
||||
"repo": "gf-rgl",
|
||||
"rev": "f19dcc01f99252feb79823830863389e6cf0fc7f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "GrammaticalFramework",
|
||||
"ref": "master",
|
||||
"repo": "gf-rgl",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gf-wordnet": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1695803720,
|
||||
"narHash": "sha256-LG5NVsB81Any5P/2WgEpELJKZQmySloHk1F42E7wD1k=",
|
||||
"owner": "GrammaticalFramework",
|
||||
"repo": "gf-wordnet",
|
||||
"rev": "39efb2f91ccb9575c8d96bc272bd2d9f90c1eb23",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "GrammaticalFramework",
|
||||
"ref": "master",
|
||||
"repo": "gf-wordnet",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1665056165,
|
||||
"narHash": "sha256-2C7VfNphJa0FxPoT+suMOmUDVrQ5RIE+NKfDWqElvE4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "27a89ba43b0fb735ce867e8ab3d2442f8cc61dad",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1769170682,
|
||||
"narHash": "sha256-oMmN1lVQU0F0W2k6OI3bgdzp2YOHWYUAw79qzDSjenU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c5296fdd05cfa2c187990dd909864da9658df755",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"gf": "gf",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
40
flake.nix
Normal file
40
flake.nix
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
gf.url = "github:anka-213/cclaw-nix-stuff/nix-flakes";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
let
|
||||
supportedSystems = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (pkgs) lib;
|
||||
inherit system;
|
||||
});
|
||||
in {
|
||||
devShells =
|
||||
each-system ({ pkgs, system, ... }:
|
||||
let
|
||||
gf-lsp = import
|
||||
(pkgs.fetchzip {
|
||||
url = "https://github.com/anka-213/gf-lsp/archive/refs/tags/1.0.6.0.tar.gz";
|
||||
hash = "sha256-UAI2qUslzLOWYjTirZJ0y4DZbkPZnVXTY0XtFO8+Rks=";
|
||||
}) {inherit system;};
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
inputs.gf.packages.${system}.gf-with-rgl
|
||||
pkgs.graphviz
|
||||
gf-lsp.gf-lsp
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
225
lab1/grammar/korean/MicroLangKor.gf
Normal file
225
lab1/grammar/korean/MicroLangKor.gf
Normal file
@@ -0,0 +1,225 @@
|
||||
--# -path=.:../abstract
|
||||
concrete MicroLangKor of MicroLang = open MicroResKor, Prelude in {
|
||||
|
||||
-----------------------------------------------------
|
||||
---------------- Grammar part -----------------------
|
||||
-----------------------------------------------------
|
||||
|
||||
lincat
|
||||
Utt = {s : Str} ;
|
||||
|
||||
S = {s : Str} ;
|
||||
VP = {verb : Verb ; compl : Str} ; ---s special case of Mini
|
||||
Comp = {s : Str} ;
|
||||
AP = Adjective ;
|
||||
CN = Noun ;
|
||||
NP = {s : Case => Str ; a : Agreement} ;
|
||||
Pron = {s : Case => Str ; a : Agreement} ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
Prep = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
A = Adjective ;
|
||||
N = Noun ;
|
||||
Adv = {s : Str} ;
|
||||
|
||||
lin
|
||||
UttS s = s ;
|
||||
UttNP np = {s = np.s ! Acc} ;
|
||||
|
||||
PredVPS np vp = {
|
||||
s = np.s ! Nom ++ vp.verb.s ! agr2vform np.a ++ vp.compl
|
||||
} ;
|
||||
|
||||
UseV v = {
|
||||
verb = v ;
|
||||
compl = [] ;
|
||||
} ;
|
||||
|
||||
ComplV2 v2 np = {
|
||||
verb = v2 ;
|
||||
compl = v2.c ++ np.s ! Acc -- NP object in the accusative, preposition first
|
||||
} ;
|
||||
|
||||
UseComp comp = {
|
||||
verb = be_Verb ; -- the verb is the copula "be"
|
||||
compl = comp.s
|
||||
} ;
|
||||
|
||||
CompAP ap = ap ;
|
||||
|
||||
AdvVP vp adv =
|
||||
vp ** {compl = vp.compl ++ adv.s} ;
|
||||
|
||||
DetCN det cn = {
|
||||
s = \\c => det.s ++ cn.s ! det.n ;
|
||||
a = Agr det.n ;
|
||||
} ;
|
||||
|
||||
UsePron p = p ;
|
||||
|
||||
a_Det = {s = pre {"a"|"e"|"i"|"o" => "an" ; _ => "a"} ; n = Sg} ; --- a/an can get wrong
|
||||
aPl_Det = {s = "" ; n = Pl} ;
|
||||
the_Det = {s = "the" ; n = Sg} ;
|
||||
thePl_Det = {s = "the" ; n = Pl} ;
|
||||
|
||||
UseN n = n ;
|
||||
|
||||
AdjCN ap cn = {
|
||||
s = table {n => ap.s ++ cn.s ! n}
|
||||
} ;
|
||||
|
||||
PositA a = a ;
|
||||
|
||||
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
|
||||
|
||||
in_Prep = {s = "in"} ;
|
||||
on_Prep = {s = "on"} ;
|
||||
with_Prep = {s = "with"} ;
|
||||
|
||||
he_Pron = {
|
||||
s = table {Nom => "he" ; Acc => "him"} ;
|
||||
a = Agr Sg ;
|
||||
} ;
|
||||
she_Pron = {
|
||||
s = table {Nom => "she" ; Acc => "her"} ;
|
||||
a = Agr Sg ;
|
||||
} ;
|
||||
they_Pron = {
|
||||
s = table {Nom => "they" ; Acc => "them"} ;
|
||||
a = Agr Pl ;
|
||||
} ;
|
||||
|
||||
-----------------------------------------------------
|
||||
---------------- Lexicon part -----------------------
|
||||
-----------------------------------------------------
|
||||
|
||||
lin already_Adv = mkAdv "벌써" ;
|
||||
lin animal_N = mkN "동물" ;
|
||||
lin apple_N = mkN "사과" ;
|
||||
lin baby_N = mkN "아기" ;
|
||||
lin bad_A = mkA "나쁜" ;
|
||||
lin beer_N = mkN "beer" ;
|
||||
lin big_A = mkA "큰" ;
|
||||
lin bike_N = mkN "bike" ;
|
||||
lin bird_N = mkN "bird" ;
|
||||
lin black_A = mkA "black" ;
|
||||
lin blood_N = mkN "피" ;
|
||||
lin blue_A = mkA "blue" ;
|
||||
lin boat_N = mkN "boat" ;
|
||||
lin book_N = mkN "책" ;
|
||||
lin boy_N = mkN "소녁" ;
|
||||
lin bread_N = mkN "bread" ;
|
||||
lin break_V2 = mkV2 (mkV "break" "broke" "broken") ;
|
||||
lin buy_V2 = mkV2 (mkV "buy" "bought" "bought") ;
|
||||
lin car_N = mkN "자동차" ;
|
||||
lin cat_N = mkN "고양이" ;
|
||||
lin child_N = mkN "어린이" ;
|
||||
lin city_N = mkN "city" ;
|
||||
lin clean_A = mkA "정소한" ;
|
||||
lin clever_A = mkA "똑똑한" ;
|
||||
lin cloud_N = mkN "cloud" ;
|
||||
lin cold_A = mkA "차가운" ;
|
||||
lin come_V = mkV "come" "came" "come" ;
|
||||
lin computer_N = mkN "컴퓨터" ;
|
||||
lin cow_N = mkN "cow" ;
|
||||
lin dirty_A = mkA "더러운" ;
|
||||
lin dog_N = mkN "개" ;
|
||||
lin drink_V2 = mkV2 (mkV "drink" "drank" "drunk") ;
|
||||
lin eat_V2 = mkV2 (mkV "eat" "ate" "eaten") ;
|
||||
lin find_V2 = mkV2 (mkV "find" "found" "found") ;
|
||||
lin fire_N = mkN "fire" ;
|
||||
lin fish_N = mkN "생선" ;
|
||||
lin flower_N = mkN "flower" ;
|
||||
lin friend_N = mkN "진구" ;
|
||||
lin girl_N = mkN "소녀" ;
|
||||
lin good_A = mkA "좋은" ;
|
||||
lin go_V = mkV "go" "went" "gone" ;
|
||||
lin grammar_N = mkN "grammar" ;
|
||||
lin green_A = mkA "green" ;
|
||||
lin heavy_A = mkA "heavy" ;
|
||||
lin horse_N = mkN "horse" ;
|
||||
lin hot_A = mkA "hot" ;
|
||||
lin house_N = mkN "집" ;
|
||||
-- lin john_PN = mkPN "John" ;
|
||||
lin jump_V = mkV "jump" ;
|
||||
lin kill_V2 = mkV2 "kill" ;
|
||||
-- lin know_VS = mkVS (mkV "know" "knew" "known") ;
|
||||
lin language_N = mkN "언어" ;
|
||||
lin live_V = mkV "live" ;
|
||||
lin love_V2 = mkV2 (mkV "love") ;
|
||||
lin man_N = mkN "남자" ;
|
||||
lin milk_N = mkN "우유" ;
|
||||
lin music_N = mkN "음악" ;
|
||||
lin new_A = mkA "new" ;
|
||||
lin now_Adv = mkAdv "지금" ;
|
||||
lin old_A = mkA "낡안" ;
|
||||
-- lin paris_PN = mkPN "Paris" ;
|
||||
lin play_V = mkV "play" ;
|
||||
lin read_V2 = mkV2 (mkV "read" "read" "read") ;
|
||||
lin ready_A = mkA "ready" ;
|
||||
lin red_A = mkA "red" ;
|
||||
lin river_N = mkN "river" ;
|
||||
lin run_V = mkV "run" "ran" "run" ;
|
||||
lin sea_N = mkN "바다" ;
|
||||
lin see_V2 = mkV2 (mkV "see" "saw" "seen") ;
|
||||
lin ship_N = mkN "ship" ;
|
||||
lin sleep_V = mkV "sleep" "slept" "slept" ;
|
||||
lin small_A = mkA "작은" ;
|
||||
lin star_N = mkN "별" ;
|
||||
lin swim_V = mkV "swim" "swam" "swum" ;
|
||||
lin teach_V2 = mkV2 (mkV "teach" "taught" "taught") ;
|
||||
lin train_N = mkN "train" ;
|
||||
lin travel_V = mkV "travel" ;
|
||||
lin tree_N = mkN "tree" ;
|
||||
lin understand_V2 = mkV2 (mkV "understand" "understood" "understood") ;
|
||||
lin wait_V2 = mkV2 "wait" "for" ;
|
||||
lin walk_V = mkV "walk" ;
|
||||
lin warm_A = mkA "따뜻한" ;
|
||||
lin water_N = mkN "물" ;
|
||||
lin white_A = mkA "하얗은" ;
|
||||
lin wine_N = mkN "wine" ;
|
||||
lin woman_N = mkN "여자" ;
|
||||
lin yellow_A = mkA "yellow" ;
|
||||
lin young_A = mkA "young" ;
|
||||
|
||||
---------------------------
|
||||
-- Paradigms part ---------
|
||||
---------------------------
|
||||
|
||||
oper
|
||||
mkN = overload {
|
||||
mkN : Str -> Noun -- predictable noun, e.g. car-cars, boy-boys, fly-flies, bush-bushes
|
||||
= \n -> lin N (smartNoun n) ;
|
||||
mkN : Str -> Str -> Noun -- irregular noun, e.g. man-men
|
||||
= \sg,pl -> lin N (mkNoun sg pl) ;
|
||||
} ;
|
||||
|
||||
mkA : Str -> A
|
||||
= \s -> lin A {s = s} ;
|
||||
|
||||
mkV = overload {
|
||||
mkV : (inf : Str) -> V -- predictable verb, e.g. play-plays, cry-cries, wash-washes
|
||||
= \s -> lin V (smartVerb s) ;
|
||||
mkV : (inf,pres,part : Str) -> V -- irregular verb, e.g. drink-drank-drunk
|
||||
= \inf,pres,part -> lin V (irregVerb inf pres part) ;
|
||||
} ;
|
||||
|
||||
mkV2 = overload {
|
||||
mkV2 : Str -> V2 -- predictable verb with direct object, e.g. "wash"
|
||||
= \s -> lin V2 (smartVerb s ** {c = []}) ;
|
||||
mkV2 : Str -> Str -> V2 -- predictable verb with preposition, e.g. "wait - for"
|
||||
= \s,p -> lin V2 (smartVerb s ** {c = p}) ;
|
||||
mkV2 : V -> V2 -- any verb with direct object, e.g. "drink"
|
||||
= \v -> lin V2 (v ** {c = []}) ;
|
||||
mkV2 : V -> Str -> V2 -- any verb with preposition
|
||||
= \v,p -> lin V2 (v ** {c = p}) ;
|
||||
} ;
|
||||
|
||||
mkAdv : Str -> Adv
|
||||
= \s -> lin Adv {s = s} ;
|
||||
|
||||
mkPrep : Str -> Prep
|
||||
= \s -> lin Prep {s = s} ;
|
||||
|
||||
}
|
||||
75
lab1/grammar/korean/MicroResKor.gf
Normal file
75
lab1/grammar/korean/MicroResKor.gf
Normal file
@@ -0,0 +1,75 @@
|
||||
resource MicroResKor = open Prelude in {
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
Case = Nom | Acc ;
|
||||
|
||||
|
||||
Agreement = Agr Number ; ---s Person to be added
|
||||
|
||||
-- all forms of normal Eng verbs, although not yet used in MiniGrammar
|
||||
VForm = Inf | PresSg3 | Past | PastPart | PresPart ;
|
||||
|
||||
oper
|
||||
Noun : Type = {s : Number => Str} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \sg,pl -> {
|
||||
s = table {Sg => sg ; Pl => pl}
|
||||
} ;
|
||||
|
||||
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
|
||||
|
||||
-- smart paradigm
|
||||
smartNoun : Str -> Noun = \sg -> case sg of {
|
||||
_ + ("ay"|"ey"|"oy"|"uy") => regNoun sg ;
|
||||
x + "y" => mkNoun sg (x + "ies") ;
|
||||
_ + ("ch"|"sh"|"s"|"o") => mkNoun sg (sg + "es") ;
|
||||
_ => regNoun sg
|
||||
} ;
|
||||
|
||||
Adjective : Type = {s : Str} ;
|
||||
|
||||
Verb : Type = {s : VForm => Str} ;
|
||||
|
||||
mkVerb : (inf,pres,past,pastpart,prespart : Str) -> Verb
|
||||
= \inf,pres,past,pastpart,prespart -> {
|
||||
s = table {
|
||||
Inf => inf ;
|
||||
PresSg3 => pres ;
|
||||
Past => past ;
|
||||
PastPart => pastpart ;
|
||||
PresPart => prespart
|
||||
}
|
||||
} ;
|
||||
|
||||
regVerb : (inf : Str) -> Verb = \inf ->
|
||||
mkVerb inf (inf + "s") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
|
||||
-- regular verbs with predictable variations
|
||||
smartVerb : Str -> Verb = \inf -> case inf of {
|
||||
pl + ("a"|"e"|"i"|"o"|"u") + "y" => regVerb inf ;
|
||||
cr + "y" => mkVerb inf (cr + "ies") (cr + "ied") (cr + "ied") (inf + "ing") ;
|
||||
lov + "e" => mkVerb inf (inf + "s") (lov + "ed") (lov + "ed") (lov + "ing") ;
|
||||
kis + ("s"|"sh"|"x"|"o") => mkVerb inf (inf + "es") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
_ => regVerb inf
|
||||
} ;
|
||||
|
||||
-- normal irregular verbs e.g. drink,drank,drunk
|
||||
irregVerb : (inf,past,pastpart : Str) -> Verb =
|
||||
\inf,past,pastpart ->
|
||||
let verb = smartVerb inf
|
||||
in mkVerb inf (verb.s ! PresSg3) past pastpart (verb.s ! PresPart) ;
|
||||
|
||||
-- two-place verb with "case" as preposition; for transitive verbs, c=[]
|
||||
Verb2 : Type = Verb ** {c : Str} ;
|
||||
|
||||
be_Verb : Verb = mkVerb "are" "is" "was" "been" "being" ; ---s to be generalized
|
||||
|
||||
|
||||
---s a very simplified verb agreement function for Micro
|
||||
agr2vform : Agreement -> VForm = \a -> case a of {
|
||||
Agr Sg => PresSg3 ;
|
||||
Agr Pl => Inf
|
||||
} ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user