public override bool equals(object obj) { if (this == obj) { return(true); } if (this.GetType() != obj.GetType()) { return(false); } ImmutableState immutableState = (ImmutableState)obj; return(Arrays.equals(this.arcs, immutableState.arcs) && base.equals(obj)); }
private static ImmutableFst readImmutableFst(ObjectInputStream objectInputStream) { string[] isyms = Fst.readStringMap(objectInputStream); string[] osyms = Fst.readStringMap(objectInputStream); int num = objectInputStream.readInt(); Semiring semiring = (Semiring)objectInputStream.readObject(); int num2 = objectInputStream.readInt(); ImmutableFst immutableFst = new ImmutableFst(num2); immutableFst.isyms = isyms; immutableFst.osyms = osyms; immutableFst.semiring = semiring; for (int i = 0; i < num2; i++) { int num3 = objectInputStream.readInt(); ImmutableState immutableState = new ImmutableState(num3 + 1); float num4 = objectInputStream.readFloat(); if (num4 == immutableFst.semiring.zero()) { num4 = immutableFst.semiring.zero(); } else if (num4 == immutableFst.semiring.one()) { num4 = immutableFst.semiring.one(); } immutableState.setFinalWeight(num4); immutableState.id = objectInputStream.readInt(); immutableFst.states[immutableState.getId()] = immutableState; } immutableFst.setStart(immutableFst.states[num]); num2 = immutableFst.states.Length; for (int i = 0; i < num2; i++) { ImmutableState immutableState2 = immutableFst.states[i]; for (int j = 0; j < immutableState2.initialNumArcs - 1; j++) { Arc arc = new Arc(); arc.setIlabel(objectInputStream.readInt()); arc.setOlabel(objectInputStream.readInt()); arc.setWeight(objectInputStream.readFloat()); arc.setNextState(immutableFst.states[objectInputStream.readInt()]); immutableState2.setArc(j, arc); } } return(immutableFst); }
public override string toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(new StringBuilder().append("Fst(start=").append(this.start).append(", isyms=").append(Arrays.toString(this.isyms)).append(", osyms=").append(Arrays.toString(this.osyms)).append(", semiring=").append(this.semiring).append(")\n").toString()); int num = this.states.Length; for (int i = 0; i < num; i++) { ImmutableState immutableState = this.states[i]; stringBuilder.append(new StringBuilder().append(" ").append(immutableState).append("\n").toString()); int numArcs = immutableState.getNumArcs(); for (int j = 0; j < numArcs; j++) { Arc arc = immutableState.getArc(j); stringBuilder.append(new StringBuilder().append(" ").append(arc).append("\n").toString()); } } return(stringBuilder.toString()); }