public void Serialize(BinWriter bw) { bw.WriteString(ZhSurf); bw.WriteString(TrgSurf); bw.WriteShort((short)ZhTokMap.Length); foreach (var ip in ZhTokMap) { bw.WriteShort(ip.A); bw.WriteShort(ip.B); } bw.WriteShort((short)TrgTokMap.Length); foreach (var ip in TrgTokMap) { bw.WriteShort(ip.A); bw.WriteShort(ip.B); } bw.WriteShort((short)ZhToTrgAlign.Length); foreach (var alm in ZhToTrgAlign) { bw.WriteShort(alm.Ix1); bw.WriteShort(alm.Ix2); bw.WriteDouble(alm.Score); } bw.WriteShort((short)TrgToZhAlign.Length); foreach (var alm in TrgToZhAlign) { bw.WriteShort(alm.Ix1); bw.WriteShort(alm.Ix2); bw.WriteDouble(alm.Score); } }
/// <summary> /// Serialize to binary stream. /// </summary> public void Serialize(BinWriter bw) { bw.WriteArray(pinyin, (ps, bwr) => ps.Serialize(bwr)); bw.WriteString(ChSimpl); bw.WriteString(ChTrad); bw.WriteArray(senses); bw.WriteArray(hanziPinyinMap, (x, bwr) => bwr.WriteShort(x)); }
/// <summary> /// Serialize into binary stream. /// </summary> public void Serialize(BinWriter bw) { // Write flags byte flags = 0; if (Simp != null) { flags |= 1; } if (Trad != Simp) { flags |= 2; } if (Pinyin != null) { flags |= 4; } bw.WriteByte(flags); // Write simplified if (Simp != null) { bw.WriteString(Simp); } // Write traditional, if different if (Trad != Simp) { bw.WriteString(Trad); } // Write pinyin, if present if (Pinyin != null) { if (Pinyin.Length > byte.MaxValue) { throw new Exception("Pinyin syllable count exceeds maximum byte value: " + Pinyin.Length.ToString()); } byte pinyinCount = (byte)Pinyin.Length; bw.WriteByte(pinyinCount); foreach (PinyinSyllable py in Pinyin) { py.Serialize(bw); } } }
/// <summary> /// Serialize to binary stream. /// </summary> public void Serialize(BinWriter bw) { bw.WriteArray(pinyin, (ps, bwr) => ps.Serialize(bwr)); bw.WriteString(ChSimpl); bw.WriteString(ChTrad); bw.WriteUShort(Freq); bw.WriteInt(StableId); bw.WriteByte((byte)Status); bw.WriteArray(senses); bw.WriteArray(hanziPinyinMap, (x, bwr) => bwr.WriteShort(x)); if (zhoEmbeds == null) { bw.WriteShort(0); } else { bw.WriteShort((short)zhoEmbeds.Length); for (int i = 0; i != zhoEmbeds.Length; ++i) { zhoEmbeds[i].Serialize(bw); } } }
/// <summary> /// Serialize into binary stream. /// </summary> public void Serialize(BinWriter bw) { bw.WriteChar(Radical); bw.WriteChar(Phon); bw.WriteChar(Seman); bw.WriteString(Decomp); if (Strokes.Count > short.MaxValue) { throw new Exception("Strokes too long for serialization."); } bw.WriteShort((short)Strokes.Count); foreach (var os in Strokes) { os.Serialize(bw); } }
/// <summary> /// Serialize into binary stream. /// </summary> public void Serialize(BinWriter bw) { bw.WriteString(Text); }
/// <summary> /// Serializes pinyin syllable into binary stream. /// </summary> public void Serialize(BinWriter bw) { bw.WriteString(Text); bw.WriteByte((byte)(Tone + 1)); }