Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
APDPlat - Application Product Development Platform Copyright (c) 2013, 杨尚川, yang-shangchuan@qq.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
package org.apdplat.qa.model;
候选答案集合 包含多个候选答案

Author(s):
杨尚川
public class CandidateAnswerCollection {
    private static final Logger LOG = LoggerFactory.getLogger(CandidateAnswerCollection.class);
    private final List<CandidateAnswercandidateAnswers = new ArrayList<>();
    public boolean isEmpty() {
        return .isEmpty();
    }

    
获取所有候选答案

Returns:
        //按CandidateAnswer的分值排序
        Collections.sort();
        Collections.reverse();
        return ;
    }
    public void showAll() {
        for (CandidateAnswer candidateAnswer : getAllCandidateAnswer()) {
            .debug(candidateAnswer.getAnswer() + " " + candidateAnswer.getScore());
        }
    }
    public void showTopN(int topN) {
        for (CandidateAnswer candidateAnswer : getTopNCandidateAnswer(topN)) {
            .debug(candidateAnswer.getAnswer() + " " + candidateAnswer.getScore());
        }
    }
    public List<CandidateAnswergetTopNCandidateAnswer(int topN) {
        //按CandidateAnswer的分值排序,返回topN
        List<CandidateAnswerresult = new ArrayList<>();
        Collections.sort();
        Collections.reverse();
        int len = .size();
        if (topN > len) {
            topN = len;
        }
        for (int i = 0; i < .size(); i++) {
            result.add(.get(i));
        }
        return result;
    }
    public void addAnswer(CandidateAnswer candidateAnswer) {
        if (!.contains(candidateAnswer)) {
            .add(candidateAnswer);
        }
    }
    public void removeAnswer(CandidateAnswer candidateAnswer) {
        .remove(candidateAnswer);
    }
New to GrepCode? Check out our FAQ X