Next: , Previous: , Up: Auxiliary Programs   [Contents][Index]


8.4 pcfg-reach

The purpose of this program is debugging removing unreachable productions from a PCFG and simplifying it.

To remove unreachable productions from a PCFG, use the following command-line format:

$ pcfg-reach PCFG_FILE [ RETAIN_NONT_1 ... RETAIN_NONT_n ]

where PCFG_FILE is the name of a file with the PCFG, and RETAIN_NONT_1, ..., RETAIN_NONT_n are nonterminal symbols to retain in a resulting PCFG even if they are unreachable. See pcfg-generate-seq for the description of PCFG format.

Example:

$ cat >reachable.pcfg <<EOF
S: "s" A
 | A A
;

A: "b"
 | "a" "b"
;

B: "c"
 | "b" C
;

C: "e"
 | "d" B
;
EOF
$ pcfg-reach reachable.pcfg
S: "s" A
 | A A
;

A: "b"
 | "a" "b"
;

To remove unreachable productions from a PCFG and simplify it, use the command-line format

$ pcfg-reach --simplify PCFG_FILE [ RETAIN_NONT_1 ... RETAIN_NONT_n ]

Example:

$ cat >simplify.pcfg <<EOF
S: "a"
 | B
 | C "s" C "s" C
 | F F
;

B: "b"
 | "b" "b"
;

C: "c" ;
D: ;
E: "e" "e" "e" ;

F: D "d" D
 | "d"
 | "f" "f" E "f" "f"
;
EOF
$ pcfg-reach --simplify simplify.pcfg
S: "a"
 | "b"
 | "b" "b"
 | "c" "s" "c" "s" "c"
 | F F
;

F: "d"
 | "f" "f" "e" "e" "e" "f" "f"
;