public static ProbCNFGrammar buildExampleGrammarOne(){
  ProbCNFGrammar g=new ProbCNFGrammar();
  ArrayList<Rule> rules=new ArrayList<Rule>();
  rules.add(new Rule("S","Y,Z",(float)0.10));
  rules.add(new Rule("B","B,D",(float)0.10));
  rules.add(new Rule("B","G,D",(float)0.10));
  rules.add(new Rule("C","E,C",(float)0.10));
  rules.add(new Rule("C","E,H",(float)0.10));
  rules.add(new Rule("E","M,N",(float)0.10));
  rules.add(new Rule("D","M,N",(float)0.10));
  rules.add(new Rule("Y","E,C",(float)0.10));
  rules.add(new Rule("Z","E,C",(float)0.10));
  rules.add(new Rule("M","m",(float)1.0));
  rules.add(new Rule("N","n",(float)1.0));
  rules.add(new Rule("B","a",(float)0.25));
  rules.add(new Rule("B","b",(float)0.25));
  rules.add(new Rule("B","c",(float)0.25));
  rules.add(new Rule("B","d",(float)0.25));
  rules.add(new Rule("G","a",(float)0.50));
  rules.add(new Rule("G","d",(float)0.50));
  rules.add(new Rule("C","x",(float)0.20));
  rules.add(new Rule("C","y",(float)0.20));
  rules.add(new Rule("C","z",(float)0.60));
  rules.add(new Rule("H","u",(float)0.50));
  rules.add(new Rule("H","z",(float)0.50));
  if (!g.addRules(rules)) {
    return null;
  }
  return g;
}

public static ProbCNFGrammar buildExampleGrammarOne ( ) { ProbCNFGrammar g = new ProbCNFGrammar ( ) ; ArrayList < Rule > rules = new ArrayList < Rule > ( ) ; rules . add ( new Rule ( "S" , "Y,Z" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "B" , "B,D" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "B" , "G,D" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "C" , "E,C" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "C" , "E,H" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "E" , "M,N" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "D" , "M,N" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "Y" , "E,C" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "Z" , "E,C" , ( float ) 0.10 ) ) ; rules . add ( new Rule ( "M" , "m" , ( float ) 1.0 ) ) ; rules . add ( new Rule ( "N" , "n" , ( float ) 1.0 ) ) ; rules . add ( new Rule ( "B" , "a" , ( float ) 0.25 ) ) ; rules . add ( new Rule ( "B" , "b" , ( float ) 0.25 ) ) ; rules . add ( new Rule ( "B" , "c" , ( float ) 0.25 ) ) ; rules . add ( new Rule ( "B" , "d" , ( float ) 0.25 ) ) ; rules . add ( new Rule ( "G" , "a" , ( float ) 0.50 ) ) ; rules . add ( new Rule ( "G" , "d" , ( float ) 0.50 ) ) ; rules . add ( new Rule ( "C" , "x" , ( float ) 0.20 ) ) ; rules . add ( new Rule ( "C" , "y" , ( float ) 0.20 ) ) ; rules . add ( new Rule ( "C" , "z" , ( float ) 0.60 ) ) ; rules . add ( new Rule ( "H" , "u" , ( float ) 0.50 ) ) ; rules . add ( new Rule ( "H" , "z" , ( float ) 0.50 ) ) ; if ( ! g . addRules ( rules ) ) { return null ; } return g ; }
an elementary chomsky - normal - form grammar for simple testing and demonstrating . this type of grammar is seen more in computing theory classes , and does not mock a subset of english phrase - structure .
