Esempio n. 1
0
        /// <summary>
        /// Generates chunk tags for the given sequence returning the result in an array.
        /// </summary>
        /// <param name="tokens">an array of the tokens or words of the sequence.</param>
        /// <param name="tags">an array of the pos tags of the sequence.</param>
        /// <returns>an array of chunk tags for each token in the sequence.</returns>
        public string[] Chunk(string[] tokens, string[] tags)
        {
            ChunkSample predsSample = mSampleStream.Read();

            // checks if the streams are sync
            for (int i = 0; i < tokens.Length; i++)
            {
                if (!tokens[i].Equals(predsSample.Sentence[i]) ||
                    !tags[i].Equals(predsSample.Tags[i]))
                {
                    throw new ApplicationException("The streams are not sync!"
                                                   + "\n expected sentence: " + tokens.ToDisplay()
                                                   + "\n expected tags: " + tags.ToDisplay()
                                                   + "\n predicted sentence: "
                                                   + predsSample.Sentence.ToArray().ToDisplay()
                                                   + "\n predicted tags: "
                                                   + predsSample.Tags.ToArray().ToDisplay());
                }
            }

            return(predsSample.Preds.ToArray());
        }