Skip to content
Snippets Groups Projects
Commit 7e8b84ee authored by Franck Dary's avatar Franck Dary
Browse files

Made sentid into an extra column

parent 23b452ce
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ class Config ...@@ -56,6 +56,7 @@ class Config
String state{"NONE"}; String state{"NONE"};
boost::circular_buffer<String> history{10}; boost::circular_buffer<String> history{10};
boost::circular_buffer<std::size_t> stack{50}; boost::circular_buffer<std::size_t> stack{50};
std::vector<std::string> extraColumns{isMultiColName, childsColName, sentIdColName, EOSColName};
protected : protected :
...@@ -145,6 +146,7 @@ class Config ...@@ -145,6 +146,7 @@ class Config
void addComment(); void addComment();
void setAppliableSplitTransitions(const std::vector<Transition *> & appliableSplitTransitions); void setAppliableSplitTransitions(const std::vector<Transition *> & appliableSplitTransitions);
const std::vector<Transition *> & getAppliableSplitTransitions() const; const std::vector<Transition *> & getAppliableSplitTransitions() const;
bool isExtraColumn(const std::string & colName) const;
}; };
#endif #endif
...@@ -28,25 +28,13 @@ void BaseConfig::readMCD(std::string_view mcdFilename) ...@@ -28,25 +28,13 @@ void BaseConfig::readMCD(std::string_view mcdFilename)
std::fclose(file); std::fclose(file);
if (colName2Index.count(isMultiColName)) for (auto & column : extraColumns)
util::myThrow(fmt::format("mcd '{}' must not contain column '{}'", mcdFilename, isMultiColName)); {
colIndex2Name.emplace_back(isMultiColName); if (colName2Index.count(column))
colName2Index.emplace(isMultiColName, colIndex2Name.size()-1); util::myThrow(fmt::format("mcd '{}' must not contain column '{}'", mcdFilename, column));
colIndex2Name.emplace_back(column);
if (colName2Index.count(childsColName)) colName2Index.emplace(column, colIndex2Name.size()-1);
util::myThrow(fmt::format("mcd '{}' must not contain column '{}'", mcdFilename, childsColName)); }
colIndex2Name.emplace_back(childsColName);
colName2Index.emplace(childsColName, colIndex2Name.size()-1);
if (colName2Index.count(sentIdColName))
util::myThrow(fmt::format("mcd '{}' must not contain column '{}'", mcdFilename, sentIdColName));
colIndex2Name.emplace_back(sentIdColName);
colName2Index.emplace(sentIdColName, colIndex2Name.size()-1);
if (colName2Index.count(EOSColName))
util::myThrow(fmt::format("mcd '{}' must not contain column '{}'", mcdFilename, EOSColName));
colIndex2Name.emplace_back(EOSColName);
colName2Index.emplace(EOSColName, colIndex2Name.size()-1);
} }
void BaseConfig::readRawInput(std::string_view rawFilename) void BaseConfig::readRawInput(std::string_view rawFilename)
......
...@@ -98,7 +98,7 @@ void Config::print(FILE * dest) const ...@@ -98,7 +98,7 @@ void Config::print(FILE * dest) const
} }
for (unsigned int i = 0; i < getNbColumns()-1; i++) for (unsigned int i = 0; i < getNbColumns()-1; i++)
{ {
if (getColName(i) == isMultiColName or getColName(i) == childsColName) if (isExtraColumn(getColName(i)) and getColName(i) != EOSColName)
{ {
if (i == getNbColumns()-2) if (i == getNbColumns()-2)
currentSequence.back().back() = '\n'; currentSequence.back().back() = '\n';
...@@ -146,7 +146,7 @@ void Config::printForDebug(FILE * dest) const ...@@ -146,7 +146,7 @@ void Config::printForDebug(FILE * dest) const
toPrint.back().emplace_back(""); toPrint.back().emplace_back("");
for (unsigned int i = 0; i < getNbColumns(); i++) for (unsigned int i = 0; i < getNbColumns(); i++)
{ {
if (getColName(i) == isMultiColName or getColName(i) == childsColName) if (isExtraColumn(getColName(i)) and getColName(i) != EOSColName)
continue; continue;
toPrint.back().emplace_back(getColName(i)); toPrint.back().emplace_back(getColName(i));
} }
...@@ -159,7 +159,7 @@ void Config::printForDebug(FILE * dest) const ...@@ -159,7 +159,7 @@ void Config::printForDebug(FILE * dest) const
toPrint.back().emplace_back(line == (int)wordIndex ? "=>" : ""); toPrint.back().emplace_back(line == (int)wordIndex ? "=>" : "");
for (unsigned int i = 0; i < getNbColumns(); i++) for (unsigned int i = 0; i < getNbColumns(); i++)
{ {
if (getColName(i) == isMultiColName or getColName(i) == childsColName) if (isExtraColumn(getColName(i)) and getColName(i) != EOSColName)
continue; continue;
std::string colContent = has(i,line,0) ? getAsFeature(i, line).get() : "?"; std::string colContent = has(i,line,0) ? getAsFeature(i, line).get() : "?";
std::string toPrintCol = colContent; std::string toPrintCol = colContent;
...@@ -563,6 +563,10 @@ void Config::addPredicted(const std::set<std::string> & predicted) ...@@ -563,6 +563,10 @@ void Config::addPredicted(const std::set<std::string> & predicted)
util::myThrow(fmt::format("unknown column '{}'", col)); util::myThrow(fmt::format("unknown column '{}'", col));
this->predicted.insert(col); this->predicted.insert(col);
} }
for (auto & col : extraColumns)
if (col != EOSColName)
this->predicted.insert(col);
} }
bool Config::isPredicted(const std::string & colName) const bool Config::isPredicted(const std::string & colName) const
...@@ -674,3 +678,11 @@ Config::Object Config::str2object(const std::string & s) ...@@ -674,3 +678,11 @@ Config::Object Config::str2object(const std::string & s)
return Object::Buffer; return Object::Buffer;
} }
bool Config::isExtraColumn(const std::string & colName) const
{
for (auto & extraCol : extraColumns)
if (extraCol == colName)
return true;
return false;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment