<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">[I'm blocked from posting to CWBdev once again, so here's a direct re-send]<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><br class="Apple-interchange-newline"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">From: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Stefan Evert &lt;<a href="mailto:stefanML@collocations.de" class="">stefanML@collocations.de</a>&gt;<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Subject: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">Re: [CWB] Ngrams in CWB</b><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Date: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">16 March 2018 at 18:24:07 CET<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">To: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">CWBdev Mailing List &lt;<a href="mailto:cwb@sslmit.unibo.it" class="">cwb@sslmit.unibo.it</a>&gt;<br class=""></span></div><br class=""><div class=""><div class=""><blockquote type="cite" class="">in CWB, is there a way to detect ngrams (e.g. trigrams) with one defined lexical item but without defining its exact position? I could merge the results of, say,<br class=""><br class="">"word"[][]<br class="">[]"word"[]<br class="">[][]"word"<br class=""></blockquote><br class="">There is no convenient way of doing this: you'll have to run three queries (or three passes with cwb-scan-corpus) and merge the results. &nbsp;You could formally write it as a single query<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>A = "word" [] [] | [] "word" [] | [] [] "word"<br class=""><br class="">but that's horribly inefficient for larger corpora.<br class=""><br class="">If "word" is relatively rare, the most efficient approach should be as follows (assuming that "word" isn't at the start or end of the corpus, in which case it would create additional bigram and unigram entries in your trigram table):<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>W = "word";<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Tri = W;<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>set Tri matchend rightmost [] within right 2 words; # "word" [] []<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>A = W;<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>set A match leftmost [] within left 1 word; &nbsp;# [] "word" []<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>set A matchend rightmost [] within right 1 word;<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Tri = union Tri A;<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>A = W;<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>set A match leftmost [] within left 2 words; # [] [] "word"<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Tri = union Tri A;<br class=""><br class="">I agree this isn't the most intuitive and convenient code …<br class=""><br class="">Stefan</div></div></blockquote></div><br class=""></body></html>