Search in sources :

Example 1 with Evaluator

use of com.hankcs.hanlp.corpus.dependency.CoNll.Evaluator in project HanLP by hankcs.

the class TestParse method testEvaluate.

public void testEvaluate() throws Exception {
    testParse();
    LinkedList<CoNLLSentence> sentenceList = CoNLLLoader.loadSentenceList("D:\\Doc\\语料库\\依存分析训练数据\\THU\\dev.conll");
    Evaluator evaluator = new Evaluator();
    int id = 1;
    for (CoNLLSentence sentence : sentenceList) {
        System.out.printf("%d / %d...", id++, sentenceList.size());
        long start = System.currentTimeMillis();
        List<Term> termList = new LinkedList<Term>();
        for (CoNLLWord word : sentence.word) {
            termList.add(new Term(word.LEMMA, Nature.valueOf(word.POSTAG)));
        }
        CoNLLSentence out = CRFDependencyParser.compute(termList);
        evaluator.e(sentence, out);
        System.out.println("done in " + (System.currentTimeMillis() - start) + " ms.");
    }
    System.out.println(evaluator);
}
Also used : CoNLLWord(com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLWord) CoNLLSentence(com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLSentence) Term(com.hankcs.hanlp.seg.common.Term) Evaluator(com.hankcs.hanlp.corpus.dependency.CoNll.Evaluator) LinkedList(java.util.LinkedList)

Aggregations

CoNLLSentence (com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLSentence)1 CoNLLWord (com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLWord)1 Evaluator (com.hankcs.hanlp.corpus.dependency.CoNll.Evaluator)1 Term (com.hankcs.hanlp.seg.common.Term)1 LinkedList (java.util.LinkedList)1