summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <unknown>2005-11-01 08:20:09 +0000
committeraarne <unknown>2005-11-01 08:20:09 +0000
commit27c65e985d1a0c23978239bd52342c766964b98b (patch)
tree66071f0b6ab585bf9941ff9fd819c684b838c1e8
parenta48236172fc24f32792d56675b0ef682d6119348 (diff)
doc of prob
-rw-r--r--doc/gf-history.html13
-rw-r--r--examples/TWA.cf1
-rw-r--r--src/GF/Probabilistic/Probabilistic.hs6
3 files changed, 17 insertions, 3 deletions
diff --git a/doc/gf-history.html b/doc/gf-history.html
index 193b18a50..5a50baa46 100644
--- a/doc/gf-history.html
+++ b/doc/gf-history.html
@@ -12,11 +12,24 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
</center>
+1/11 (AR) Yet another method for adding probabilities: append
+<tt> --# prob Double</tt> to the end of a line defining a function.
+This can be (1) a <tt>.cf</tt> rule (2) a <tt>fun</tt> rule, or
+(3) a <tt>lin</tt> rule. The probability is attached to the
+first identifier on the line.
+
+<p>
+
31/10 (AR) Probabilistic grammars. Probabilities can be used to
weight random generation (<tt>gr -prob</tt>) and to rank parse
results (<tt>p -prob</tt>). They are read from a separate file
(flag <tt>i -probs=File</tt>, format <tt>--# prob Fun Double</tt>)
or from the top-level grammar file itself (option <tt>i -prob</tt>).
+<br>
+As a by-product, the probabilistic random generation algorithm is
+available for any context-free abstract syntax. Use the flag
+<tt>gr -cf<&tt>. This algorithm is much more efficient than the
+old (more general) one.
<p>
diff --git a/examples/TWA.cf b/examples/TWA.cf
index 56b14dd2c..32ae7b73f 100644
--- a/examples/TWA.cf
+++ b/examples/TWA.cf
@@ -1,4 +1,5 @@
-- example of probabilistic grammar from Jurafsky & Martin p. 449
+-- AR 1/11/2005
PredVP. S ::= NP VP ; --# prob 0.80
PredAux. S ::= Aux NP VP ; --# prob 0.15
diff --git a/src/GF/Probabilistic/Probabilistic.hs b/src/GF/Probabilistic/Probabilistic.hs
index 1126776c8..5b5c6b2af 100644
--- a/src/GF/Probabilistic/Probabilistic.hs
+++ b/src/GF/Probabilistic/Probabilistic.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/11/01 09:10:54 $
+-- > CVS $Date: 2005/11/01 09:20:09 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.4 $
+-- > CVS $Revision: 1.5 $
--
-- Probabilistic abstract syntax. AR 30\/10\/2005
--
@@ -83,7 +83,7 @@ pProb s = case words s of
"--#":"prob":f:p:_ | isDouble p -> [(zIdent f, read p)]
f:ps@(g:rest) -> case span (/= "--#") ps of
(_,_:"prob":p:_) | isDouble p -> [(zIdent f', readD p)] where
- f' = if f=="fun" then ident g else ident f
+ f' = if elem f ["fun","lin","data"] then ident g else ident f
_ -> []
_ -> []
where