示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractAnalyzer" /> using a custom analyzer weight.
        /// </summary>
        /// <param name="tagger">The part-of-speech tagger used by this analyzer.</param>
        /// <param name="weight">The analyzer weight.</param>
        /// <exception cref="System.ArgumentNullException">tagger</exception>
        public POSTaggerAnalyzer(POSTaggerME tagger, float weight)
            : base(weight) {
            if (tagger == null)
                throw new ArgumentNullException("tagger");

            Tagger = tagger;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractAnalyzer" /> using a custom analyzer weight.
        /// </summary>
        /// <param name="tagger">The part-of-speech tagger used by this analyzer.</param>
        /// <param name="weight">The analyzer weight.</param>
        /// <exception cref="System.ArgumentNullException">tagger</exception>
        public POSTaggerAnalyzer(POSTaggerME tagger, float weight)
            : base(weight)
        {
            if (tagger == null)
            {
                throw new ArgumentNullException("tagger");
            }

            Tagger = tagger;
        }
示例#3
0
        /// <summary>
        /// Creates a new event array based on the outcomes predicted by the specified parameters for the specified sequence.
        /// </summary>
        /// <param name="sequence">The sequence to be evaluated.</param>
        /// <param name="model">The model.</param>
        /// <returns>The event array.</returns>
        public Event[] UpdateContext(Sequence sequence, AbstractModel model)
        {
            var tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, new POSTaggerFactory()));
            var sample = sequence.GetSource <POSSample>();
            var tags   = tagger.Tag(sample.Sentence);

            return(POSSampleEventStream.GenerateEvents(
                       sample.Sentence,
                       tags,
                       Array.ConvertAll(sample.AdditionalContext, input => (object)input),
                       contextGenerator).ToArray());
        }
示例#4
0
        public void TestPOSTagger() {
            var posModel = TrainPOSModel();

            var tagger = new POSTaggerME(posModel);

            var tags = tagger.Tag(new[] { "The", "driver", "got", "badly", "injured", "." });

            Assert.AreEqual(6, tags.Length);

            Assert.AreEqual("DT", tags[0]);
            Assert.AreEqual("NN", tags[1]);
            Assert.AreEqual("VBD", tags[2]);
            Assert.AreEqual("RB", tags[3]);
            Assert.AreEqual("VBN", tags[4]);
            Assert.AreEqual(".", tags[5]);
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="POSTaggerAnalyzer"/> using the default analyzer weight.
 /// </summary>
 /// <param name="tagger">The part-of-speech tagger used by this analyzer.</param>
 public POSTaggerAnalyzer(POSTaggerME tagger) : this(tagger, 4f)
 {
 }
        /// <summary>
        /// Creates a new event array based on the outcomes predicted by the specified parameters for the specified sequence.
        /// </summary>
        /// <param name="sequence">The sequence to be evaluated.</param>
        /// <param name="model">The model.</param>
        /// <returns>The event array.</returns>
        public Event[] UpdateContext(Sequence sequence, AbstractModel model) {
            var tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, new POSTaggerFactory()));
            var sample = sequence.GetSource<POSSample>();
            var tags = tagger.Tag(sample.Sentence);

            return POSSampleEventStream.GenerateEvents(
                sample.Sentence,
                tags,
                Array.ConvertAll(sample.AdditionalContext, input => (object) input),
                contextGenerator).ToArray();
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="POSTaggerAnalyzer"/> using the default analyzer weight.
 /// </summary>
 /// <param name="tagger">The part-of-speech tagger used by this analyzer.</param>
 public POSTaggerAnalyzer(POSTaggerME tagger) : this(tagger, 4f) { }