summaryrefslogtreecommitdiff
path: root/utils/alignment_io.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-03-24 23:04:46 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-03-24 23:04:46 -0400
commitb6eede632af4fa58a6f5325ee0d059c02a898b9f (patch)
tree4d29d1d1d700b9540af213bac32ffda96046abe1 /utils/alignment_io.h
parent0c7e078d14dd7078ec4a5b3e77007609aec5e54c (diff)
rename aligner, add support for distinguishing translation / transliteration
Diffstat (limited to 'utils/alignment_io.h')
-rw-r--r--utils/alignment_io.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/alignment_io.h b/utils/alignment_io.h
new file mode 100644
index 00000000..36bcecd7
--- /dev/null
+++ b/utils/alignment_io.h
@@ -0,0 +1,42 @@
+#ifndef _ALIGNMENT_IO_H_
+#define _ALIGNMENT_IO_H_
+
+#include <string>
+#include <iostream>
+#include <boost/shared_ptr.hpp>
+#include "array2d.h"
+
+struct AlignmentIO {
+ enum AlignmentType { kNONE = 0, kTRANSLATION = 1, kTRANSLITERATION = 2 };
+
+ static boost::shared_ptr<Array2D<bool> > ReadPharaohAlignmentGrid(const std::string& al);
+ static void SerializePharaohFormat(const Array2D<bool>& alignment, std::ostream* out);
+ static void SerializeTypedAlignment(const Array2D<AlignmentType>& alignment, std::ostream* out);
+};
+
+inline std::ostream& operator<<(std::ostream& os, const Array2D<AlignmentIO::AlignmentType>& m) {
+ os << ' ';
+ for (int j=0; j<m.height(); ++j)
+ os << (j%10);
+ os << "\n";
+ for (int i=0; i<m.width(); ++i) {
+ os << (i%10);
+ for (int j=0; j<m.height(); ++j) {
+ switch (m(i,j)) {
+ case AlignmentIO::kNONE: os << '.'; break;
+ case AlignmentIO::kTRANSLATION: os << '*'; break;
+ case AlignmentIO::kTRANSLITERATION: os << '#'; break;
+ default: os << '?'; break;
+ }
+ }
+ os << (i%10) << "\n";
+ }
+ os << ' ';
+ for (int j=0; j<m.height(); ++j)
+ os << (j%10);
+ os << "\n";
+ return os;
+}
+
+
+#endif