summaryrefslogtreecommitdiff
path: root/extools
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-29 18:09:34 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-29 18:09:34 +0000
commitb1dcd16e660f8c613a78cda5ec9fc6312b0b87c1 (patch)
tree75323c8a7a7e8bb941fdfb377054cc65903bdaf8 /extools
parentcb252f82c66e3d7c8ae60a20a9a7da05d895716d (diff)
bug fix
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@65 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'extools')
-rw-r--r--extools/sentence_pair.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/extools/sentence_pair.cc b/extools/sentence_pair.cc
index 5706398f..02df3349 100644
--- a/extools/sentence_pair.cc
+++ b/extools/sentence_pair.cc
@@ -51,14 +51,15 @@ int AnnotatedParallelSentence::ReadAlignmentPoint(const char* buf,
short* a,
short* b) {
if (end - start < 3) {
- cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; abort();
+ cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl;
+ exit(1);
}
int c = start;
*a = 0;
while(c < end && buf[c] != '-') {
if (buf[c] < '0' || buf[c] > '9') {
- cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl;
- abort();
+ cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl;
+ exit(1);
}
(*a) *= 10;
(*a) += buf[c] - '0';
@@ -66,13 +67,14 @@ int AnnotatedParallelSentence::ReadAlignmentPoint(const char* buf,
}
++c;
if (c >= end) {
- cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; abort();
+ cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl;
+ exit(1);
}
(*b) = 0;
while(c < end && (!permit_col || (permit_col && buf[c] != ':'))) {
if (buf[c] < '0' || buf[c] > '9') {
- cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl;
- abort();
+ cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl;
+ exit(1);
}
(*b) *= 10;
(*b) += buf[c] - '0';
@@ -99,7 +101,12 @@ void AnnotatedParallelSentence::ParseSpanLabel(const char* buf, int start, int e
short a,b;
int c = ReadAlignmentPoint(buf, start, end, true, &a, &b) + 1;
if (buf[c-1] != ':' || c >= end) {
- cerr << "Span badly formed: " << string(buf, start, end-start) << endl; abort();
+ cerr << "Span badly formed: " << string(buf, start, end-start) << endl << buf << endl;
+ exit(1);
+ }
+ if (a >= e_len || b > e_len) {
+ cerr << "(" << a << ',' << b << ") is out of bounds in labeled span. INPUT=\n" << buf << endl;
+ exit(1);
}
// cerr << a << " " << b << " " << string(buf,c,end-c) << endl;
span_types(a,b).push_back(-TD::Convert(string(buf, c, end-c)));