NClassifier.Bayesian.BayesianClassifier.TransformWord C# (CSharp) Method

TransformWord() public method

Allows transformations to be done to the given word.
public TransformWord ( string word ) : string
word string The word to transform.
return string
        public string TransformWord(string word)
        {
            if (word != null)
            {
                if (!_isCaseSensitive)
                    return word.ToLower();
                else
                    return word;
            }
            else
                throw new ArgumentNullException("Word cannot be null.");
        }

Usage Example

        public void TestTransformWord()
        {
            var classifier = new BayesianClassifier();
            Assert.IsFalse(classifier.IsCaseSensitive);

            string word = null;
            try
            {
                classifier.TransformWord(word);
                Assert.Fail("No exception thrown when null passed.");
            }
            catch {}

            word = "myWord";
            Assert.AreEqual(word.ToLower(), classifier.TransformWord(word));

            classifier.IsCaseSensitive = true;
            Assert.AreEqual(word, classifier.TransformWord(word));
        }