mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +03:00
fix feature name splitting to split on last colon
This commit is contained in:
parent
6758881357
commit
614c98e682
@ -71,7 +71,7 @@ void FeatureDataIterator::readNext() {
|
|||||||
StringPiece line = m_in->ReadLine();
|
StringPiece line = m_in->ReadLine();
|
||||||
m_next.push_back(FeatureDataItem());
|
m_next.push_back(FeatureDataItem());
|
||||||
for (TokenIter<AnyCharacter, true> token(line, AnyCharacter(" \t")); token; ++token) {
|
for (TokenIter<AnyCharacter, true> token(line, AnyCharacter(" \t")); token; ++token) {
|
||||||
TokenIter<AnyCharacter,false> value(*token,AnyCharacter(":"));
|
TokenIter<AnyCharacterLast,false> value(*token,AnyCharacterLast(":"));
|
||||||
if (!value) throw FileFormatException(m_in->FileName(), line.as_string());
|
if (!value) throw FileFormatException(m_in->FileName(), line.as_string());
|
||||||
StringPiece first = *value;
|
StringPiece first = *value;
|
||||||
++value;
|
++value;
|
||||||
|
@ -87,6 +87,22 @@ class AnyCharacter {
|
|||||||
return StringPiece(std::find_first_of(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1);
|
return StringPiece(std::find_first_of(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringPiece FindLast(const StringPiece &in) const {
|
||||||
|
return StringPiece(std::find_end(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
StringPiece chars_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AnyCharacterLast {
|
||||||
|
public:
|
||||||
|
explicit AnyCharacterLast(const StringPiece &chars) : chars_(chars) {}
|
||||||
|
|
||||||
|
StringPiece Find(const StringPiece &in) const {
|
||||||
|
return StringPiece(std::find_end(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StringPiece chars_;
|
StringPiece chars_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user