@Test public void evaluateCollocation(){ double expected = -7952.59350417; double actual = target.evaluateCollocation(nGram, new ArrayList<TreeMap<String, Object>>()); Assert.assertEquals(expected, actual, 1e-4); }
public double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output) { if(nGram.getLength() <= 1 ) { return 0; } else if(nGram.getLength() < 3) { return evaluateSubPhrase(nGram, output) - parameterSet.bigramThreshold; } else { double score = 0; for(int i = 0; i < nGram.getLength() - 2; ++i) { score += evaluateSubPhrase(nGram.getSubNGram(i, 3), output) - parameterSet.trigramThreshold; } return score/(nGram.getLength()-2); } }
BayesCollocationScorer implements ICollocationScorer { public double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output) { if(nGram.getLength() <= 1 ) { return 0; } else if(nGram.getLength() < 3) { return evaluateSubPhrase(nGram, output) - parameterSet.bigramThreshold; } else { double score = 0; for(int i = 0; i < nGram.getLength() - 2; ++i) { score += evaluateSubPhrase(nGram.getSubNGram(i, 3), output) - parameterSet.trigramThreshold; } return score/(nGram.getLength()-2); } } }
BayesCollocationScorer implements ICollocationScorer { public double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output) { if(nGram.getLength() <= 1 ) { return 0; } else if(nGram.getLength() < 3) { return evaluateSubPhrase(nGram, output) - parameterSet.bigramThreshold; } else { double score = 0; for(int i = 0; i < nGram.getLength() - 2; ++i) { score += evaluateSubPhrase(nGram.getSubNGram(i, 3), output) - parameterSet.trigramThreshold; } return score/(nGram.getLength()-2); } } BayesCollocationScorer(FrequencyMap frequencyMap, ScorerParameterSet parameterSet); }
BayesCollocationScorer implements ICollocationScorer { public double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output) { if(nGram.getLength() <= 1 ) { return 0; } else if(nGram.getLength() < 3) { return evaluateSubPhrase(nGram, output) - parameterSet.bigramThreshold; } else { double score = 0; for(int i = 0; i < nGram.getLength() - 2; ++i) { score += evaluateSubPhrase(nGram.getSubNGram(i, 3), output) - parameterSet.trigramThreshold; } return score/(nGram.getLength()-2); } } BayesCollocationScorer(FrequencyMap frequencyMap, ScorerParameterSet parameterSet); double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output); }
BayesCollocationScorer implements ICollocationScorer { public double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output) { if(nGram.getLength() <= 1 ) { return 0; } else if(nGram.getLength() < 3) { return evaluateSubPhrase(nGram, output) - parameterSet.bigramThreshold; } else { double score = 0; for(int i = 0; i < nGram.getLength() - 2; ++i) { score += evaluateSubPhrase(nGram.getSubNGram(i, 3), output) - parameterSet.trigramThreshold; } return score/(nGram.getLength()-2); } } BayesCollocationScorer(FrequencyMap frequencyMap, ScorerParameterSet parameterSet); double evaluateCollocation(NGram nGram, List<TreeMap<String, Object>> output);  }