Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
APDPlat - Application Product Development Platform Copyright (c) 2013, 杨尚川, 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 <>.
对证据进行评分 【二元模型评分组件】 利用二元模型构造出问题的所有正则表达式 在证据中进行匹配,匹配1次得2分

public class BigramEvidenceScore implements EvidenceScore {
    private static final Logger LOG = LoggerFactory.getLogger(BigramEvidenceScore.class);
    private ScoreWeight scoreWeight = new ScoreWeight();
    public void setScoreWeight(ScoreWeight scoreWeight) {
        this. = scoreWeight;
    public void score(Question questionEvidence evidence) {
        .debug("Evidence 二元模型评分开始");
        List<StringquestionTerms = question.getTerms();
        List<Stringpatterns = new ArrayList<>();
        for (int i = 0; i < questionTerms.size() - 1; i++) {
            String pattern = questionTerms.get(i) + questionTerms.get(i + 1);
            .debug("二元模型表达式:" + pattern);
        String text = evidence.getTitle() + evidence.getSnippet();
        double score = 0;
        for (String pattern : patterns) {
            int count = Tools.countsForBigram(textpattern);
            if (count > 0) {
                .debug("模式: " + pattern + " 在文本中出现 " + count + "次");
                score = score + count * 2;
        score *= .getBigramEvidenceScoreWeight();
        .debug("Evidence 二元模型评分:" + score);
        .debug("Evidence 二元模型评分结束");
New to GrepCode? Check out our FAQ X