Next: , Previous: , Up: Examples   [Contents][Index]


Example 3

$ cat gram/3.pcfg

  S: A B
  ;
  
  A: "a" "b" "c"
   | "d" "c" "b" "a"
  ;
  
  B: "e"
   | "f" "e"
  ;

$ ./pcfg-generate-seq -i1 -n2000 -o seq/3-2k.seq gram/3.pcfg
$ ../scripts/mk-rg-vit.sh 6 6 2 >gram/3.rg
$ ./topdown -i1 -n5000 --det-niter-goal=50 --od=td-learn/3_det.rg  \
            --oo=td-learn/3.log gram/3.rg seq/3-2k.seq
$ ./topdown -i1 -n5000 --od=td-learn/3_out.rg --op=td-learn/3_out.pcfg  \
            --oo=- --simplify td-learn/3_det.rg seq/3-2k.seq

  Iteration 1:
  P: prob_gram 0.40992566, prob_term 0.56725727, prob_wpredict 0.79502085,
     prob_npredict 0.78240000, cycle_period 61
  T: prob_gram 0.40992566, prob_term 0.56725727, prob_wpredict 0.79502085,
     prob_npredict 0.78240000, cycle_period 61
  Finished.

$ cat td-learn/3_out.rg

  S: "a" . .
   | "b"
   | "c" . .
   | "e" . . . .
   | "f" . . . . .
   | "d" . . . ( [ "a" "d" ]
               | [ "b" "c" "e" ]
               | "f" .
               )
  ;

$ cat td-learn/3_out.pcfg

  S: "f" "e" "d" "c" "b" "a"  [0.12712713]  // 127  0.80250568
   | "a" "b" "c"              [0.15915916]  // 159  0.55241081
   | "e" "d" "c" "b" "a"      [0.19719720]  // 197  0.49884307
   | "e" "a" "b" "c" "f"      [0.11411411]  // 114  0.17593122
   | "f" "e" "a" "b" "c" "e"  [0.06006006]  // 60   0.14745296
   | "e" "a" "b" "c" "e"      [0.09909910]  // 99   0.10209655
   | "f" "e" "a" "b" "c" "f"  [0.05205205]  // 52   0.09883227
   | "d" "c" "b" "a" L2_1     [0.19119119]  // 191
  ;  // 999
  
  L2_1: "e"      [0.54210526]  // 103  0.55160321
      | "f" "e"  [0.45789474]  // 87   0.52205497
  ;  // 190

$ ./topdown -i-1 -n5000 --os=seq/3_random.seq --oo=- gram/3.rg seq/3-2k.seq

  [0]: prob_gram 0.09174307, prob_term 0.11068237, prob_wpredict 0.53279974,
       prob_npredict 0.40400000, cycle_period 993
  prob_epredict 0.40400000

$ ./topdown -i1 -n5000 --os=seq/3_predict.seq --oo=- td-learn/3_out.rg seq/3-2k.seq

  [0]: prob_gram 0.40992566, prob_term 0.56725727, prob_wpredict 0.79502085,
       prob_npredict 0.78240000, cycle_period 61
  prob_epredict 0.78240000

$ ./pcfg-predict-eval --prob-rand=0.40400000 gram/3.pcfg seq/3_predict.seq

  {
      "seq_len"              : 5000,
      "wpredict_max"         : 4001.50000000,
      "npredict_actual"      : 3912,
      "wpredict_rand"        : 2020.0,
      "prob_wpredict_max"    : 0.80030000,
      "prob_npredict_actual" : 0.78240000,
      "prob_npredict_rand"   : 0.40400000,
      "efficiency_rand, %"   : 95.5
  }