Skip to content

Commit 7c7abdb

Browse files
committed
Make NLTK -> Tableau conversion more robust against unexpected input
1 parent fd1a8da commit 7c7abdb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

frontend/src/app/services/parse.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function nltkNode2tableauNode(nltk: any, tree: any) {
5757
const lines = nltk.node.split('\n');
5858
if (lines[0] === 'Closed') {
5959
node.rule = lines[1];
60-
} else if (lines[0] !== 'Model') {
60+
} else if (lines.length >= 3) {
6161
const sign = lines.pop();
6262
node.sign = (sign === 'True');
6363
const tagLine = lines.shift().split(':');
@@ -78,6 +78,8 @@ function nltkNode2tableauNode(nltk: any, tree: any) {
7878
}
7979
}
8080
if (lines.length) node.head = lines[0];
81+
} else if (lines[0] !== 'Model') {
82+
node.head = nltk.node;
8183
}
8284
if (!nltk.children || !nltk.children.length) {
8385
node.end = true;

0 commit comments

Comments
 (0)