*/
public Map<ScoreType, Double> computeNGramScore()
{
Map<ScoreType, Double> results = new HashMap<ScoreType, Double>();
MutableInt gramHit = new MutableInt(0);
MutableDouble gramScore = new MutableDouble(0);
// #------------------------------------------------
// # read model file and create model n-gram maps
int totalGramHit = 0;
int totalGramCount = 0;
double gramScoreBest = -1;
double gramScoreP = 0; //# precision
double gramScoreF = 0; //# f-measure
int totalGramCountP = 0;
Map<String, Integer> peer_grams = createNGram(peer, this.n);
if (DEBUG)
{
System.out.println(peer.getSourceFile());
System.out.println(peer.asText());
int i = 0;
System.out.print("[");
for (String key : peer_grams.keySet())
{
System.out.print(key + ":" + peer_grams.get(key).intValue());
if (i != peer_grams.size() - 1)
{
System.out.print("|");
}
}
System.out.println("]");
}
for (IRougeSummaryModel model : models)
{
Map<String, Integer> model_grams = createNGram(model, this.n);
if (DEBUG)
{
System.out.println(model.getSourceFile());
System.out.println(model.asText());
int i = 0;
System.out.print("[");
for (String key : model_grams.keySet())
{
System.out.print(key + ":" + model_grams.get(key).intValue());
if (i != model_grams.size() - 1)
{
System.out.print("|");
}
}
System.out.println("]");
}
ngramScore(model_grams, peer_grams, gramHit, gramScore);
switch (scoreMode)
{
case 'A':
case 'a':
{
totalGramHit += gramHit.intValue();
totalGramCount += model_grams.get("_cn_");
totalGramCountP += peer_grams.get("_cn_");
break;
}
case 'B':
case 'b':
{
if (gramScore.doubleValue() > gramScoreBest)
{
//# only take a better score (i.e. better match)
gramScoreBest = gramScore.doubleValue();
totalGramHit = gramHit.intValue();
totalGramCount = model_grams.get("_cn_");
totalGramCountP = peer_grams.get("_cn_");
}
break;
}
default:
{
System.out.println("Warning: Unknown scoring mode - using average mode");
totalGramHit += gramHit.intValue();
totalGramCount += model_grams.get("_cn_");
totalGramCountP += peer_grams.get("_cn_");
}
}
}