                  compound = keyw_nounphrases$keyword, ngram = keyw_nounphrases$ngram)
<span class="hljs-comment">## Keep keyword or just plain nouns</span>
x$term &lt;- ifelse(x$upos %<span class="hljs-keyword">in</span>% <span class="hljs-string">"NOUN"</span>, x$term,
                 ifelse(x$term %<span class="hljs-keyword">in</span>% c(keyw_rake$keyword, keyw_nounphrases$keyword), x$term, <span class="hljs-literal">NA</span>))

<span class="hljs-comment">## Build document/term/matrix</span>
dtm &lt;- 