From 6cdb5e1616064accd231b08df757233f82e848b7 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Mon, 29 Jun 2020 17:22:28 +0200 Subject: [PATCH] different null value for each column in ContextModule --- torch_modules/src/ContextModule.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/torch_modules/src/ContextModule.cpp b/torch_modules/src/ContextModule.cpp index a3129c8..4824034 100644 --- a/torch_modules/src/ContextModule.cpp +++ b/torch_modules/src/ContextModule.cpp @@ -113,7 +113,7 @@ void ContextModuleImpl::addToContext(std::vector<std::vector<long>> & context, c if (index == -1) { for (auto & contextElement : context) - contextElement.push_back(dict.getIndexOrInsert(Dict::nullValueStr)); + contextElement.push_back(dict.getIndexOrInsert(fmt::format("{}({})", col, Dict::nullValueStr))); } else { @@ -134,7 +134,12 @@ void ContextModuleImpl::addToContext(std::vector<std::vector<long>> & context, c dictIndex = dict.getIndexOrInsert(fmt::format("EOS({})", config.getAsFeature(col, index))); } else - dictIndex = dict.getIndexOrInsert(functions[colIndex](config.getAsFeature(col, index))); + { + std::string featureValue = functions[colIndex](config.getAsFeature(col, index)); + if (w2vFile.empty()) + featureValue = fmt::format("{}({})", col, featureValue); + dictIndex = dict.getIndexOrInsert(featureValue); + } for (auto & contextElement : context) contextElement.push_back(dictIndex); -- GitLab