Пример #1
0
 public void train(List<Tree<String>> trainTrees) {
   lexicon = new Lexicon(trainTrees);
   knownParses = new CounterMap<List<String>, Tree<String>>();
   spanToCategories = new CounterMap<Integer, String>();
   for (Tree<String> trainTree : trainTrees) {
     List<String> tags = trainTree.getPreTerminalYield();
     knownParses.incrementCount(tags, trainTree, 1.0);
     tallySpans(trainTree, 0);
   }
 }
Пример #2
0
 /* Builds a lexicon from the observed tags in a list of training trees. */
 public Lexicon(List<Tree<String>> trainTrees) {
   for (Tree<String> trainTree : trainTrees) {
     List<String> words = trainTree.getYield();
     List<String> tags = trainTree.getPreTerminalYield();
     for (int position = 0; position < words.size(); position++) {
       String word = words.get(position);
       String tag = tags.get(position);
       tallyTagging(word, tag);
     }
   }
 }