/// <summary>
        /// Returns the next <see cref="Sequence"/>. Calling this method repeatedly until it returns,
        /// null will return each object from the underlying source exactly once.
        /// </summary>
        /// <returns>
        /// The next <see cref="Sequence"/> or null to signal that the stream is exhausted.
        /// </returns>
        public Sequence Read() {
            var sample = objectStream.Read();

            if (sample != null) {
                var events = new Event[sample.Sentence.Length];
                for (var i = 0; i < events.Length; i++) {
                    events[i] = new Event(sample.Tags[i],
                        contextGenerator.GetContext(i, sample.Sentence, sample.Tags, null));
                }
                return new Sequence(events, sample);
            }

            return null;
        }
        /// <summary>
        /// Returns the next <see cref="Sequence"/>. Calling this method repeatedly until it returns,
        /// null will return each object from the underlying source exactly once.
        /// </summary>
        /// <returns>
        /// The next object or null to signal that the stream is exhausted.
        /// </returns>
        public Sequence Read() {
            var sample = samples.Read();
            if (sample == null) 
                return null;

            var events = new Event[sample.Sentence.Count];
            for (int i = 0, count = sample.Sentence.Count; i < count; i++) {
                events[i] = new Event(
                    sample.Tags[i],
                    // it is safe to pass the tags as previous tags because
                    // the context generator does not look for non predicted tags
                    contextGenerator.GetContext(i, sample.Sentence.ToArray(), sample.Tags.ToArray(), null));
            }
            return new Sequence(events, sample);
        }
        /// <summary>
        /// Returns the next object. Calling this method repeatedly until it returns,
        /// null will return each object from the underlying source exactly once.
        /// </summary>
        /// <returns>
        /// The next object or null to signal that the stream is exhausted.
        /// </returns>
        public Sequence Read() {
            var sample = psi.Read();
            if (sample != null) {

                var events = new Event[sample.Sentence.Length];

                for (int i = 0; i < sample.Sentence.Length; i++) {

                    // it is safe to pass the tags as previous tags because
                    // the context generator does not look for non predicted tags
                    var tags = seqCodec.Encode(sample.Names, sample.Sentence.Length);


                    var context = pcg.GetContext(
                        i,
                        sample.Sentence,
                        useOutcomes ? tags : null,
                        null);

                    events[i] = new Event(tags[i], context);
                }

                return new Sequence(events, sample);
            }
            return null;
        }