forked from GitHub/gf-core
printing option -api in the eb command
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
concrete QuestionsEng of Questions = QuestionsI with
|
concrete QuestionsEng of Questions = QuestionsI with
|
||||||
(Lang = LangEng) ;
|
(Syntax = SyntaxEng) ;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- to compile: echo "eb -file=QuestionsI.gfe" -probs=probs | gf $GF_LIB_PATH/present/LangEng.gfo
|
-- to compile: echo "eb -probs=probs -api -file=QuestionsI.gfe" | gf $GF_LIB_PATH/present/LangEng.gfo
|
||||||
-- or use directly gf <mkAnimals.gfs
|
-- or use directly gf <mkAnimals.gfs
|
||||||
|
|
||||||
incomplete concrete QuestionsI of Questions = open Lang in {
|
incomplete concrete QuestionsI of Questions = open Syntax in {
|
||||||
lincat
|
lincat
|
||||||
Phrase = Utt ;
|
Phrase = Utt ;
|
||||||
Entity = N ;
|
Entity = N ;
|
||||||
@@ -9,21 +9,20 @@ incomplete concrete QuestionsI of Questions = open Lang in {
|
|||||||
|
|
||||||
lin
|
lin
|
||||||
Who love_V2 man_N = (
|
Who love_V2 man_N = (
|
||||||
--- WARNING: ambiguous example who loves men
|
mkUtt (mkQCl (mkQCl whoSg_IP (mkVP (mkVPSlash love_V2) (mkNP a_Art plNum man_N)))) -- 4.548068040131532e-11
|
||||||
UttQS (UseQCl (TTAnt TPres ASimul) PPos (QuestVP whoSg_IP (ComplSlash (SlashV2a love_V2) (DetCN (DetQuant IndefArt NumPl) (UseN man_N))))) -- 2.122431752061382e-11
|
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
Whom man_N love_V2 = (
|
Whom man_N love_V2 = (
|
||||||
--- WARNING: ambiguous example whom does the man love
|
--- WARNING: ambiguous example whom does the man love
|
||||||
UttQS (UseQCl (TTAnt TPres ASimul) PPos (QuestSlash whoPl_IP (SlashVP (DetCN (DetQuant DefArt NumSg) (UseN man_N)) (SlashV2a love_V2)))) -- 1.3265198450383634e-11
|
mkUtt (mkQCl (mkQCl whoPl_IP (mkClSlash (mkNP the_Art man_N) (mkVPSlash love_V2)))) -- 2.8425425250822075e-11
|
||||||
--- UttQS (UseQCl (TTAnt TPres ASimul) PPos (QuestSlash whoSg_IP (SlashVP (DetCN (DetQuant DefArt NumSg) (UseN man_N)) (SlashV2a love_V2)))) -- 1.3265198450383634e-11
|
--- mkUtt (mkQCl (mkQCl whoSg_IP (mkClSlash (mkNP the_Art man_N) (mkVPSlash love_V2)))) -- 2.8425425250822075e-11
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
Answer woman_N love_V2 man_N = (
|
Answer woman_N love_V2 man_N = (
|
||||||
--- WARNING: ambiguous example the woman loves men
|
--- WARNING: ambiguous example the woman loves men
|
||||||
UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN woman_N)) (ComplSlash (SlashV2a love_V2) (DetCN (DetQuant IndefArt NumPl) (UseN man_N))))) -- 1.1637456560533483e-14
|
mkUtt (mkCl (mkCl (mkNP the_Art woman_N) (mkVP (mkVPSlash love_V2) (mkNP a_Art plNum man_N)))) -- 3.273034657650043e-14
|
||||||
--- UttNP (DetCN (DetQuant DefArt NumSg) (ApposCN (ApposCN (UseN woman_N) (DetCN (DetQuant IndefArt NumPl) (UseN love_N))) (DetCN (DetQuant IndefArt NumPl) (UseN man_N)))) -- 2.018579347059343e-20
|
--- mkUtt (mkNP the_Art (mkCN (mkCN (mkCN woman_N) (mkNP a_Art plNum love_N)) (mkNP a_Art plNum man_N))) -- 1.6623594622841657e-20
|
||||||
--- UttNP (DetCN (DetQuant DefArt NumSg) (ApposCN (UseN woman_N) (DetCN (DetQuant IndefArt NumPl) (ApposCN (UseN love_N) (DetCN (DetQuant IndefArt NumPl) (UseN man_N)))))) -- 2.018579347059343e-20
|
--- mkUtt (mkNP the_Art (mkCN (mkCN woman_N) (mkNP a_Art plNum (mkCN (mkCN love_N) (mkNP a_Art plNum man_N))))) -- 1.6623594622841657e-20
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- to compile: echo "eb -file=QuestionsI.gfe" | gf $GF_LIB_PATH/present/LangEng.gfo
|
-- to compile: echo "eb -probs=probs -api -file=QuestionsI.gfe" | gf $GF_LIB_PATH/present/LangEng.gfo
|
||||||
-- or use directly gf <mkAnimals.gfs
|
-- or use directly gf <mkAnimals.gfs
|
||||||
|
|
||||||
incomplete concrete QuestionsI of Questions = open Lang in {
|
incomplete concrete QuestionsI of Questions = open Syntax in {
|
||||||
lincat
|
lincat
|
||||||
Phrase = Utt ;
|
Phrase = Utt ;
|
||||||
Entity = N ;
|
Entity = N ;
|
||||||
@@ -9,7 +9,7 @@ incomplete concrete QuestionsI of Questions = open Lang in {
|
|||||||
|
|
||||||
lin
|
lin
|
||||||
Who love_V2 man_N = %ex Utt "who loves men" ;
|
Who love_V2 man_N = %ex Utt "who loves men" ;
|
||||||
Whom man_N love_V2 = %ex Utt "whom does the man love and chase" ;
|
Whom man_N love_V2 = %ex Utt "whom does the man love" ;
|
||||||
Answer woman_N love_V2 man_N = %ex Utt "the woman loves and chases men" ;
|
Answer woman_N love_V2 man_N = %ex Utt "the woman loves men" ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,9 @@ allCommands env@(pgf, mos) = Map.fromList [
|
|||||||
"gr and rt. Notice that the command doesn't change the environment,",
|
"gr and rt. Notice that the command doesn't change the environment,",
|
||||||
"but the resulting .gf file must be imported separately."
|
"but the resulting .gf file must be imported separately."
|
||||||
],
|
],
|
||||||
|
options = [
|
||||||
|
("api","convert trees to overloaded API expressions (using Syntax not Lang)")
|
||||||
|
],
|
||||||
flags = [
|
flags = [
|
||||||
("file","the file to be converted (suffix .gfe must be given)"),
|
("file","the file to be converted (suffix .gfe must be given)"),
|
||||||
("lang","the language in which to parse"),
|
("lang","the language in which to parse"),
|
||||||
@@ -304,7 +307,8 @@ allCommands env@(pgf, mos) = Map.fromList [
|
|||||||
exec = \opts _ -> do
|
exec = \opts _ -> do
|
||||||
let file = optFile opts
|
let file = optFile opts
|
||||||
pgf <- optProbs opts pgf
|
pgf <- optProbs opts pgf
|
||||||
let conf = configureExBased pgf (optMorpho opts) (optLang opts)
|
let printer = if (isOpt "api" opts) then exprToAPI else (showExpr [])
|
||||||
|
let conf = configureExBased pgf (optMorpho opts) (optLang opts) printer
|
||||||
(file',ws) <- parseExamplesInGrammar conf file
|
(file',ws) <- parseExamplesInGrammar conf file
|
||||||
if null ws then return () else putStrLn ("unknown words: " ++ unwords ws)
|
if null ws then return () else putStrLn ("unknown words: " ++ unwords ws)
|
||||||
return (fromString ("wrote " ++ file')),
|
return (fromString ("wrote " ++ file')),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module GF.Compile.ExampleBased (
|
|||||||
import PGF
|
import PGF
|
||||||
import PGF.Probabilistic
|
import PGF.Probabilistic
|
||||||
import PGF.Morphology
|
import PGF.Morphology
|
||||||
|
import PGF.ToAPI
|
||||||
|
|
||||||
import Data.List
|
import Data.List
|
||||||
|
|
||||||
@@ -55,11 +56,16 @@ convertFile conf src file = do
|
|||||||
return []
|
return []
|
||||||
ParseOk ts ->
|
ParseOk ts ->
|
||||||
case rank ts of
|
case rank ts of
|
||||||
(t:tt) -> appv ("WARNING: ambiguous example " ++ ex) >>
|
(t:tt) -> do
|
||||||
appn t >> mapM_ (appn . (" --- " ++)) tt >> return []
|
if null tt
|
||||||
appn ")"
|
then return ()
|
||||||
|
else appv ("WARNING: ambiguous example " ++ ex)
|
||||||
|
appn t
|
||||||
|
mapM_ (appn . (" --- " ++)) tt
|
||||||
|
appn ")"
|
||||||
|
return []
|
||||||
return ws
|
return ws
|
||||||
rank ts = [showExpr [] t ++ " -- " ++ show p | (t,p) <- rankTreesByProbs pgf ts]
|
rank ts = [printExp conf t ++ " -- " ++ show p | (t,p) <- rankTreesByProbs pgf ts]
|
||||||
appf = appendFile file
|
appf = appendFile file
|
||||||
appn s = appf s >> appf "\n"
|
appn s = appf s >> appf "\n"
|
||||||
appv s = appn ("--- " ++ s) >> putStrLn s
|
appv s = appn ("--- " ++ s) >> putStrLn s
|
||||||
@@ -68,9 +74,10 @@ data ExConfiguration = ExConf {
|
|||||||
resource_pgf :: PGF,
|
resource_pgf :: PGF,
|
||||||
resource_morpho :: Morpho,
|
resource_morpho :: Morpho,
|
||||||
verbose :: Bool,
|
verbose :: Bool,
|
||||||
language :: Language
|
language :: Language,
|
||||||
|
printExp :: Tree -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
configureExBased :: PGF -> Morpho -> Language -> ExConfiguration
|
configureExBased :: PGF -> Morpho -> Language -> (Tree -> String) -> ExConfiguration
|
||||||
configureExBased pgf morpho lang = ExConf pgf morpho False lang
|
configureExBased pgf morpho lang pr = ExConf pgf morpho False lang pr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user