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

Fixed filing of columns rawRange

parent 9cd10b96
No related branches found
No related tags found
No related merge requests found
...@@ -80,9 +80,6 @@ Action Action::consumeCharacterIndex(const util::utf8string & consumed) ...@@ -80,9 +80,6 @@ Action Action::consumeCharacterIndex(const util::utf8string & consumed)
{ {
auto apply = [consumed](Config & config, Action &) auto apply = [consumed](Config & config, Action &)
{ {
config.getLastNotEmptyHyp(Config::rawRangeStartColName, config.getWordIndex()) = fmt::format("{}", config.getCharacterIndex());
config.getLastNotEmptyHyp(Config::rawRangeEndColName, config.getWordIndex()) = fmt::format("{}", config.getCharacterIndex() + consumed.size());
config.moveCharacterIndex(consumed.size()); config.moveCharacterIndex(consumed.size());
}; };
...@@ -586,8 +583,7 @@ Action Action::addCharsToCol(const std::string & col, int n, Config::Object obje ...@@ -586,8 +583,7 @@ Action Action::addCharsToCol(const std::string & col, int n, Config::Object obje
{ {
if (util::isEmpty(config.getAsFeature(Config::rawRangeStartColName, index))) if (util::isEmpty(config.getAsFeature(Config::rawRangeStartColName, index)))
config.getLastNotEmptyHyp(Config::rawRangeStartColName, index) = fmt::format("{}", config.getCharacterIndex()); config.getLastNotEmptyHyp(Config::rawRangeStartColName, index) = fmt::format("{}", config.getCharacterIndex());
if (util::isEmpty(config.getAsFeature(Config::rawRangeEndColName, index))) config.getLastNotEmptyHyp(Config::rawRangeEndColName, index) = fmt::format("{}", config.getCharacterIndex());
config.getLastNotEmptyHyp(Config::rawRangeEndColName, index) = fmt::format("{}", config.getCharacterIndex());
int curEndValue = std::stoi(config.getAsFeature(Config::rawRangeEndColName, index)); int curEndValue = std::stoi(config.getAsFeature(Config::rawRangeEndColName, index));
config.getLastNotEmptyHyp(Config::rawRangeEndColName, index) = fmt::format("{}", curEndValue+n); config.getLastNotEmptyHyp(Config::rawRangeEndColName, index) = fmt::format("{}", curEndValue+n);
} }
...@@ -753,8 +749,15 @@ Action Action::updateIds(int bufferIndex) ...@@ -753,8 +749,15 @@ Action Action::updateIds(int bufferIndex)
if (config.has(0,firstIndexOfSentence,0)) if (config.has(0,firstIndexOfSentence,0))
{ {
std::string textMetadata = "# text = "; std::string textMetadata = "# text = ";
for (auto i = std::stoi(config.getAsFeature(Config::rawRangeStartColName, firstIndexOfSentence)); i < std::stoi(config.getAsFeature(Config::rawRangeEndColName, lineIndex)); i++) int firstIndex = 0;
int lastIndex = 0;
try {firstIndex = std::stoi(config.getAsFeature(Config::rawRangeStartColName, firstIndexOfSentence));}
catch (std::exception & e) {util::myThrow(fmt::format("{} : '{}'", e.what(), config.getAsFeature(Config::rawRangeStartColName, firstIndexOfSentence)));}
try {lastIndex = std::stoi(config.getAsFeature(Config::rawRangeEndColName, lineIndex));}
catch (std::exception & e) {util::myThrow(fmt::format("{} : '{}'", e.what(), config.getAsFeature(Config::rawRangeEndColName, lineIndex)));}
for (auto i = firstIndex; i < lastIndex; i++)
textMetadata = fmt::format("{}{}", textMetadata, config.getLetter(i)); textMetadata = fmt::format("{}{}", textMetadata, config.getLetter(i));
config.getLastNotEmptyHyp(Config::commentsColName, firstIndexOfSentence) = fmt::format("{}\n# sent_id = {}", textMetadata, config.getAsFeature(Config::sentIdColName, firstIndexOfSentence)); config.getLastNotEmptyHyp(Config::commentsColName, firstIndexOfSentence) = fmt::format("{}\n# sent_id = {}", textMetadata, config.getAsFeature(Config::sentIdColName, firstIndexOfSentence));
} }
}; };
......
...@@ -317,7 +317,11 @@ void Transition::initSplitWord(std::vector<std::string> words) ...@@ -317,7 +317,11 @@ void Transition::initSplitWord(std::vector<std::string> words)
sequence.emplace_back(Action::addCharsToCol("FORM", consumedWord.size(), Config::Object::Buffer, 0)); sequence.emplace_back(Action::addCharsToCol("FORM", consumedWord.size(), Config::Object::Buffer, 0));
sequence.emplace_back(Action::consumeCharacterIndex(consumedWord)); sequence.emplace_back(Action::consumeCharacterIndex(consumedWord));
for (unsigned int i = 1; i < words.size(); i++) for (unsigned int i = 1; i < words.size(); i++)
{
sequence.emplace_back(Action::addHypothesisRelativeRelaxed("FORM", Config::Object::Buffer, i, words[i])); sequence.emplace_back(Action::addHypothesisRelativeRelaxed("FORM", Config::Object::Buffer, i, words[i]));
sequence.emplace_back(Action::transformSuffix(Config::rawRangeStartColName, Config::Object::Buffer, 0, Config::rawRangeStartColName, Config::Object::Buffer, i, util::utf8string(), util::utf8string()));
sequence.emplace_back(Action::transformSuffix(Config::rawRangeEndColName, Config::Object::Buffer, 0, Config::rawRangeEndColName, Config::Object::Buffer, i, util::utf8string(), util::utf8string()));
}
sequence.emplace_back(Action::setMultiwordIds(words.size()-1)); sequence.emplace_back(Action::setMultiwordIds(words.size()-1));
costDynamic = [words](const Config & config) costDynamic = [words](const Config & config)
......
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