Ejemplo n.º 1
0
        public void Read(FileStream stream)
        {
            _size.ReadFromFile(stream);

            if (_size.GetValueAsRawInt() < 50000)
            {
                _sentence = new ByteString(Size.Position + Size.Length, Size.GetValueAsRawInt());
                _sentence.ReadFromFile(stream);
            }
            else
            {
                Console.Out.WriteLine("Maximum sentence length [50000] exceeded.");
            }
        }
Ejemplo n.º 2
0
        protected override void ReadTableMeta(FileStream stream)
        {
            _sentenceCount = new MxeWord(_sentenceCountPos, "i");
            _aCount = new MxeWord(_aCountPos, "i");
            _bCount = new MxeWord(_bCountPos, "i");
            _eofcOne = new MxeWord(_eofcOnePos, "i");
            _eofcTwo = new MxeWord(_eofcTwoPos, "i");

            _sentenceCount.ReadFromFile(stream);
            _aCount.ReadFromFile(stream);
            _bCount.ReadFromFile(stream);
            _eofcOne.ReadFromFile(stream);
            _eofcTwo.ReadFromFile(stream);

            int sc = (int)_sentenceCount.GetValueAsRawInt();
            int ac = (int)_aCount.GetValueAsRawInt(); // this is also the size of the index entries
            int bc = (int)_bCount.GetValueAsRawInt();
            int pos = _aBlockPos + _aCount.Length * ac + _bCount.Length * bc;

            Console.Out.WriteLine("Sentence count: " + sc);

            _indexesStart = pos;

            List<MtpIndexEntry> entries = new List<MtpIndexEntry>();
            MtpIndexEntry prevE = null;
            for (int i = 0; i < sc; i++)
            {
                MtpIndexEntry e = new MtpIndexEntry(pos, this, prevE);
                if (ac == 0x14)
                {
                    e = new MtpIndexExtendedEntry(pos, this, prevE);
                }
                entries.Add(e);

                prevE = e;
                pos += _sentenceCount.Length * ac;
            }

            _sentencesStart = pos;

            //can't read or setup all this stuff until after _sentencesStart is set.
            foreach (MtpIndexEntry e in entries)
            {
                e.ReadEntry(stream);
                _indexes.Add(e.Id.GetValueAsRawInt(), e);
            }

            int endingLoc = prevE.Sentence.Sentence.Position + prevE.Sentence.Sentence.Length;
            _restOfIt = new ByteString(endingLoc, (int)stream.Length - endingLoc);
            _restOfIt.ReadFromFile(stream);
        }