Jaccard similarity in stringdist package to match words in character string
<p>I would like to use the Jaccard similarity in the stringdist function to determine the similarity of bags of words.  From what I can tell, using Jaccard only matches by letters within a character string.  </p>

<pre><code>c &lt;- c('cat', 'dog', 'person')
d &lt;- c('cat', 'dog', 'ufo')

stringdist(c, d, method='jaccard', q=2)
[1] 0 0 1
</code></pre>

<p>So we see here that it calculates the similarity of 'cat' and 'cat', 'dog' and 'dog' and 'person' and 'ufo'.  </p>

<p>I also tried converting the words into 1 long text string.  The following approaches what I need, but it's still calculating 1 - (number of shared 2-grams / number of total unique 2-grams):</p>

<pre><code>f &lt;- 'cat dog person'
g &lt;- 'cat dog ufo'
stringdist(f, g, method='jaccard', q=2)
[1] 0.5625
</code></pre>

<p>How would I get it to calculate similarity by the words?</p>