N-grams: Difference between revisions

Content added Content deleted
Line 85: Line 85:
def ngrams($n):
def ngrams($n):
ascii_upcase as $text
ascii_upcase as $text
| bow( range(0;$text|length - $n) as $i | $text[$i:$i+$n]);
| bow( range(0;$text|1+ length - $n) as $i | $text[$i:$i+$n]);


# The task
# The task
Line 98: Line 98:
{{output}}
{{output}}
<pre>
<pre>
<pre>

All 2-grams of 'Live and let live' and their frequencies:
All 2-grams of 'Live and let live' and their frequencies:
A: 1
A: 1
Line 107: Line 109:
ND: 1
ND: 1
T : 1
T : 1
VE: 1
L: 2
L: 2
IV: 2
IV: 2
LI: 2
LI: 2
VE: 2


All 3-grams of 'Live and let live' and their frequencies:
All 3-grams of 'Live and let live' and their frequencies:
Line 120: Line 122:
E A: 1
E A: 1
ET : 1
ET : 1
IVE: 1
LET: 1
LET: 1
ND : 1
ND : 1
T L: 1
T L: 1
VE : 1
VE : 1
IVE: 2
LIV: 2
LIV: 2


Line 137: Line 139:
IVE : 1
IVE : 1
LET : 1
LET : 1
LIVE: 1
ND L: 1
ND L: 1
T LI: 1
T LI: 1
VE A: 1
VE A: 1
LIVE: 2
</pre>
</pre>
</pre>