From 9bde56ed23b4b97f8193f9f8f582f18086ff17c1 Mon Sep 17 00:00:00 2001
From: Patrick Simianer
Date: Fri, 23 Sep 2011 20:53:15 +0200
Subject: begin refactoring
---
dtrain/dtest.cc | 94 ---------------------------------------------------------
1 file changed, 94 deletions(-)
delete mode 100644 dtrain/dtest.cc
(limited to 'dtrain/dtest.cc')
diff --git a/dtrain/dtest.cc b/dtrain/dtest.cc
deleted file mode 100644
index 36c880a3..00000000
--- a/dtrain/dtest.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "common.h"
-#include "kbestget.h"
-#include "util.h"
-
-
-/*
- * init
- *
- */
-bool
-init(int argc, char** argv, po::variables_map* conf)
-{
- int N;
- po::options_description opts( "Command Line Options" );
- opts.add_options()
- ( "decoder-config,c", po::value(), "configuration file for cdec" )
- ( "weights,w", po::value(), "weights file" )
- ( "ngrams,n", po::value(&N)->default_value(DTRAIN_DEFAULT_N), "N for Ngrams (default 5)" );
- po::options_description cmdline_options;
- cmdline_options.add(opts);
- po::store( parse_command_line(argc, argv, cmdline_options), *conf );
- po::notify( *conf );
- if ( ! (conf->count("decoder-config") || conf->count("weights")) ) {
- cerr << cmdline_options << endl;
- return false;
- }
- return true;
-}
-
-
-/*
- * main
- *
- */
-int
-main(int argc, char** argv)
-{
- SetSilent( true );
- po::variables_map conf;
- if ( !init(argc, argv, &conf) ) return 1;
- register_feature_functions();
- size_t k = 1;
- ReadFile ini_rf( conf["decoder-config"].as() );
- Decoder decoder( ini_rf.stream() );
- KBestGetter observer( k, "no" );
- size_t N = conf["ngrams"].as();
-
- Weights weights;
- if ( conf.count("weights") ) weights.InitFromFile( conf["weights"].as() );
- vector w;
- weights.InitVector( &w );
- decoder.SetWeights( w );
-
- vector in_split, ref_strs;
- vector ref_ids;
- string in, psg;
- size_t sn = 0;
- double overall = 0.0;
- double overall1 = 0.0;
- double overall2 = 0.0;
- while( getline(cin, in) ) {
- in_split.clear();
- boost::split( in_split, in, boost::is_any_of("\t") );
- // grammar
- psg = boost::replace_all_copy( in_split[3], " __NEXT__RULE__ ", "\n" ); psg += "\n";
- decoder.SetSentenceGrammarFromString( psg );
- decoder.Decode( in_split[1], &observer );
- KBestList* kb = observer.GetKBest();
- // reference
- ref_strs.clear(); ref_ids.clear();
- boost::split( ref_strs, in_split[2], boost::is_any_of(" ") );
- register_and_convert( ref_strs, ref_ids );
- // scoring kbest
- double score = 0.0;
- double score1 = 0.0;
- double score2 = 0.0;
- NgramCounts counts = make_ngram_counts( ref_ids, kb->sents[0], N );
- score = smooth_bleu( counts, ref_ids.size(), kb->sents[0].size(), N );
- score1 = stupid_bleu( counts, ref_ids.size(), kb->sents[0].size(), N );
- score2 = bleu( counts, ref_ids.size(), kb->sents[0].size(), N );
- cout << TD::GetString( kb->sents[0] ) << endl;
- overall += score;
- overall1 += score1;
- overall2 += score2;
- sn += 1;
- }
- cerr << "Average score (smooth) : " << overall/(double)(sn+1) << endl;
- cerr << "Average score (stupid) : " << overall1/(double)(sn+1) << endl;
- cerr << "Average score (vanilla): " << overall2/(double)(sn+1) << endl;
- cerr << endl;
-
- return 0;
-}
-
--
cgit v1.2.3