summaryrefslogtreecommitdiff
path: root/extractor/translation_table.cc
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-06-04 23:17:57 +0100
committerPaul Baltescu <pauldb89@gmail.com>2013-06-04 23:17:57 +0100
commit02099a01350a41a99ec400e9b29df08a01d88979 (patch)
treeb5af245aa6c7e00e3d4b088c9e7e3b893d080a26 /extractor/translation_table.cc
parent891502bdd646c21954684763f322b107568a072e (diff)
Serialize data structures.
Diffstat (limited to 'extractor/translation_table.cc')
-rw-r--r--extractor/translation_table.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/extractor/translation_table.cc b/extractor/translation_table.cc
index adb59cb5..03e41d9a 100644
--- a/extractor/translation_table.cc
+++ b/extractor/translation_table.cc
@@ -112,15 +112,10 @@ double TranslationTable::GetSourceGivenTargetScore(
return translation_probabilities[make_pair(source_id, target_id)].second;
}
-void TranslationTable::WriteBinary(const fs::path& filepath) const {
- FILE* file = fopen(filepath.string().c_str(), "w");
-
- int size = translation_probabilities.size();
- fwrite(&size, sizeof(int), 1, file);
- for (auto entry: translation_probabilities) {
- fwrite(&entry.first, sizeof(entry.first), 1, file);
- fwrite(&entry.second, sizeof(entry.second), 1, file);
- }
+bool TranslationTable::operator==(const TranslationTable& other) const {
+ return *source_data_array == *other.source_data_array &&
+ *target_data_array == *other.target_data_array &&
+ translation_probabilities == other.translation_probabilities;
}
} // namespace extractor