Skip to content

Commit 73ca08d

Browse files
committed
Make NLTK -> Tableau conversion more robust against unexpected input
1 parent 72ebab2 commit 73ca08d

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
@@ -72,7 +72,7 @@ function nltkNode2tableauNode(nltk: any, tree: any) {
7272
const lines = nltk.node.split('\n');
7373
if (lines[0] === 'Closed') {
7474
node.rule = lines[1];
75-
} else if (lines[0] !== 'Model') {
75+
} else if (lines.length >= 3) {
7676
const sign = lines.pop();
7777
node.sign = (sign === 'True');
7878
const tagLine = lines.shift().split(':');
@@ -93,6 +93,8 @@ function nltkNode2tableauNode(nltk: any, tree: any) {
9393
}
9494
}
9595
if (lines.length) node.head = lines[0];
96+
} else if (lines[0] !== 'Model') {
97+
node.head = nltk.node;
9698
}
9799
if (!nltk.children || !nltk.children.length) {
98100
node.end = true;

0 commit comments

Comments
 (0)