diff --git a/src/__xml4nlp/Xml4nlp.cpp b/src/__xml4nlp/Xml4nlp.cpp index 527334bc6..b51fee039 100644 --- a/src/__xml4nlp/Xml4nlp.cpp +++ b/src/__xml4nlp/Xml4nlp.cpp @@ -859,7 +859,14 @@ int XML4NLP::SetParsesToSentence(const vector &vecHead, const vector &vecHead, const vector &vecRel, int sentenceIdx) { - if (0 != SetInfoToSentence(vecHead, sentenceIdx, TAG_PSR_PARENT)) return -1; + // decreasing vecHead index + vector d_vecHead; + for (int i = 0; i < vecHead.size(); i++) + { + d_vecHead.push_back(vecHead[i] - 1); + } + + if (0 != SetInfoToSentence(d_vecHead, sentenceIdx, TAG_PSR_PARENT)) return -1; if (0 != SetInfoToSentence(vecRel, sentenceIdx, TAG_PSR_RELATE)) return -1; return 0; } diff --git a/src/parser/parser_dll.cpp b/src/parser/parser_dll.cpp index 8fc3e1d6a..cd1c778d8 100644 --- a/src/parser/parser_dll.cpp +++ b/src/parser/parser_dll.cpp @@ -56,7 +56,7 @@ class ParserWrapper : public ltp::parser::Parser { heads.resize(len - 1); deprels.resize(len - 1); for (int i = 1; i < len; ++ i) { - heads[i - 1] = inst->predicted_heads[i] - 1; + heads[i - 1] = inst->predicted_heads[i]; deprels[i - 1] = ltp::parser::Parser::model->deprels.at( inst->predicted_deprelsidx[i]); }