Example #1
0
        protected AbstractParserEventStream(
            IObjectStream <Parse> samples,
            IHeadRules headRules,
            ParserEventTypeEnum type,
            Dictionary.Dictionary dictionary) : base(samples)
        {
            Rules         = headRules;
            Punctuation   = headRules.PunctuationTags;
            Dictionary    = dictionary;
            FixPossesives = false;

            Type = type;

#pragma warning disable 618
            switch (type)
            {
            case ParserEventTypeEnum.Chunk:
                chunkerContextGenerator = new ChunkContextGenerator();
                break;

            case ParserEventTypeEnum.Tag:
                posContextGenerator = new DefaultPOSContextGenerator(null);
                break;
            }
#pragma warning restore 618
        }
Example #2
0
        internal static List <Event> GenerateEvents(string[] sentence, string[] tags, object[] additionalContext,
                                                    IPOSContextGenerator cg)
        {
            var events = new List <Event>();

            for (var i = 0; i < 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 context = cg.GetContext(i, sentence, tags, additionalContext);

                events.Add(new Event(tags[i], context));
            }
            return(events);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="POSSampleSequenceStream"/> class.
 /// </summary>
 /// <param name="objectStream">The object stream.</param>
 /// <param name="contextGenerator">The context generator.</param>
 public POSSampleSequenceStream(IObjectStream <POSSample> objectStream, IPOSContextGenerator contextGenerator)
 {
     this.objectStream     = objectStream;
     this.contextGenerator = contextGenerator;
 }
Example #4
0
 internal static List <Event> GenerateEvents(string[] sentence, string[] tags, IPOSContextGenerator cg)
 {
     return(GenerateEvents(sentence, tags, null, cg));
 }
Example #5
0
 /// <summary>
 /// Initializes the current instance with the given samples and the given <see cref="IPOSContextGenerator"/>.
 /// </summary>
 /// <param name="samples">The samples.</param>
 /// <param name="cg">The context generator.</param>
 public POSSampleEventStream(IObjectStream <POSSample> samples, IPOSContextGenerator cg) : base(samples)
 {
     this.cg = cg;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="POSSampleSequenceStream"/> class.
 /// </summary>
 /// <param name="objectStream">The object stream.</param>
 /// <param name="contextGenerator">The context generator.</param>
 public POSSampleSequenceStream(IObjectStream<POSSample> objectStream, IPOSContextGenerator contextGenerator) {
     this.objectStream = objectStream;
     this.contextGenerator = contextGenerator;
 }