Remove unecessary headers; fix indentation.

This commit is contained in:
Tetsuo Kiso 2012-03-24 04:12:33 +09:00
parent 8a264801e3
commit 184b24b456
4 changed files with 17 additions and 25 deletions

View File

@ -40,8 +40,7 @@ vector<int> CapMicroOverlapping::prepareStats(const sentence_t& cand, const sent
float CapMicroOverlapping::calculateScore(const vector<int>& stats) const
{
if (stats.size() != 2)
{
if (stats.size() != 2) {
throw std::runtime_error("Size of stats vector has to be 2");
}
if (stats[1] == 0) return 1.0f;
@ -82,7 +81,7 @@ float CapMacroOverlapping::calculateScore(const vector<int>& stats) const
int clipped = stats[2 * i];
int refsize = stats[2 * i + 1];
if (refsize > 0) {
sum += clipped / (float) refsize;
sum += clipped / static_cast<float>(refsize);
++n;
}
}

View File

@ -7,7 +7,7 @@
#include <utility>
#include <vector>
// TODO: need to comments about this number.
// TODO: need comments about this number.
const int kMaxNOC = 30;
typedef std::pair<std::string, std::string> str_item_t;

View File

@ -75,19 +75,18 @@ void SemposScorer::prepareStats(size_t sid, const string& text, ScoreStats& entr
void SemposScorer::splitSentence(const string& sentence, str_sentence_t& splitSentence)
{
splitSentence.clear();
splitSentence.clear();
vector<string> tokens;
split(sentence, ' ', tokens);
for (vector<string>::iterator it = tokens.begin(); it != tokens.end(); ++it)
{
vector<string> factors;
split(*it, '|', factors);
if (factors.size() != 2) throw runtime_error("Sempos scorer accepts two factors (item|class)");
const string& item = factors[0];
const string& klass = factors[1];
splitSentence.push_back(make_pair(item, klass));
}
vector<string> tokens;
split(sentence, ' ', tokens);
for (vector<string>::iterator it = tokens.begin(); it != tokens.end(); ++it) {
vector<string> factors;
split(*it, '|', factors);
if (factors.size() != 2) throw runtime_error("Sempos scorer accepts two factors (item|class)");
const string& item = factors[0];
const string& klass = factors[1];
splitSentence.push_back(make_pair(item, klass));
}
}
void SemposScorer::encodeSentence(const str_sentence_t& sentence, sentence_t& encodedSentence)
@ -118,18 +117,14 @@ int SemposScorer::encodeSempos(const string& sempos)
{
if (sempos == "-") return -1;
encoding_it it = m_semposMap.find(sempos);
if (it == m_semposMap.end())
{
if (m_semposMap.size() == kMaxNOC)
{
if (it == m_semposMap.end()) {
if (m_semposMap.size() == kMaxNOC) {
throw std::runtime_error("Number of classes is greater than kMaxNOC");
}
const int classNumber = static_cast<int>(m_semposMap.size());
m_semposMap[sempos] = classNumber;
return classNumber;
}
else
{
} else {
return it->second;
}
}

View File

@ -7,8 +7,6 @@
#include <vector>
#include <boost/scoped_ptr.hpp>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
// NOTE: This header should be included in .cpp file