code: public static float evaluate(POSTagger tagger, String corpus)
      {
          int correct = 0, total = 0;
          IOUtil.LineIterator lineIterator = new IOUtil.LineIterator(corpus);
          for (String line : lineIterator)
          {
              Sentence sentence = Sentence.create(line);
              if (sentence == null) continue;
              String[][] wordTagArray = sentence.toWordTagArray();
              String[] prediction = tagger.tag(wordTagArray[0]);
              assert prediction.length == wordTagArray[1].length;
              total += prediction.length;
              for (int i = 0; i < prediction.length; i++)
              {
                  if (prediction[i].equals(wordTagArray[1][i]))
                      ++correct;
              }
          }
          if (total == 0) return 0;
          return correct / (float) total * 100;
      }
docs: 评估词性标注器的准确率
  
  @param tagger 词性标注器
  @param corpus 测试集
  @return Accuracy百分比