Exemple #1
0
        /// <summary>
        /// Returns the variant of the word identified by the supplied string.
        /// If the variant doesn't exist then it will be created, unless readOnly was true
        /// in which case null will be returned.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <param name="readOnly">if set to <c>true</c> [read only].</param>
        /// <returns>The word variant</returns>
        public WordVariant LookupVariant(string str, bool readOnly)
        {
            if (!readOnly)
            {
                this.Count++;
            }

            foreach (var v in this.Variants.Where(v => v.Text.Equals(str)))
            {
                if (!readOnly)
                {
                    v.Count++;
                }

                return(v);
            }

            if (readOnly)
            {
                return(null);
            }

            WordVariant wv = new WordVariant {
                Text = str, Count = 1
            };

            this.Variants.Add(wv);
            return(wv);
        }
Exemple #2
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            WordVariant wv = this.MostCommonVariant;

            return(wv == null ? "<null>" : wv.Text);
        }