forked from GitHub/gf-core
added srg; extended shallow
This commit is contained in:
@@ -8,6 +8,11 @@
|
|||||||
-- It is not primarily aimed to be used through selection from the API,
|
-- It is not primarily aimed to be used through selection from the API,
|
||||||
-- but through a parser.
|
-- but through a parser.
|
||||||
-- It can also serve for experiments with shallow (fast?) parsing.
|
-- It can also serve for experiments with shallow (fast?) parsing.
|
||||||
|
--
|
||||||
|
-- S ::= NP Adv* V NP? Adv*
|
||||||
|
-- | NP Adv* "is" Adj Adv*
|
||||||
|
-- NP ::= Det CN
|
||||||
|
-- CN ::= Adj* N
|
||||||
|
|
||||||
abstract Shallow = {
|
abstract Shallow = {
|
||||||
cat
|
cat
|
||||||
@@ -21,10 +26,12 @@ abstract Shallow = {
|
|||||||
N ;
|
N ;
|
||||||
Noun ;
|
Noun ;
|
||||||
CN ;
|
CN ;
|
||||||
NP ;
|
|
||||||
PN ;
|
PN ;
|
||||||
|
NP ;
|
||||||
|
Det ;
|
||||||
Adv ;
|
Adv ;
|
||||||
Prep ;
|
Prep ;
|
||||||
|
Num ;
|
||||||
|
|
||||||
fun
|
fun
|
||||||
PhrS : S -> Phr ;
|
PhrS : S -> Phr ;
|
||||||
@@ -46,13 +53,57 @@ abstract Shallow = {
|
|||||||
ImpCN, ImpNegCN : CN -> Imp ;
|
ImpCN, ImpNegCN : CN -> Imp ;
|
||||||
ImpAdv,ImpNegAdv : Adv -> Imp ;
|
ImpAdv,ImpNegAdv : Adv -> Imp ;
|
||||||
|
|
||||||
ModNoun : Adj -> Noun -> Noun ;
|
UsePN : PN -> NP ;
|
||||||
|
DefNP : CN -> NP ;
|
||||||
|
IndefNP : CN -> NP ;
|
||||||
|
DetNP : Det -> CN -> NP ;
|
||||||
|
|
||||||
PrepNP : Prep -> NP -> Adv ;
|
PrepNP : Prep -> NP -> Adv ;
|
||||||
PrepNoun : CN -> Prep -> NP -> CN ;
|
AdvNoun : CN -> Adv -> CN ;
|
||||||
|
|
||||||
CNNoun : Noun -> CN ;
|
CNNoun : Noun -> CN ;
|
||||||
NounN : N -> Noun ;
|
NounN : N -> Noun ;
|
||||||
DefNP, IndefNP, EveryNP, AllNP : CN -> NP ;
|
ModNoun : Adj -> Noun -> Noun ;
|
||||||
UsePN : PN -> NP ;
|
|
||||||
|
NoNum : Num ;
|
||||||
|
|
||||||
|
-- copied from Structural
|
||||||
|
|
||||||
|
EveryDet, WhichDet, AllMassDet, -- every, sg which, sg all
|
||||||
|
SomeDet, AnyDet, NoDet, -- sg some, any, no
|
||||||
|
MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much
|
||||||
|
ThisDet, ThatDet : Det ; -- this, that
|
||||||
|
|
||||||
|
AllNumDet, WhichNumDet, -- pl all, which (86)
|
||||||
|
SomeNumDet, AnyNumDet, NoNumDet, -- pl some, any, no
|
||||||
|
TheseNumDet, ThoseNumDet : Num -> Det ; -- these, those (86)
|
||||||
|
|
||||||
|
ThisNP, ThatNP : NP ; -- this, that
|
||||||
|
TheseNumNP, ThoseNumNP : Num -> NP ; -- these, those (86)
|
||||||
|
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
|
||||||
|
WeNumNP, YeNumNP : Num -> NP ; -- these pronouns can take numeral
|
||||||
|
TheyNP : NP ; YouNP : NP ; -- they, the polite you
|
||||||
|
|
||||||
|
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
|
||||||
|
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
|
||||||
|
|
||||||
|
|
||||||
|
InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations
|
||||||
|
ThroughPrep, AbovePrep, UnderPrep,
|
||||||
|
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
|
||||||
|
BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations
|
||||||
|
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
|
||||||
|
PossessPrep : Prep ; -- possessive/genitive
|
||||||
|
PartPrep : Prep ; -- partitive "of" ("bottle of wine")
|
||||||
|
AgentPrep : Prep ; -- agent "by" in passive constructions
|
||||||
|
|
||||||
|
|
||||||
|
--!
|
||||||
|
--2 Affirmation and negation
|
||||||
|
--
|
||||||
|
-- The negative-positive (French "si", German "doch") is missing.
|
||||||
|
|
||||||
|
PhrYes, PhrNo : Phr ; -- yes, no
|
||||||
|
|
||||||
|
|
||||||
PossessPrep : Prep ;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ incomplete concrete ShallowI of Shallow = open (Resource = Resource) in {
|
|||||||
Adv = Resource.AdV ;
|
Adv = Resource.AdV ;
|
||||||
Det = Resource.Det ;
|
Det = Resource.Det ;
|
||||||
Prep = Resource.Prep ;
|
Prep = Resource.Prep ;
|
||||||
|
Num = Resource.Num ;
|
||||||
|
|
||||||
lin
|
lin
|
||||||
PhrS = Resource.IndicPhrase ;
|
PhrS = Resource.IndicPhrase ;
|
||||||
@@ -63,15 +64,76 @@ incomplete concrete ShallowI of Shallow = open (Resource = Resource) in {
|
|||||||
|
|
||||||
ModNoun a n = Resource.ModAdj (Resource.AdjP1 a) n ;
|
ModNoun a n = Resource.ModAdj (Resource.AdjP1 a) n ;
|
||||||
PrepNP = Resource.PrepNP ;
|
PrepNP = Resource.PrepNP ;
|
||||||
PrepNoun f p x = Resource.AdvCN f (Resource.PrepNP p x) ;
|
AdvNoun f a = Resource.AdvCN f a ;
|
||||||
NounN = Resource.UseN ;
|
NounN = Resource.UseN ;
|
||||||
CNNoun n = n ;
|
CNNoun n = n ;
|
||||||
|
|
||||||
AllNP = Resource.DetNP (Resource.AllNumDet Resource.NoNum) ;
|
DetNP = Resource.DetNP ;
|
||||||
EveryNP = Resource.DetNP Resource.EveryDet ;
|
|
||||||
DefNP = Resource.DefOneNP ;
|
DefNP = Resource.DefOneNP ;
|
||||||
IndefNP = Resource.IndefOneNP ;
|
IndefNP = Resource.IndefOneNP ;
|
||||||
UsePN = Resource.UsePN ;
|
UsePN = Resource.UsePN ;
|
||||||
|
|
||||||
PossessPrep = Resource.PossessPrep ;
|
-- created in hugs from gf Warning lines by:
|
||||||
|
-- do {s <- readFile "koe2" ; mapM_ (appendFile "koe3" . (\f -> f ++ " = Resource." ++ f ++ " ;\n") . last . words) (lines s)}
|
||||||
|
|
||||||
|
AfterPrep = Resource.AfterPrep ;
|
||||||
|
AgentPrep = Resource.AgentPrep ;
|
||||||
|
AllMassDet = Resource.AllMassDet ;
|
||||||
|
AllNumDet = Resource.AllNumDet ;
|
||||||
|
AnyDet = Resource.AnyDet ;
|
||||||
|
AnyNumDet = Resource.AnyNumDet ;
|
||||||
|
BeforePrep = Resource.BeforePrep ;
|
||||||
|
BehindPrep = Resource.BehindPrep ;
|
||||||
|
BetweenPrep = Resource.BetweenPrep ;
|
||||||
|
ByMeansPrep = Resource.ByMeansPrep ;
|
||||||
|
DuringPrep = Resource.DuringPrep ;
|
||||||
|
EveryDet = Resource.EveryDet ;
|
||||||
|
EverybodyNP = Resource.EverybodyNP ;
|
||||||
|
EverythingNP = Resource.EverythingNP ;
|
||||||
|
FromPrep = Resource.FromPrep ;
|
||||||
|
HeNP = Resource.HeNP ;
|
||||||
|
INP = Resource.INP ;
|
||||||
|
InFrontPrep = Resource.InFrontPrep ;
|
||||||
|
InPrep = Resource.InPrep ;
|
||||||
|
ItNP = Resource.ItNP ;
|
||||||
|
ManyDet = Resource.ManyDet ;
|
||||||
|
MostDet = Resource.MostDet ;
|
||||||
|
MostsDet = Resource.MostsDet ;
|
||||||
|
MuchDet = Resource.MuchDet ;
|
||||||
|
NoDet = Resource.NoDet ;
|
||||||
|
NoNum = Resource.NoNum ;
|
||||||
|
NoNumDet = Resource.NoNumDet ;
|
||||||
|
NobodyNP = Resource.NobodyNP ;
|
||||||
|
NothingNP = Resource.NothingNP ;
|
||||||
|
OnPrep = Resource.OnPrep ;
|
||||||
|
PartPrep = Resource.PartPrep ;
|
||||||
|
PhrNo = Resource.PhrNo ;
|
||||||
|
PhrYes = Resource.PhrYes ;
|
||||||
|
PossessPrep = Resource.PossessPrep ;
|
||||||
|
SheNP = Resource.SheNP ;
|
||||||
|
SomeDet = Resource.SomeDet ;
|
||||||
|
SomeNumDet = Resource.SomeNumDet ;
|
||||||
|
SomebodyNP = Resource.SomebodyNP ;
|
||||||
|
SomethingNP = Resource.SomethingNP ;
|
||||||
|
ThatDet = Resource.ThatDet ;
|
||||||
|
ThatNP = Resource.ThatNP ;
|
||||||
|
TheseNumDet = Resource.TheseNumDet ;
|
||||||
|
TheseNumNP = Resource.TheseNumNP ;
|
||||||
|
TheyNP = Resource.TheyNP ;
|
||||||
|
ThisDet = Resource.ThisDet ;
|
||||||
|
ThisNP = Resource.ThisNP ;
|
||||||
|
ThoseNumDet = Resource.ThoseNumDet ;
|
||||||
|
ThoseNumNP = Resource.ThoseNumNP ;
|
||||||
|
ThouNP = Resource.ThouNP ;
|
||||||
|
ThroughPrep = Resource.ThroughPrep ;
|
||||||
|
ToPrep = Resource.ToPrep ;
|
||||||
|
UnderPrep = Resource.UnderPrep ;
|
||||||
|
WeNumNP = Resource.WeNumNP ;
|
||||||
|
WhichDet = Resource.WhichDet ;
|
||||||
|
WhichNumDet = Resource.WhichNumDet ;
|
||||||
|
WithPrep = Resource.WithPrep ;
|
||||||
|
WithoutPrep = Resource.WithoutPrep ;
|
||||||
|
YeNumNP = Resource.YeNumNP ;
|
||||||
|
YouNP = Resource.YouNP ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
48
src/GF/CF/CFtoSRG.hs
Normal file
48
src/GF/CF/CFtoSRG.hs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{-
|
||||||
|
**************************************************************
|
||||||
|
GF Module
|
||||||
|
|
||||||
|
Description : This module prints a CF as a SRG (Speech
|
||||||
|
Recognition Grammar).
|
||||||
|
|
||||||
|
Author : Markus Forsberg (markus@cs.chalmers.se)
|
||||||
|
|
||||||
|
License : GPL (GNU General Public License)
|
||||||
|
|
||||||
|
Created : 21 January, 2001
|
||||||
|
|
||||||
|
Modified : 16 April, 2004 by Aarne Ranta for GF 2
|
||||||
|
**************************************************************
|
||||||
|
-}
|
||||||
|
|
||||||
|
module CFtoSRG where
|
||||||
|
|
||||||
|
import Operations
|
||||||
|
import CF
|
||||||
|
import CFIdent
|
||||||
|
---import UseGrammar
|
||||||
|
import PPrCF
|
||||||
|
import List (intersperse)
|
||||||
|
|
||||||
|
header :: String
|
||||||
|
header = unlines ["#ABNF 1.0 ISO-8859-1;\n",
|
||||||
|
"language en;",
|
||||||
|
"mode voice;",
|
||||||
|
"root $Main;",
|
||||||
|
"meta \"author\" is \"Grammatical Framework\";\n"]
|
||||||
|
|
||||||
|
prSRG :: CF -> String
|
||||||
|
prSRG cf = (header ++) $ prSRGC (catsOfCF cf) cf
|
||||||
|
|
||||||
|
prSRGC :: [CFCat] -> CF -> String
|
||||||
|
prSRGC [] _ = []
|
||||||
|
prSRGC (c:cs) cf = "$" ++ prCFCat c ++ " = " ++ items ++ ";\n"++ prSRGC cs cf
|
||||||
|
where items = concat $ intersperse " | " $
|
||||||
|
map f $ map valItemsCF (rulesForCFCat cf c)
|
||||||
|
f [] = "$NULL"
|
||||||
|
f xs = unwords $ map prSRGItem xs
|
||||||
|
|
||||||
|
prSRGItem :: CFItem -> [Char]
|
||||||
|
prSRGItem (CFNonterm c) = "$" ++ prCFCat c
|
||||||
|
prSRGItem (CFTerm a) = prRegExp a
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ import PPrCF
|
|||||||
import PrLBNF
|
import PrLBNF
|
||||||
import PrGrammar
|
import PrGrammar
|
||||||
import MkGFC
|
import MkGFC
|
||||||
|
import CFtoSRG
|
||||||
|
|
||||||
import Zipper
|
import Zipper
|
||||||
|
|
||||||
@@ -145,6 +146,7 @@ customGrammarPrinter =
|
|||||||
[
|
[
|
||||||
(strCI "gfc", prCanon . stateGrammarST) -- DEFAULT
|
(strCI "gfc", prCanon . stateGrammarST) -- DEFAULT
|
||||||
,(strCI "cf", prCF . stateCF)
|
,(strCI "cf", prCF . stateCF)
|
||||||
|
,(strCI "srg", prSRG . stateCF)
|
||||||
,(strCI "lbnf", prLBNF . stateCF)
|
,(strCI "lbnf", prLBNF . stateCF)
|
||||||
,(strCI "morpho", prMorpho . stateMorpho)
|
,(strCI "morpho", prMorpho . stateMorpho)
|
||||||
,(strCI "fullform",prFullForm . stateMorpho)
|
,(strCI "fullform",prFullForm . stateMorpho)
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ q, quit: q
|
|||||||
-printer=gf GF grammar
|
-printer=gf GF grammar
|
||||||
-printer=cf context-free grammar
|
-printer=cf context-free grammar
|
||||||
*-printer=happy source file for Happy parser generator
|
*-printer=happy source file for Happy parser generator
|
||||||
*-printer=srg speech recognition grammar
|
-printer=srg speech recognition grammar
|
||||||
*-printer=haskell abstract syntax in Haskell, with transl to/from GF
|
*-printer=haskell abstract syntax in Haskell, with transl to/from GF
|
||||||
-printer=morpho full-form lexicon, long format
|
-printer=morpho full-form lexicon, long format
|
||||||
*-printer=latex LaTeX file (for the tg command)
|
*-printer=latex LaTeX file (for the tg command)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module Today where today = "Tue Apr 13 13:53:49 CEST 2004"
|
module Today where today = "Fri Apr 16 18:06:59 CEST 2004"
|
||||||
|
|||||||
Reference in New Issue
Block a user