[SRILM User List] Lattice tool crash
Andreas Stolcke
stolcke at icsi.berkeley.edu
Mon Apr 23 10:36:28 PDT 2012
On 4/22/2012 7:46 AM, Nickolay V. Shmyrev wrote:
> Hello
>
> lattice tool crashes when trying to read the attached lattice with.
>
> lattice-tool -in-lattice problem.lat -read-htk
>
> The problem is that it fails to find the final node. So
> finalNode->word on line 1218 in HTK lattice causes access violation.
>
>
Indeed. Your lattice is missing a end= specification, and the heuristic
used to determine a final node in this case fails (because your
de-facto-final node has a self-loop). The same could happen with the
start node, if undefined.
The attached patch will issue an error in these cases. However, you
should still fix your input lattices (include start/end attributes).
Andreas
-------------- next part --------------
Index: lattice/src/HTKLattice.cc
===================================================================
RCS file: /home/srilm/CVS/srilm/lattice/src/HTKLattice.cc,v
retrieving revision 1.53
diff -c -r1.53 HTKLattice.cc
*** lattice/src/HTKLattice.cc 24 Dec 2011 05:25:54 -0000 1.53
--- lattice/src/HTKLattice.cc 23 Apr 2012 17:27:32 -0000
***************
*** 1164,1169 ****
--- 1164,1171 ----
// search for start node: the one without incoming transitions
LHashIter<NodeIndex, LatticeNode> nodeIter(nodes);
NodeIndex nodeIndex;
+
+ initialNode = 0;
while (LatticeNode *node = nodeIter.next(nodeIndex)) {
if (node->inTransitions.numEntries() == 0) {
initial = nodeIndex;
***************
*** 1172,1177 ****
--- 1174,1185 ----
}
}
+ if (!initialNode) {
+ file.position() << "could not find start node\n";
+ if (!useNullNodes) vocab.remove(HTKNodeDummy);
+ return false;
+ }
+
// now find the HTK node info associated with first node
LHashIter<unsigned, NodeIndex> nodeMapIter(nodeMap);
unsigned htkNode;
***************
*** 1213,1218 ****
--- 1221,1228 ----
// search for end node: the one without outgoing transitions
LHashIter<NodeIndex, LatticeNode> nodeIter(nodes);
NodeIndex nodeIndex;
+
+ finalNode = 0;
while (LatticeNode *node = nodeIter.next(nodeIndex)) {
if (node->outTransitions.numEntries() == 0) {
final = nodeIndex;
***************
*** 1221,1226 ****
--- 1231,1242 ----
}
}
+ if (!finalNode) {
+ file.position() << "could not find final node\n";
+ if (!useNullNodes) vocab.remove(HTKNodeDummy);
+ return false;
+ }
+
// now find the HTK node info associated with final node
LHashIter<unsigned, NodeIndex> nodeMapIter(nodeMap);
unsigned htkNode;
More information about the SRILM-User
mailing list