Esempio n. 1
0
    public void train(List<Tree<String>> trainTrees) {
      // TODO: before you generate your grammar, the training trees
      // need to be binarized so that rules are at most binary
      // Binarize the tree.
      List<Tree<String>> binarizedTrees = new ArrayList<Tree<String>>();

      for (Tree<String> trainTree : trainTrees) {
        Tree<String> newTree = TreeAnnotations.annotateTree(trainTree);
        binarizedTrees.add(newTree);
      }
      lexicon = new Lexicon(binarizedTrees);
      grammar = new Grammar(binarizedTrees);
      System.out.println("trained!!");
    }
    public void train(List<Tree<String>> trainTrees) {
      // TODO: before you generate your grammar, the training trees
      // need to be binarized so that rules are at most binary

      List<Tree<String>> annotatedTrees = new ArrayList<Tree<String>>();
      for (Tree<String> tree : trainTrees) {
        annotatedTrees.add(TreeAnnotations.annotateTree(tree));
      }

      /*
      System.out.println("trainTrees: " );
      for (Tree<String> tree: trainTrees)  System.out.println("  " + tree);
      System.out.println("annotatedTrees: " );
      for (Tree<String> tree: annotatedTrees)  System.out.println("  " + tree);
       */
      lexicon = new Lexicon(annotatedTrees);
      grammar = new Grammar(annotatedTrees);

      /*
      System.out.println("lexicon: " + lexicon.getAllTags());
      System.out.println("grammar: " + grammar);
      */
      // System.exit(-1);
    }