mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
Merge branch 'master' of github.com:moses-smt/mosesdecoder
This commit is contained in:
commit
6182750b70
@ -114,8 +114,11 @@ void ChartCell::SortHypotheses()
|
||||
MapType::iterator iter;
|
||||
for (iter = m_hypoColl.begin(); iter != m_hypoColl.end(); ++iter) {
|
||||
ChartHypothesisCollection &coll = iter->second;
|
||||
coll.SortHypotheses();
|
||||
m_targetLabelSet.AddConstituent(iter->first, &coll.GetSortedHypotheses());
|
||||
|
||||
if (coll.GetSize()) {
|
||||
coll.SortHypotheses();
|
||||
m_targetLabelSet.AddConstituent(iter->first, &coll.GetSortedHypotheses());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,15 +163,9 @@ float ChartTranslationOptionList::GetBestScore(const ChartCellLabel *chartCell)
|
||||
{
|
||||
const HypoList *stack = chartCell->GetStack().cube;
|
||||
assert(stack);
|
||||
//assert(!stack->empty());
|
||||
if (stack->empty()) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
const ChartHypothesis &bestHypo = **(stack->begin());
|
||||
return bestHypo.GetTotalScore();
|
||||
} const ChartHypothesis &bestHypo = **(stack->begin());
|
||||
return bestHypo.GetTotalScore();
|
||||
assert(!stack->empty());
|
||||
const ChartHypothesis &bestHypo = **(stack->begin());
|
||||
return bestHypo.GetTotalScore();
|
||||
}
|
||||
|
||||
void ChartTranslationOptionList::Evaluate(const InputType &input, const InputPath &inputPath)
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <boost/thread.hpp>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
void GenericCandidate::readBin(FILE* f)
|
||||
@ -62,6 +64,17 @@ void Candidates::readBin(FILE* f)
|
||||
|
||||
const LabelId PrefixTreeMap::MagicWord = std::numeric_limits<LabelId>::max() - 1;
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
PrefixTreeMap::~PrefixTreeMap() {
|
||||
if(m_FileSrc) {
|
||||
fClose(m_FileSrc);
|
||||
}
|
||||
if(m_FileTgt) {
|
||||
fClose(m_FileTgt);
|
||||
}
|
||||
FreeMemory();
|
||||
}
|
||||
|
||||
|
||||
void PrefixTreeMap::FreeMemory()
|
||||
{
|
||||
@ -75,20 +88,21 @@ void PrefixTreeMap::FreeMemory()
|
||||
m_PtrPool.reset();
|
||||
}
|
||||
|
||||
static WordVoc* ReadVoc(const std::string& filename)
|
||||
WordVoc &ReadVoc(std::map<std::string,WordVoc> &vocs, const std::string& filename)
|
||||
{
|
||||
static std::map<std::string,WordVoc*> vocs;
|
||||
#ifdef WITH_THREADS
|
||||
boost::mutex mutex;
|
||||
boost::mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
std::map<std::string,WordVoc*>::iterator vi = vocs.find(filename);
|
||||
std::map<std::string,WordVoc>::iterator vi = vocs.find(filename);
|
||||
if (vi == vocs.end()) {
|
||||
WordVoc* voc = new WordVoc();
|
||||
voc->Read(filename);
|
||||
vocs[filename] = voc;
|
||||
WordVoc &voc = vocs[filename];
|
||||
voc.Read(filename);
|
||||
return voc;
|
||||
}
|
||||
else {
|
||||
return vi->second;
|
||||
}
|
||||
return vocs[filename];
|
||||
}
|
||||
|
||||
int PrefixTreeMap::Read(const std::string& fileNameStem, int numVocs)
|
||||
@ -133,7 +147,7 @@ int PrefixTreeMap::Read(const std::string& fileNameStem, int numVocs)
|
||||
sprintf(num, "%d", i);
|
||||
//m_Voc[i] = new WordVoc();
|
||||
//m_Voc[i]->Read(ifv + num);
|
||||
m_Voc[i] = ReadVoc(ifv + num);
|
||||
m_Voc[i] = &ReadVoc(m_vocs, ifv + num);
|
||||
}
|
||||
|
||||
TRACE_ERR("binary file loaded, default OFF_T: "<< PTF::getDefault()<<"\n");
|
||||
|
@ -99,18 +99,11 @@ public:
|
||||
PrefixTreeMap() : m_FileSrc(0), m_FileTgt(0) {
|
||||
PTF::setDefault(InvalidOffT);
|
||||
}
|
||||
~PrefixTreeMap() {
|
||||
if(m_FileSrc) {
|
||||
fClose(m_FileSrc);
|
||||
}
|
||||
if(m_FileTgt) {
|
||||
fClose(m_FileTgt);
|
||||
}
|
||||
FreeMemory();
|
||||
}
|
||||
~PrefixTreeMap();
|
||||
|
||||
public:
|
||||
static const LabelId MagicWord;
|
||||
public:
|
||||
|
||||
void FreeMemory();
|
||||
|
||||
int Read(const std::string& fileNameStem, int numVocs = -1);
|
||||
@ -135,6 +128,7 @@ private:
|
||||
|
||||
std::vector<WordVoc*> m_Voc;
|
||||
ObjectPool<PPimp> m_PtrPool;
|
||||
std::map<std::string,WordVoc> m_vocs;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -436,7 +436,8 @@ function ngram_summary() {
|
||||
$score_line = "";
|
||||
for($i=0;$i<count($each_score);$i++) {
|
||||
if (preg_match('/([\d\(\)\.\s]+) (BLEU[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match)) {
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (METEOR[\-c]*)/',$each_score[$i],$match)) {
|
||||
$header .= "<td>$match[2]</td>";
|
||||
$score_line .= "<td>$match[1]</td>";
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ function diff_analysis() {
|
||||
}
|
||||
print "</h4>";
|
||||
|
||||
?><script language="javascript" src="/javascripts/prototype.js"></script>
|
||||
<script language="javascript" src="/javascripts/scriptaculous.js"></script>
|
||||
?><script language="javascript" src="javascripts/prototype.js"></script>
|
||||
<script language="javascript" src="javascripts/scriptaculous.js"></script>
|
||||
<script>
|
||||
function diff(field,sort,count) {
|
||||
var url = '?analysis_diff=' + field + '_diff'
|
||||
@ -683,7 +683,8 @@ function ngram_summary_diff() {
|
||||
$each_score = explode(" ; ",$experiment[$idx?$id2:$id]->result[$set]);
|
||||
for($i=0;$i<count($each_score);$i++) {
|
||||
if (preg_match('/([\d\(\)\.\s]+) (BLEU[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match)) {
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (METEOR[\-c]*)/',$each_score[$i],$match)) {
|
||||
$score[$match[2]][$idx] = $match[1];
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ function head($title) {
|
||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html><head><title>'.$title.'</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script language="javascript" src="/javascripts/prototype.js"></script>
|
||||
<script language="javascript" src="/javascripts/scriptaculous.js"></script>
|
||||
<script language="javascript" src="javascripts/prototype.js"></script>
|
||||
<script language="javascript" src="javascripts/scriptaculous.js"></script>
|
||||
<script language="javascript" src="hierarchical-segmentation.js"></script>
|
||||
<script language="javascript" src="base64.js"></script>
|
||||
<link href="general.css" rel="stylesheet" type="text/css">
|
||||
@ -22,7 +22,8 @@ function head($title) {
|
||||
<body><h2>'.$title."</h2>\n";
|
||||
}
|
||||
|
||||
if (array_key_exists("setup",$_POST) || array_key_exists("setup",$_GET)) {
|
||||
if (array_key_exists("setStepStatus",$_GET)) { set_step_status($_GET["setStepStatus"]); }
|
||||
else if (array_key_exists("setup",$_POST) || array_key_exists("setup",$_GET)) {
|
||||
load_experiment_info();
|
||||
load_comment();
|
||||
|
||||
|
@ -295,7 +295,8 @@ function output_score($id,$info) {
|
||||
$each_score = explode(" ; ",$score);
|
||||
for($i=0;$i<count($each_score);$i++) {
|
||||
if (preg_match('/([\d\(\)\.\s]+) (BLEU[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match)) {
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (METEOR[\-c]*)/',$each_score[$i],$match)) {
|
||||
if ($i>0) { print "<BR>"; }
|
||||
$opened_a_tag = 0;
|
||||
if ($set != "avg") {
|
||||
|
@ -3,7 +3,7 @@ function sgviz($sentence) {
|
||||
global $setup,$dir,$id,$set;
|
||||
?><html><head><title>Search Graph Visualization, Sentence <?php $sentence ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script language="javascript" src="/javascripts/prototype.js"></script></head>
|
||||
<script language="javascript" src="javascripts/prototype.js"></script></head>
|
||||
<body><svg id="sg" height="500" width="900" xmlns="http://www.w3.org/2000/svg"><g id="chart"></g></svg>
|
||||
<script>
|
||||
var sg = document.getElementById("sg");
|
||||
|
Loading…
Reference in New Issue
Block a user