What you want to do is find a vector representation of those strings which are in your $X$ vector. Two such techniques are Bag-of-Words and $n$-grams.
Bag-of-Words (BoW)
This technique will build a dictionary with all the words that exist in your training set. Then we will build a vector with the count of each word in each instance. For example let's consider these three separate instances:
- 'hi'
- 'i am bussy'
- 'how are you doing?'
Then we can see that the following "words" in this training set are: hi, i, am, bussy, how, are, you, doing. So the vector representation of the above strings would be:
- [1, 0, 0, 0, 0, 0, 0, 0]
- [0, 1, 1, 1, 0, 0, 0, 0]
- [0, 0, 0, 0, 1, 1, 1, 1]
There are ways to make this technique more effective by removing tenses from verbs or plurality of words. This is called stemming and should be used with BoW.
n-grams
n-grams is a feature extraction technique for language based data. It segments the Strings such that roots of words can be found, ignoring verb endings, pluralities etc...
The segmentation works as follows:
The String: Hello World
2-gram: "He", "el", "ll", "lo", "o ", " W", "Wo", "or", "rl", "ld"
3-gram: "Hel", "ell", "llo", "lo ", "o W", " Wo", "Wor", "orl", "rld"
4-gram: "Hell", "ello", "llo ", "lo W", "o Wo", " Wor", "Worl", "orld"
Thus in your example, if we use 4-grams, truncations of the word Hello would appear to be the same. And this similarity would be captured by your features. Then you can vectorize the results of the $n$-gram in the same way as BoW.
Term Frequency-Inverse Document Frequency (TF-IDF)
Both of the above techniques can be enhanced with TF-IDF. This removes words that appear too often and do not have much information about the string, for example: the, like, a, ab, is...
For a term $t$ in a string $s$, the weight for that term is given by
$W_{t,s} = TF_{t,s} log(\frac{N}{DF_t})$
where N is the number of strings in your corpus, $TF$ is the number of times the term appeared in the given instance string and $DF$ is the number of documents in which the term appears.