2008-05-14 16:23:58 +04:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "ScoreData.h"
|
2008-05-20 18:33:47 +04:00
|
|
|
#include "Data.h"
|
2008-05-15 20:03:49 +04:00
|
|
|
#include "Scorer.h"
|
2008-05-27 20:50:52 +04:00
|
|
|
#include "ScorerFactory.h"
|
2008-05-14 16:23:58 +04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
cout << "Testing the scorer" << endl;
|
|
|
|
//BleuScorer bs("test-scorer-data/cppstats.feats.opt");;
|
|
|
|
vector<string> references;
|
|
|
|
references.push_back("test_scorer_data/reference.txt");
|
|
|
|
//bs.prepare(references, "test-scorer-data/nbest.out");
|
2008-05-14 23:47:34 +04:00
|
|
|
Scorer* scorer = new BleuScorer();;
|
|
|
|
scorer->setReferenceFiles(references);
|
2008-05-20 18:33:47 +04:00
|
|
|
Data d(*scorer);
|
|
|
|
d.loadnbest("test_scorer_data/nbest.out");
|
2008-05-14 20:31:22 +04:00
|
|
|
//sd.savetxt();
|
|
|
|
|
2008-05-14 23:47:34 +04:00
|
|
|
//calculate two bleu scores, nbest and a diff
|
2008-05-20 18:33:47 +04:00
|
|
|
ScoreData* sd=d.getScoreData();
|
|
|
|
scorer->setScoreData(sd);
|
|
|
|
candidates_t candidates(sd->size());;
|
|
|
|
for (size_t i = 0; i < sd->size(); ++i) {
|
|
|
|
sd->get(i,0).savetxt("/dev/stdout");
|
2008-05-14 20:31:22 +04:00
|
|
|
}
|
|
|
|
|
2008-05-14 23:47:34 +04:00
|
|
|
diffs_t diffs;
|
|
|
|
diff_t diff;
|
|
|
|
diff.push_back(make_pair(1,2));
|
|
|
|
diff.push_back(make_pair(7,8));
|
|
|
|
diffs.push_back(diff);
|
|
|
|
|
2008-05-15 23:09:01 +04:00
|
|
|
statscores_t scores;
|
2008-05-14 23:47:34 +04:00
|
|
|
scorer->score(candidates,diffs,scores);
|
|
|
|
|
|
|
|
cout << "Bleus: " << scores[0] << " " << scores[1] << endl;
|
2008-05-15 18:13:32 +04:00
|
|
|
|
|
|
|
//try the per
|
|
|
|
scorer = new PerScorer();
|
2008-05-20 18:33:47 +04:00
|
|
|
Data pd(*scorer);
|
2008-05-15 18:13:32 +04:00
|
|
|
scorer->setReferenceFiles(references);
|
|
|
|
|
2008-05-20 18:33:47 +04:00
|
|
|
pd.loadnbest("test_scorer_data/nbest.out");
|
2008-05-15 18:13:32 +04:00
|
|
|
//sd.savetxt();
|
|
|
|
|
2008-05-20 18:33:47 +04:00
|
|
|
ScoreData* psd=pd.getScoreData();
|
|
|
|
scorer->setScoreData(psd);
|
|
|
|
for (size_t i = 0; i < psd->size(); ++i) {
|
|
|
|
psd->get(i,0).savetxt("/dev/stdout");
|
|
|
|
}
|
|
|
|
|
2008-05-15 18:13:32 +04:00
|
|
|
|
|
|
|
cout << "PER: " << scorer->score(candidates) << endl;
|
|
|
|
|
2008-05-14 16:23:58 +04:00
|
|
|
}
|