summaryrefslogtreecommitdiff
path: root/extractor/alignment.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2013-06-24 14:40:07 +0200
committerPatrick Simianer <p@simianer.de>2013-06-24 14:40:07 +0200
commit230d7667eac7a229d1c5809022b17c6137f67065 (patch)
tree821d2a362f605211c49782a6511ec167d5287242 /extractor/alignment.cc
parent14e64ada4aa7d1ddc1b5c27c096e58c969d34370 (diff)
parent23e89686849d290e8b64875a0bdf77cbdb70d2df (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'extractor/alignment.cc')
-rw-r--r--extractor/alignment.cc15
1 files changed, 4 insertions, 11 deletions
diff --git a/extractor/alignment.cc b/extractor/alignment.cc
index b187c03a..2278c825 100644
--- a/extractor/alignment.cc
+++ b/extractor/alignment.cc
@@ -23,8 +23,8 @@ Alignment::Alignment(const string& filename) {
boost::split(items, line, boost::is_any_of(" -"));
vector<pair<int, int>> alignment;
alignment.reserve(items.size() / 2);
- for (size_t i = 0; i < items.size(); i += 2) {
- alignment.push_back(make_pair(stoi(items[i]), stoi(items[i + 1])));
+ for (size_t i = 1; i < items.size(); i += 2) {
+ alignment.push_back(make_pair(stoi(items[i - 1]), stoi(items[i])));
}
alignments.push_back(alignment);
}
@@ -39,15 +39,8 @@ vector<pair<int, int>> Alignment::GetLinks(int sentence_index) const {
return alignments[sentence_index];
}
-void Alignment::WriteBinary(const fs::path& filepath) {
- FILE* file = fopen(filepath.string().c_str(), "w");
- int size = alignments.size();
- fwrite(&size, sizeof(int), 1, file);
- for (vector<pair<int, int>> alignment: alignments) {
- size = alignment.size();
- fwrite(&size, sizeof(int), 1, file);
- fwrite(alignment.data(), sizeof(pair<int, int>), size, file);
- }
+bool Alignment::operator==(const Alignment& other) const {
+ return alignments == other.alignments;
}
} // namespace extractor