Skip to content

Commit eee3a6c

Browse files
committed
Merge pull request #13 from drevicko/fix-instancelist-serialisation
set alphabets from data or pipe when reading serialised instance list
2 parents 2705baa + 9b89ffe commit eee3a6c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/cc/mallet/types/InstanceList.java

+16
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,22 @@ private void readObject (ObjectInputStream in) throws IOException, ClassNotFound
831831
int version = in.readInt ();
832832
instWeights = (HashMap<Instance,Double>) in.readObject();
833833
pipe = (Pipe) in.readObject();
834+
if (dataAlphabet == null) {
835+
if (size()>0) {
836+
Instance instance = get(0);
837+
dataAlphabet = instance.getDataAlphabet ();
838+
} else if (pipe.getDataAlphabet()!=null) {
839+
dataAlphabet = pipe.getDataAlphabet ();
840+
}
841+
}
842+
if (targetAlphabet == null) {
843+
if (size()>0) {
844+
Instance instance = get(0);
845+
targetAlphabet = instance.getTargetAlphabet ();
846+
} else if (pipe.getTargetAlphabet()!=null) {
847+
targetAlphabet = pipe.getTargetAlphabet ();
848+
}
849+
}
834850
}
835851

836852
// added - [email protected]

0 commit comments

Comments
 (0)