private void LoadDictionary(byte[] data, int offset) { EntryCount = BitConverter.ToInt16(data, offset); Mark("EntryCount", offset, sizeof(short)); EntryOffset = new ushort[EntryCount]; var dataOffset = sizeof(short) + (sizeof(short) * EntryCount); Mark("EntryOffsetArrayDescription", offset + sizeof(short), EntryCount * sizeof(short)); for (var i = 0; i < EntryCount; i++) { EntryOffset[i] = BitConverter.ToUInt16(data, offset + sizeof(short) + (sizeof(short) * i)); var length = EntryOffset[i] - dataOffset; var dictionaryData = new byte[length]; Array.Copy(data, offset + dataOffset, dictionaryData, 0, length); Mark("DictionaryEntriesArray", "Dictionary Entry " + i, i); var entry = new DictionaryEntry(dictionaryData); entry.Mark("Data", offset + dataOffset, length); DictionaryEntries.Add(entry); dataOffset = EntryOffset[i]; } }
public void ReadUnknownDefinition(Stream input, Encoding encoding) { foreach (var line in input.ReadLines(encoding)) { var entry = UnknownDictionaryEntryParser.Parse(line); DictionaryEntries.Add(entry); } }
public void ReadTokenInfo(Stream input) { var entryCount = PosInfo.EntryCount; foreach (var line in input.ReadLines(Encoding)) { var entry = Parse(line); var dictionaryEntry = MakeGenericDictionaryEntry(entry); var leftId = dictionaryEntry.LeftId; var rightId = dictionaryEntry.RightId; var wordCost = dictionaryEntry.WordCost; var allPosFeatures = dictionaryEntry.PartOfSpeechFeatures; var posFeatureIds = PosInfo.MapFeatures(allPosFeatures); var featureList = dictionaryEntry.OtherFeatures; var otherFeatureIds = OtherInfo.MapFeatures(featureList); var bufferEntry = new BufferEntry(); bufferEntry.TokenInfo.Add(leftId); bufferEntry.TokenInfo.Add(rightId); bufferEntry.TokenInfo.Add(wordCost); if (EntriesFitInAByte(entryCount)) { var posFeatureIdBytes = CreatePosFeatureIds(posFeatureIds); bufferEntry.PosInfo.AddRange(posFeatureIdBytes); } else { foreach (var posFeatureId in posFeatureIds) { bufferEntry.TokenInfo.Add((short)posFeatureId); } } bufferEntry.Features.AddRange(otherFeatureIds); BufferEntries.Add(bufferEntry); Surfaces.Add(dictionaryEntry.Surface); if (DictionaryEntries != null) { DictionaryEntries.Add(dictionaryEntry); } } }