Example 3: A simple probabilistic context-free example (2)

The parser can be used by running:
java -jar stefs.jar
(or: java -classpath stefs.jar stefs.Interpreter).

Input:

// test 5: testing probabilistic grammars
// $Id: 5,v 1.1 2007/03/24 04:10:16 vlado Exp $

print "TEST 5\n"

set PPath P

[S P:#1=!Accumulator(0)] -> [NP P:#1] [VP P:#1].

[NP P:#1=!Accumulator(-0.91629073)] -> [N P:#1].          //ln 0.4
[NP P:#1=!Accumulator(-1.6094379) ] -> [N P:#1] [N P:#1]. //ln 0.2
[NP P:#1=!Accumulator(-0.91629073)] -> [D P:#1] [N P:#1]. //ln 0.4

[VP P:#1=!Accumulator(-0.69314718)] -> [V P:#1] [NP P:#1]. //ln 0.5
[VP P:#1=!Accumulator(-0.69314718)] -> [V P:#1] [PP P:#1]. //ln 0.5

[PP P:#1=!Accumulator(0)] -> [P P:#1] [NP P:#1]. //ln 1

[V P:!Accumulator(-1.2039728) ] -> like.  //ln 0.3
[V P:!Accumulator(-0.35667494)] -> flies. //ln 0.7

[P P:!Accumulator(0)] -> like. //ln 1

[N P:!Accumulator(-0.69314718)] -> time.  //ln 0.5
[N P:!Accumulator(-1.2039728) ] -> arrow. //ln 0.3
[N P:!Accumulator(-1.6094379) ] -> flies. //ln 0.2

[D P:!Accumulator(0) ] -> an. //ln 1

tokenize <s> time flies like an arrow </s>
parse
print parse trees
print BestParse

println "\n\nAll edges:\n"
foreachpassiveedge e 'println e + "\n"';

Output:

// test 5: testing probabilistic grammars
// $Id: 5,v 1.1 2007/03/24 04:10:16 vlado Exp $

print "TEST 5\n"

set PPath P

[S P:#1=!Accumulator(0)] -> [NP P:#1] [VP P:#1].

[NP P:#1=!Accumulator(-0.91629073)] -> [N P:#1].          //ln 0.4
[NP P:#1=!Accumulator(-1.6094379) ] -> [N P:#1] [N P:#1]. //ln 0.2
[NP P:#1=!Accumulator(-0.91629073)] -> [D P:#1] [N P:#1]. //ln 0.4

[VP P:#1=!Accumulator(-0.69314718)] -> [V P:#1] [NP P:#1]. //ln 0.5
[VP P:#1=!Accumulator(-0.69314718)] -> [V P:#1] [PP P:#1]. //ln 0.5

[PP P:#1=!Accumulator(0)] -> [P P:#1] [NP P:#1]. //ln 1

[V P:!Accumulator(-1.2039728) ] -> like.  //ln 0.3
[V P:!Accumulator(-0.35667494)] -> flies. //ln 0.7

[P P:!Accumulator(0)] -> like. //ln 1

[N P:!Accumulator(-0.69314718)] -> time.  //ln 0.5
[N P:!Accumulator(-1.2039728) ] -> arrow. //ln 0.3
[N P:!Accumulator(-1.6094379) ] -> flies. //ln 0.2

[D P:!Accumulator(0) ] -> an. //ln 1

tokenize <s> time flies like an arrow </s>
parse
print parse trees
print BestParse

println "\n\nAll edges:\n"
foreachpassiveedge e 'println e + "\n"';


© 2000-2007 Vlado Keselj, last update: March 27, 2007.