/// <summary>
        /// Initializes a new instance of the <see cref="BrownBigramFeatureGenerator"/> class.
        /// </summary>
        /// <param name="brownLexicon">The Brown lexicon.</param>
        /// <exception cref="System.ArgumentNullException">brownLexicon</exception>
        public BrownBigramFeatureGenerator(BrownCluster brownLexicon)
        {
            if (brownLexicon == null)
            {
                throw new ArgumentNullException(nameof(brownLexicon));
            }

            this.brownLexicon = brownLexicon;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BrownTokenClassFeatureGenerator"/> class.
        /// </summary>
        /// <param name="brownLexicon">The Brown lexicon.</param>
        /// <exception cref="System.ArgumentNullException">brownLexicon</exception>
        public BrownTokenClassFeatureGenerator(BrownCluster brownLexicon)
        {
            if (brownLexicon == null)
            {
                throw new ArgumentNullException("brownLexicon");
            }

            this.brownLexicon = brownLexicon;
        }
        /// <summary>
        /// It provides a list containing the pathLengths for a token if found in the <see cref="BrownCluster"/>.
        /// </summary>
        /// <param name="token">The token to be looked up in the brown clustering map.</param>
        /// <param name="brownLexicon">The Brown clustering map.</param>
        /// <returns>The list of the paths for a token.</returns>
        public static List<string> GetWordClasses(string token, BrownCluster brownLexicon) {
            if (brownLexicon[token] == null)
                return new List<string>();

            var brownClass = brownLexicon[token];

            var pathLengthsList = new List<string> {
                brownClass.Substring(0, Math.Min(brownClass.Length, pathLengths[0]))
            };

            for (var i = 1; i < pathLengths.Length; i++) {
                if (pathLengths[i - 1] < brownClass.Length) {
                    pathLengthsList.Add(brownClass.Substring(0, Math.Min(brownClass.Length, pathLengths[i])));
                }
            }
            return pathLengthsList;
        }
Beispiel #4
0
        /// <summary>
        /// It provides a list containing the pathLengths for a token if found in the <see cref="BrownCluster"/>.
        /// </summary>
        /// <param name="token">The token to be looked up in the brown clustering map.</param>
        /// <param name="brownLexicon">The Brown clustering map.</param>
        /// <returns>The list of the paths for a token.</returns>
        public static List <string> GetWordClasses(string token, BrownCluster brownLexicon)
        {
            if (brownLexicon[token] == null)
            {
                return(new List <string>());
            }

            var brownClass = brownLexicon[token];

            var pathLengthsList = new List <string> {
                brownClass.Substring(0, Math.Min(brownClass.Length, pathLengths[0]))
            };

            for (var i = 1; i < pathLengths.Length; i++)
            {
                if (pathLengths[i - 1] < brownClass.Length)
                {
                    pathLengthsList.Add(brownClass.Substring(0, Math.Min(brownClass.Length, pathLengths[i])));
                }
            }
            return(pathLengthsList);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BrownTokenClassFeatureGenerator"/> class.
        /// </summary>
        /// <param name="brownLexicon">The Brown lexicon.</param>
        /// <exception cref="System.ArgumentNullException">brownLexicon</exception>
        public BrownTokenClassFeatureGenerator(BrownCluster brownLexicon) {
            if (brownLexicon == null)
                throw new ArgumentNullException("brownLexicon");

            this.brownLexicon = brownLexicon;
        }