forked from GitHub/gf-core
adjusting doc on gfe
This commit is contained in:
@@ -20,8 +20,8 @@ converted to <tt>.gf</tt> files by the command
|
||||
<pre>
|
||||
gf -makeconcrete File.gfe
|
||||
</pre>
|
||||
See <a href="../lib/resource/doc/examples/QuestionsExI.gfe">
|
||||
<tt>../lib/resource/doc/examples/QuestionsExI.gfe</tt></a>
|
||||
See <a href="../lib/resource/doc/examples/QuestionsI.gfe">
|
||||
<tt>../lib/resource/doc/examples/QuestionsI.gfe</tt></a>
|
||||
for an example.
|
||||
|
||||
<p>
|
||||
|
||||
@@ -20,6 +20,12 @@ May 17, 2005.
|
||||
|
||||
</p><h2>News</h2>
|
||||
|
||||
<i>June 3, 2005</i>. Started a page on
|
||||
<a href="doc/gf-history.html">history of changes</a>.
|
||||
These changes will appear soon in releases.
|
||||
|
||||
<p>
|
||||
|
||||
<i>May 17, 2005</i>. Version 2.2 released. See
|
||||
<a href="doc/gf2.2-highlights.html">highlights</a>.
|
||||
Download from
|
||||
|
||||
20
lib/resource/doc/example/HandQuestionsI.gf
Normal file
20
lib/resource/doc/example/HandQuestionsI.gf
Normal file
@@ -0,0 +1,20 @@
|
||||
--# -path=.:resource/abstract:resource/../prelude
|
||||
|
||||
-- Language-independent question grammar parametrized on Resource.
|
||||
|
||||
incomplete concrete QuestionsI of Questions = open Resource in {
|
||||
lincat
|
||||
Phrase = Phr ;
|
||||
Entity = N ;
|
||||
Action = V2 ;
|
||||
lin
|
||||
Who act obj =
|
||||
QuestPhrase (UseQCl (PosTP TPresent ASimul)
|
||||
(QPredV2 who8one_IP act (IndefNumNP NoNum (UseN obj)))) ;
|
||||
Whom subj act =
|
||||
QuestPhrase (UseQCl (PosTP TPresent ASimul)
|
||||
(IntSlash who8one_IP (SlashV2 (DefOneNP (UseN subj)) act))) ;
|
||||
Answer subj act obj =
|
||||
IndicPhrase (UseCl (PosTP TPresent ASimul)
|
||||
(SPredV2 (DefOneNP (UseN subj)) act (IndefNumNP NoNum (UseN obj)))) ;
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
concrete QuestionsEng of Questions = QuestionsExI with
|
||||
concrete QuestionsEng of Questions = QuestionsI with
|
||||
(Resource = ResourceEng) ;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
--# -resource=../../langeng.gfcm
|
||||
|
||||
-- to compile: gf -makeconcrete QuestionsExI.gfe
|
||||
|
||||
incomplete concrete QuestionsExI of Questions = open Resource in {
|
||||
lincat
|
||||
Phrase = Phr ;
|
||||
Entity = N ;
|
||||
Action = V2 ;
|
||||
|
||||
lin Who love_V2 man_N = in Phr "who loves the men?" ;
|
||||
lin Whom man_N love_V2 = in Phr "whom does the man love?" ;
|
||||
lin Answer woman_N love_V2 man_N = in Phr "the woman loves the man." ;
|
||||
|
||||
}
|
||||
@@ -1,20 +1,15 @@
|
||||
--# -path=.:resource/abstract:resource/../prelude
|
||||
--# -resource=../../english/LangEng.gf
|
||||
|
||||
-- Language-independent question grammar parametrized on Resource.
|
||||
-- to compile: gf -makeconcrete QuestionsI.gfe
|
||||
|
||||
incomplete concrete QuestionsI of Questions = open Resource in {
|
||||
lincat
|
||||
Phrase = Phr ;
|
||||
Entity = N ;
|
||||
Action = V2 ;
|
||||
lin
|
||||
Who act obj =
|
||||
QuestPhrase (UseQCl (PosTP TPresent ASimul)
|
||||
(QPredV2 who8one_IP act (IndefNumNP NoNum (UseN obj)))) ;
|
||||
Whom subj act =
|
||||
QuestPhrase (UseQCl (PosTP TPresent ASimul)
|
||||
(IntSlash who8one_IP (SlashV2 (DefOneNP (UseN subj)) act))) ;
|
||||
Answer subj act obj =
|
||||
IndicPhrase (UseCl (PosTP TPresent ASimul)
|
||||
(SPredV2 (DefOneNP (UseN subj)) act (IndefNumNP NoNum (UseN obj)))) ;
|
||||
|
||||
lin Who love_V2 man_N = QuestPhrase (UseQCl (PosTP TPresent ASimul) (QPredV2 who8one_IP love_V2 (IndefNumNP NoNum (UseN man_N)))) ;
|
||||
lin Whom man_N love_V2 = QuestPhrase (UseQCl (PosTP TPresent ASimul) (IntSlash who8many_IP (SlashV2 (DefOneNP (UseN man_N)) love_V2))) ; -- AMBIGUOUS
|
||||
lin Answer woman_N love_V2 man_N = IndicPhrase (UseCl (PosTP TPresent ASimul) (SPredV2 (DefOneNP (UseN woman_N)) love_V2 (IndefNumNP NoNum (UseN man_N)))) ;
|
||||
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ We build the abstract syntax in two phases:
|
||||
|
||||
The concrete syntax of English is built in three phases:
|
||||
<ul>
|
||||
<li> <a href="example/QuestionsI.gf">QuestionsI</a> is a parametrized module
|
||||
<li> <a href="example/HandQuestionsI.gf">QuestionsI</a> is a parametrized module
|
||||
using the API module <tt>Resource</tt>.
|
||||
<li> <a href="example/QuestionsEng.gf">QuestionsEng</a> is an instantiation
|
||||
of the API with <tt>ResourceEng</tt>.
|
||||
@@ -696,6 +696,27 @@ and then call GF with
|
||||
</pre>
|
||||
|
||||
|
||||
<!-- NEW -->
|
||||
<h2>Grammar writing by examples</h2>
|
||||
|
||||
(New in GF 3/6/2005)
|
||||
|
||||
<p>
|
||||
|
||||
You can use the resource grammar as a parser on a special file format,
|
||||
<tt>.gfe</tt> ("GF examples"). Here is the new source,
|
||||
<a href="example/QuestionsI.gfe">QuestionsI.gfe</a>, which
|
||||
generates
|
||||
<a href="example/QuestionsI.gf">QuestionsI.gf</a>,
|
||||
when you execute the command
|
||||
<pre>
|
||||
gf -makeconcrete QuestionsI.gfe
|
||||
</pre>
|
||||
Of course, the grammar of any language can be created by
|
||||
parsing any language, as long as they have a common resource API.
|
||||
The use of English resource is generally recommended, because it
|
||||
is smaller and faster to parse than the other languages.
|
||||
|
||||
|
||||
<!-- NEW -->
|
||||
<h2>Implementation details: the structure of low-level files</h2>
|
||||
|
||||
@@ -44,13 +44,15 @@ mkConcrete :: FilePath -> IO ()
|
||||
mkConcrete file = do
|
||||
cont <- liftM lines $ readFileIf file
|
||||
let res = getResPath cont
|
||||
egr <- appIOE $ optFile2grammar (options [useOptimizer "share"]) res --- for -mcfg
|
||||
egr <- appIOE $
|
||||
optFile2grammar (options [useOptimizer "share",fromSource,beSilent,notEmitCode]) res --- for -mcfg
|
||||
gr <- err (\s -> putStrLn s >> error "resource file rejected") return egr
|
||||
let abs = prt_ $ absId gr
|
||||
let parser cat = errVal ([],"No parse") .
|
||||
optParseArgErrMsg (options [newMParser, firstCat cat, beVerbose]) gr
|
||||
let morpho = isKnownWord gr
|
||||
let out = suffixFile "gf" $ justModuleName file
|
||||
writeFile out ""
|
||||
mapM_ (mkCnc out parser morpho) cont
|
||||
|
||||
getResPath :: [String] -> String
|
||||
|
||||
Reference in New Issue
Block a user